From f4159bd54ca3bac51feaff272d560bf1a6ab0f85 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 4 Jun 2023 10:48:04 +0200 Subject: [PATCH] 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 --- src/Makefile.am | 2 +- src/db.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 09e9101d..380e34a9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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" \ >> "$@" diff --git a/src/db.c b/src/db.c index 23dcbbcd..cfe34c3b 100644 --- a/src/db.c +++ b/src/db.c @@ -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"