src/db.c: Switch from "const char *statements" to "const char * const"

This is primarily to make the linter happy, which spews "static const
char * array should probably be static const char * const" errors in
gerrit when adding similar new code to this existing file.  So let's
first convert the old code and then add new code that makes the linter
happy.  I guess it does have a point, as both the individual string
pointers as well as the array of the pointers are constant.

Change-Id: I39e9fb6bd8052f4878cfc95061775bf940631ae5
This commit is contained in:
Harald Welte 2023-06-04 10:48:04 +02:00
parent a854b48762
commit f4159bd54c
2 changed files with 8 additions and 8 deletions

View File

@ -111,7 +111,7 @@ BOOTSTRAP_SQL = $(top_srcdir)/sql/hlr.sql
db_bootstrap.h: $(BOOTSTRAP_SQL) $(srcdir)/db_sql2c.sed
echo "/* DO NOT EDIT THIS FILE. It is generated from files in osmo-hlr.git/sql/ */" > "$@"
echo "#pragma once" >> "$@"
echo "static const char *stmt_bootstrap_sql[] = {" >> "$@"
echo "static const char * const stmt_bootstrap_sql[] = {" >> "$@"
cat "$(BOOTSTRAP_SQL)" \
| sed -f "$(srcdir)/db_sql2c.sed" \
>> "$@"

View File

@ -235,7 +235,7 @@ void db_close(struct db_context *dbc)
talloc_free(dbc);
}
static int db_run_statements(struct db_context *dbc, const char **statements, size_t statements_count)
static int db_run_statements(struct db_context *dbc, const char * const *statements, size_t statements_count)
{
int rc = 0;
int i;
@ -308,7 +308,7 @@ static int
db_upgrade_v1(struct db_context *dbc)
{
int rc;
const char *statements[] = {
const char * const statements[] = {
"ALTER TABLE subscriber ADD COLUMN last_lu_seen TIMESTAMP default NULL",
"PRAGMA user_version = 1",
};
@ -324,7 +324,7 @@ db_upgrade_v1(struct db_context *dbc)
static int db_upgrade_v2(struct db_context *dbc)
{
int rc;
const char *statements[] = {
const char * const statements[] = {
"ALTER TABLE subscriber ADD COLUMN imei VARCHAR(14)",
"PRAGMA user_version = 2",
};
@ -437,7 +437,7 @@ static int db_upgrade_v3(struct db_context *dbc)
"ms_purged_ps," \
"last_lu_seen"
const char *statements[] = {
const char * const statements[] = {
"BEGIN TRANSACTION",
"CREATE TEMPORARY TABLE subscriber_backup" SUBSCR_V3_CREATE,
"INSERT INTO subscriber_backup SELECT " SUBSCR_V2_COLUMN_NAMES " FROM subscriber",
@ -460,7 +460,7 @@ static int db_upgrade_v3(struct db_context *dbc)
static int db_upgrade_v4(struct db_context *dbc)
{
int rc;
const char *statements[] = {
const char * const statements[] = {
"ALTER TABLE subscriber ADD COLUMN last_lu_seen_ps TIMESTAMP default NULL",
"PRAGMA user_version = 4",
};
@ -476,7 +476,7 @@ static int db_upgrade_v4(struct db_context *dbc)
static int db_upgrade_v5(struct db_context *dbc)
{
int rc;
const char *statements[] = {
const char * const statements[] = {
"ALTER TABLE subscriber ADD COLUMN vlr_via_proxy VARCHAR",
"ALTER TABLE subscriber ADD COLUMN sgsn_via_proxy VARCHAR",
"PRAGMA user_version = 5",
@ -493,7 +493,7 @@ static int db_upgrade_v5(struct db_context *dbc)
static int db_upgrade_v6(struct db_context *dbc)
{
int rc;
const char *statements[] = {
const char * const statements[] = {
"CREATE TABLE ind (\n"
" -- 3G auth IND pool to be used for this VLR\n"
" ind INTEGER PRIMARY KEY,\n"