laforge has uploaded this change for review.
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
---
M src/Makefile.am
M src/db.c
2 files changed, 24 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/63/33163/1
diff --git a/src/Makefile.am b/src/Makefile.am
index 09e9101..380e34a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -111,7 +111,7 @@
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 23dcbbc..cfe34c3 100644
--- a/src/db.c
+++ b/src/db.c
@@ -235,7 +235,7 @@
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 @@
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 @@
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 @@
"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_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_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_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"
To view, visit change 33163. To unsubscribe, or for help writing mail filters, visit settings.