Changeset: bd0ccd74eec9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bd0ccd74eec9
Modified Files:
clients/mapilib/connect.c
clients/mapilib/connect_openssl.c
clients/mapilib/msettings.c
common/stream/socket_stream.c
gdk/gdk_atoms.c
geom/monetdb5/geom.c
monetdb5/extras/rapi/rapi.c
monetdb5/mal/mal_embedded.c
monetdb5/modules/mal/batcalc.c
sql/backends/monet5/UDF/pyapi3/formatinput3.c
sql/backends/monet5/UDF/pyapi3/pyapi3.c
sql/backends/monet5/UDF/pyapi3/pyloader3.c
sql/backends/monet5/sql_upgrades.c
sql/server/rel_sequence.c
sql/server/sql_mvc.c
tools/merovingian/client/monetdb.c
tools/merovingian/utils/control.c
tools/mserver/shutdowntest.c
Branch: Dec2025
Log Message:
Declare vars in funcs that are only read and initialized to constants as static.
If possible, also declare them as const. (Some functions where some of
these vars are used are declared improperly for them to be const.)
diffs (truncated from 382 to 300 lines):
diff --git a/clients/mapilib/connect.c b/clients/mapilib/connect.c
--- a/clients/mapilib/connect.c
+++ b/clients/mapilib/connect.c
@@ -519,7 +519,7 @@ mapi_handshake(Mapi mid)
close_connection(mid);
return mid->error;
}
- char *algsv[] = {
+ static const char *algsv[] = {
"RIPEMD160",
"SHA512",
"SHA384",
@@ -528,7 +528,7 @@ mapi_handshake(Mapi mid)
"SHA1",
NULL
};
- char **algs = algsv;
+ const char **algs = algsv;
/* rBuCQ9WTn3:mserver:9:RIPEMD160,SHA256,SHA1,MD5:LIT:SHA1: */
diff --git a/clients/mapilib/connect_openssl.c
b/clients/mapilib/connect_openssl.c
--- a/clients/mapilib/connect_openssl.c
+++ b/clients/mapilib/connect_openssl.c
@@ -269,7 +269,7 @@ wrap_tls(Mapi mid, SOCKET sock)
return croak_openssl(mid, __func__,
"X509_VERIFY_PARAM_set1_host");
}
- unsigned char alpn_vector[] = { 6, 'm', 'a', 'p', 'i', '/', '9' };
+ static const unsigned char alpn_vector[] = { 6, 'm', 'a', 'p', 'i',
'/', '9' };
// NOTE: these functions return 0 on success, not 1!
if (0 != SSL_set_alpn_protos(ssl, alpn_vector, sizeof(alpn_vector))) {
BIO_free_all(bio);
diff --git a/clients/mapilib/msettings.c b/clients/mapilib/msettings.c
--- a/clients/mapilib/msettings.c
+++ b/clients/mapilib/msettings.c
@@ -40,7 +40,7 @@ msettings_malloc_failed(msettings_error
int msetting_parse_bool(const char *text)
{
- static struct { const char *word; bool value; } variants[] = {
+ static const struct { const char *word; bool value; } variants[] = {
{ "true", true },
{ "false", false },
{ "yes", true },
diff --git a/common/stream/socket_stream.c b/common/stream/socket_stream.c
--- a/common/stream/socket_stream.c
+++ b/common/stream/socket_stream.c
@@ -172,7 +172,7 @@ socket_getoob_unix(stream *s)
static int
socket_putoob_unix(stream *s, char val)
{
- char buf[3] = {
+ const char buf[3] = {
OOBMSG0,
OOBMSG1,
val,
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1569,7 +1569,7 @@ inet6_classify(char c)
{
/* The values in this table are all one too high so the invalid
* ones can be left at 0. */
- static uint8_t table[256] = {
+ static const uint8_t table[256] = {
['0'] = 0 + 1, ['1'] = 1 + 1, ['2'] = 2 + 1,
['3'] = 3 + 1, ['4'] = 4 + 1, ['5'] = 5 + 1,
['6'] = 6 + 1, ['7'] = 7 + 1, ['8'] = 8 + 1,
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2123,7 +2123,7 @@ dumpPointsPolygon(Client ctx, BAT *idBAT
const int lvlDigitsNum = 10; //MAX_UNIT = 4,294,967,295
size_t pathLength = strlen(path);
char *newPath;
- const char extraStr[] = ",";
+ static const char extraStr[] = ",";
int extraLength = 1;
//get the exterior ring of the polygon
@@ -2180,7 +2180,7 @@ dumpPointsMultiGeometry(Client ctx, BAT
unsigned int lvl = 0;
size_t pathLength = strlen(path);
char *newPath = NULL;
- const char extraStr[] = ",";
+ static const char extraStr[] = ",";
int extraLength = 1;
geometriesNum = GEOSGetNumGeometries_r(geoshandle, geosGeometry);
@@ -2724,7 +2724,7 @@ wkbAsText(Client ctx, char **txt, wkb **
allocator *ma = ctx->curprg->def->ma;
size_t len = 0;
char *wkt = NULL;
- const char sridTxt[] = "SRID:";
+ static const char sridTxt[] = "SRID:";
if (is_wkb_nil(*geomWKB) || (withSRID && is_int_nil(*withSRID))) {
*txt = (char *) str_nil;
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -423,7 +423,7 @@ static char *RAPIinitialize(void) {
// set some command line arguments
{
structRstart rp;
- char *rargv[] = { "R",
+ static /*const*/ char *rargv[] = { "R",
#if R_VERSION >= R_Version(4,0,0)
"--no-echo",
#else
diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c
--- a/monetdb5/mal/mal_embedded.c
+++ b/monetdb5/mal/mal_embedded.c
@@ -121,7 +121,7 @@ malEmbeddedBoot(int workerlimit, int mem
MT_thread_set_qry_ctx(qc_old);
return msg;
}
- char *modules[7] = { "embedded", "sql", "generator", "udf", "csv",
"monetdb_loader" };
+ static /*const*/ char *modules[7] = { "embedded", "sql", "generator",
"udf", "csv", "monetdb_loader" };
if ((msg = malIncludeModules(c, modules, 0, !with_mapi_server, NULL))
!= MAL_SUCCEED) {
MCcloseClient(c);
MT_thread_set_qry_ctx(qc_old);
diff --git a/monetdb5/modules/mal/batcalc.c b/monetdb5/modules/mal/batcalc.c
--- a/monetdb5/modules/mal/batcalc.c
+++ b/monetdb5/modules/mal/batcalc.c
@@ -1340,7 +1340,7 @@ batcalc_init(void)
}
/* possibly add the min/max + _no_nil */
/* binops on numeric types */
- struct {
+ static const struct {
char *op;
char *fname;
char *fname_el;
@@ -1444,7 +1444,7 @@ batcalc_init(void)
}
}
}
- struct {
+ static const struct {
char *op;
char *fname;
char *fname_el;
@@ -1496,7 +1496,7 @@ batcalc_init(void)
}
}
}
- struct {
+ static const struct {
char *op;
char *fname;
MALfcn fcn;
@@ -1538,7 +1538,7 @@ batcalc_init(void)
}
}
}
- struct {
+ static const struct {
char *op;
char *fname;
MALfcn fcn;
@@ -1583,7 +1583,7 @@ batcalc_init(void)
err += melFunction(false, "batcalc", logops[f].op,
logops[f].fcn, logops[f].fname, false, logops[f].comment_v_, 1, 4, ret, varg,
arg, cand);
}
}
- struct {
+ static const struct {
char *op;
char *fname;
MALfcn fcn;
@@ -1627,7 +1627,7 @@ batcalc_init(void)
}
}
- struct {
+ static const struct {
char *op;
char *fname;
MALfcn fcn;
@@ -1679,7 +1679,7 @@ batcalc_init(void)
.comment_v_ = "Return B != V",
}
};
- int newtypes[] = {
+ const int newtypes[] = {
ATOMindex("json"),
ATOMindex("inet"),
ATOMindex("uuid"),
@@ -1770,7 +1770,7 @@ batcalc_init(void)
}
}
- struct {
+ static const struct {
char *op;
char *fname;
MALfcn fcn;
@@ -1830,7 +1830,7 @@ batcalc_init(void)
err += melFunction(false, "batcalc", "avg",
(MALfcn)&CMDcalcavg, "CMDcalcavg", false, "average and number of non-nil values
of B with candidates list", 2, 5, ret, nr, arg, cand, scale);
}
- struct {
+ static const struct {
int type;
char *name;
char *fname;
diff --git a/sql/backends/monet5/UDF/pyapi3/formatinput3.c
b/sql/backends/monet5/UDF/pyapi3/formatinput3.c
--- a/sql/backends/monet5/UDF/pyapi3/formatinput3.c
+++ b/sql/backends/monet5/UDF/pyapi3/formatinput3.c
@@ -108,8 +108,8 @@ char *FormatCode(char *code, char **args
bool multiline_statement = false;
int multiline_quotes = 0;
- char base_start[] = "def pyfun(";
- char base_end[] = "):\n";
+ static const char base_start[] = "def pyfun(";
+ static const char base_end[] = "):\n";
*msg = NULL;
(void)code_object;
diff --git a/sql/backends/monet5/UDF/pyapi3/pyapi3.c
b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
--- a/sql/backends/monet5/UDF/pyapi3/pyapi3.c
+++ b/sql/backends/monet5/UDF/pyapi3/pyapi3.c
@@ -160,7 +160,7 @@ static str PyAPIeval(Client cntxt, MalBl
bool freeexprStr = false;
int argcount = pci->argc;
- char *eval_additional_args[] = {"_columns", "_column_types", "_conn"};
+ static /*const*/ char *eval_additional_args[] = {"_columns",
"_column_types", "_conn"};
if (!pyapiInitialized) {
throw(MAL, "pyapi3.eval", SQLSTATE(PY000) "Embedded Python is
enabled but an error was "
diff --git a/sql/backends/monet5/UDF/pyapi3/pyloader3.c
b/sql/backends/monet5/UDF/pyapi3/pyloader3.c
--- a/sql/backends/monet5/UDF/pyapi3/pyloader3.c
+++ b/sql/backends/monet5/UDF/pyapi3/pyloader3.c
@@ -69,7 +69,7 @@ PYAPI3PyAPIevalLoader(Client cntxt, MalB
BUN nval = 0;
int ncols = 0;
- char *loader_additional_args[] = {"_emit", "_conn"};
+ static /*const*/ char *loader_additional_args[] = {"_emit", "_conn"};
if (!PYAPI3PyAPIInitialized()) {
throw(MAL, "pyapi3.eval",
diff --git a/sql/backends/monet5/sql_upgrades.c
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -152,7 +152,7 @@ sql_fix_system_tables(Client c, mvc *sql
static str
check_sys_tables(Client c, mvc *m, sql_schema *s)
{
- struct {
+ static const struct {
const char *name;
const char *func;
const char *type;
@@ -4495,7 +4495,7 @@ sql_update_mar2025(Client c, mvc *sql, s
sql_schema *is = mvc_bind_schema(sql,
"information_schema");
t = mvc_bind_table(sql, is, "parameters");
t->system = 0;
- char query[] = "update sys.functions set func =
replace(func, E'\\n external', E' ordered\\n external') where name in
('quantile','quantile_avg','median','median_avg') and schema_id = 2000 and
language = (select language_id from sys.function_languages where language_name
= 'MAL') and type = (select function_type_id from sys.function_types where
function_type_keyword = 'AGGREGATE') and not contains(func, 'ordered');\n"
+ static const char query[] = "update sys.functions set
func = replace(func, E'\\n external', E' ordered\\n external') where name in
('quantile','quantile_avg','median','median_avg') and schema_id = 2000 and
language = (select language_id from sys.function_languages where language_name
= 'MAL') and type = (select function_type_id from sys.function_types where
function_type_keyword = 'AGGREGATE') and not contains(func, 'ordered');\n"
"update sys.functions set func = replace(func,
E'\\n\\texternal', E' ordered\\n external') where name in
('quantile','quantile_avg','median','median_avg') and schema_id = 2000 and
language = (select language_id from sys.function_languages where language_name
= 'MAL') and type = (select function_type_id from sys.function_types where
function_type_keyword = 'AGGREGATE') and not contains(func, 'ordered');\n"
"update sys.functions set func = replace(func,
E'\\nexternal', E' ordered\\n external') where name in
('quantile','quantile_avg','median','median_avg') and schema_id = 2000 and
language = (select language_id from sys.function_languages where language_name
= 'MAL') and type = (select function_type_id from sys.function_types where
function_type_keyword = 'AGGREGATE') and not contains(func, 'ordered');\n"
"update sys.functions set func = replace(func,
E' external', E' with order\\n external') where name = 'group_concat' and
schema_id = 2000 and language = (select language_id from sys.function_languages
where language_name = 'MAL') and type = (select function_type_id from
sys.function_types where function_type_keyword = 'AGGREGATE');\n"
@@ -5149,7 +5149,7 @@ sql_update_dec2025(Client c, mvc *sql, s
return err;
if (sql_bind_func(sql, "sys", "optimizer_stats", NULL, NULL, F_UNION,
true, true)) {
- const char query[] = "drop function sys.optimizer_stats
cascade;\n";
+ static const char query[] = "drop function sys.optimizer_stats
cascade;\n";
printf("Running database upgrade commands:\n%s\n", query);
err = SQLstatementIntern(c, query, "update", true, false, NULL);
if (err)
@@ -5160,7 +5160,7 @@ sql_update_dec2025(Client c, mvc *sql, s
}
if (sql_bind_func(sql, "profiler", "start", NULL, NULL, F_PROC, true,
true)) {
- const char query[] = "drop procedure profiler.start cascade;\n"
+ static const char query[] = "drop procedure profiler.start
cascade;\n"
"drop procedure profiler.stop cascade;\n"
"drop procedure profiler.setlimit cascade;\n"
"drop function profiler.getlimit cascade;\n"
@@ -5215,7 +5215,7 @@ sql_update_dec2025(Client c, mvc *sql, s
fflush(stdout);
err = SQLstatementIntern(c, query, "update", true, false, NULL);
if (err == MAL_SUCCEED) {
- const char query2[] = "ALTER TABLE sys.keywords SET
READ ONLY;\n";
+ static const char query2[] = "ALTER TABLE sys.keywords
SET READ ONLY;\n";
printf("Running database upgrade commands:\n%s\n",
query2);
fflush(stdout);
err = SQLstatementIntern(c, query2, "update", true,
false, NULL);
@@ -5230,7 +5230,7 @@ sql_update_dec2025(Client c, mvc *sql, s
if (!sql_bind_func(sql, "sys", "to_hex", &tp, NULL, F_FUNC, true,
true)) {
sql->session->status = 0; /* if the function was not found
clean the error */
sql->errstr[0] = '\0';
- const char query[] = "create function to_hex(n int)\n"
+ static const char query[] = "create function to_hex(n int)\n"
"returns text external name \"calc\".\"to_hex\";\n"
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]