Changeset: dc85db7d9402 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/dc85db7d9402
Modified Files:
        clients/mapiclient/dump.c
        clients/odbc/winsetup/install.c
        common/stream/stdio_stream.c
        geom/monetdb5/geom.c
        monetdb5/mal/mal_session.c
        sql/backends/monet5/UDF/capi/capi.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_bincopy.c
        sql/backends/monet5/sql_bincopyconvert.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/vaults/csv/csv.c
        sql/server/sql_semantic.c
        sql/storage/store.c
        tools/monetdbe/monetdbe.c
Branch: default
Log Message:

Turn constant pointers to constant string into constant arrays.


diffs (truncated from 519 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -2654,9 +2654,9 @@ bailout:
 int
 dump_database(Mapi mid, stream *sqlf, const char *ddir, const char *ext, bool 
describe, bool useInserts, bool noescape)
 {
-       const char *start_trx = "START TRANSACTION";
-       const char *end = "ROLLBACK";
-       const char *types =
+       const char start_trx[] = "START TRANSACTION";
+       const char end[] = "ROLLBACK";
+       const char types[] =
                "SELECT s.name, "
                       "t.systemname, "
                       "t.sqlname "
@@ -2708,13 +2708,13 @@ dump_database(Mapi mid, stream *sqlf, co
                  "AND ui.name <> 'monetdb' "
                  "AND ui.name <> '.snapshot' "
                "ORDER BY ui.name";
-       const char *roles =
+       const char roles[] =
                "SELECT name "
                "FROM sys.auths "
                "WHERE name NOT IN (SELECT name FROM sys.db_user_info) "
                  "AND grantor <> 0 "
                "ORDER BY name";
-       const char *grants =
+       const char grants[] =
                /* all grants granting roles to users excepting the default 
role */
                "SELECT a1.name, "
                       "a2.name "
@@ -2727,7 +2727,7 @@ dump_database(Mapi mid, stream *sqlf, co
                  "AND a1.name = ui.name "
                  "AND a2.id <> ui.default_role "
                "ORDER BY a1.name, a2.name";
-       const char *table_grants =
+       const char table_grants[] =
                "SELECT s.name, t.name, "
                       "a.name, "
                       "sum(p.privileges), "
@@ -2744,7 +2744,7 @@ dump_database(Mapi mid, stream *sqlf, co
                  "AND p.grantable = go.id "
                "GROUP BY s.name, t.name, a.name, g.name, go.opt "
                "ORDER BY s.name, t.name, a.name, g.name, go.opt";
-       const char *column_grants =
+       const char column_grants[] =
                "SELECT s.name, t.name, "
                       "c.name, a.name, "
                       "pc.privilege_code_name, "
@@ -2766,7 +2766,7 @@ dump_database(Mapi mid, stream *sqlf, co
                  "AND p.privileges = pc.privilege_code_id "
                  "AND p.grantable = go.id "
                "ORDER BY s.name, t.name, c.name, a.name, g.name, p.grantable";
-       const char *function_grants =
+       const char function_grants[] =
                "SELECT f.id, "
                           "s.name, "
                           "f.name, "
@@ -2803,7 +2803,7 @@ dump_database(Mapi mid, stream *sqlf, co
                                 "f.id, "
                                 "a.inout DESC, "
                                 "a.number";
-       const char *global_grants =
+       const char global_grants[] =
                "SELECT a.name, pc.grnt, g.name, go.opt "
                "FROM sys.privileges p, "
                     "sys.auths a, "
@@ -2816,22 +2816,22 @@ dump_database(Mapi mid, stream *sqlf, co
                  "AND p.privileges = pc.id "
                  "AND p.grantable = go.id "
                "ORDER BY a.name, g.name, go.opt";
-       const char *schemas =
+       const char schemas[] =
                "SELECT s.name, a.name, rem.remark "
                "FROM sys.schemas s LEFT OUTER JOIN sys.comments rem ON s.id = 
rem.id, "
                     "sys.auths a "
                "WHERE s.\"authorization\" = a.id "
                  "AND s.system = FALSE "
                "ORDER BY s.name";
-       const char *sequences1 =
+       const char sequences1[] =
                "SELECT sch.name, seq.name, rem.remark "
                "FROM sys.schemas sch, "
                     "sys.sequences seq LEFT OUTER JOIN sys.comments rem ON 
seq.id = rem.id "
                "WHERE sch.id = seq.schema_id "
                "ORDER BY sch.name, seq.name";
-       const char *sequences2 =
+       const char sequences2[] =
                "SELECT * FROM sys.describe_sequences ORDER BY sch, seq";
-       const char *tables =
+       const char tables[] =
                "SELECT t.id AS id, "
                           "s.name AS sname, "
                           "t.name AS name, "
@@ -2891,7 +2891,7 @@ dump_database(Mapi mid, stream *sqlf, co
                "ORDER BY t1.id, t2.id";
        /* we must dump views, functions/procedures and triggers in order
         * of creation since they can refer to each other */
-       const char *views_functions_triggers =
+       const char views_functions_triggers[] =
                "with vft (sname, name, id, query, remark) AS ("
                        "SELECT s.name AS sname, " /* views */
                               "t.name AS name, "
diff --git a/clients/odbc/winsetup/install.c b/clients/odbc/winsetup/install.c
--- a/clients/odbc/winsetup/install.c
+++ b/clients/odbc/winsetup/install.c
@@ -22,10 +22,10 @@
 #define DLL ".dll"
 #endif
 
-static const char *DriverName = "MonetDB ODBC Driver";
-static const char *DataSourceName = "MonetDB";
-static const char *DriverDLL = "MonetODBC" DLL;
-static const char *DriverDLLs = "MonetODBCs" DLL;
+static const char DriverName[] = "MonetDB ODBC Driver";
+static const char DataSourceName[] = "MonetDB";
+static const char DriverDLL[] = "MonetODBC" DLL;
+static const char DriverDLLs[] = "MonetODBCs" DLL;
 
 /* General error handler for installer functions */
 
@@ -85,7 +85,7 @@ InstallMyDriver(const char *driverpath, 
        /* the correct format of driver keywords are
         * "DriverName\0Driver=...\xxxxxx.DLL\0Setup=...\xxxxxx.DLL\0\0" */
 
-       size_t driverlen = strlen(drivername) + 2 * strlen(driverpath) + 
strlen(DriverDLL) + strlen(DriverDLLs) + 90;
+       size_t driverlen = strlen(drivername) + 2 * strlen(driverpath) + 
sizeof(DriverDLL) + sizeof(DriverDLLs) + 90;
        char *driver = malloc(driverlen);
        snprintf(driver, driverlen,
                         "%s;Driver=%s\\%s;Setup=%s\\%s;APILevel=1;"
diff --git a/common/stream/stdio_stream.c b/common/stream/stdio_stream.c
--- a/common/stream/stdio_stream.c
+++ b/common/stream/stdio_stream.c
@@ -372,7 +372,7 @@ file_wstream(FILE *restrict fp, bool bin
 stream *
 stdin_rastream(void)
 {
-       const char *name = "<stdin>";
+       const char name[] = "<stdin>";
        // Make an attempt to skip a BOM marker.
        // It would be nice to integrate this with with the BOM removal code
        // in text_stream.c but that is complicated. In text_stream,
@@ -403,7 +403,7 @@ stdin_rastream(void)
 stream *
 stdout_wastream(void)
 {
-       const char *name = "<stdout>";
+       const char name[] = "<stdout>";
 #ifdef _MSC_VER
        if (isatty(fileno(stdout)))
                return win_console_out_stream(name);
@@ -414,7 +414,7 @@ stdout_wastream(void)
 stream *
 stderr_wastream(void)
 {
-       const char *name = "<stderr>";
+       const char name[] = "<stderr>";
 #ifdef _MSC_VER
        if (isatty(fileno(stderr)))
                return win_console_out_stream(name);
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2648,7 +2648,7 @@ wkbAsText(char **txt, wkb **geomWKB, int
 {
        size_t len = 0;
        char *wkt = NULL;
-       const char *sridTxt = "SRID:";
+       const char sridTxt[] = "SRID:";
 
        if (is_wkb_nil(*geomWKB) || (withSRID && is_int_nil(*withSRID))) {
                if ((*txt = GDKstrdup(str_nil)) == NULL)
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -156,7 +156,7 @@ exit_streams(bstream *fin, stream *fout)
                bstream_destroy(fin);
 }
 
-const char *mal_enableflag = "mal_for_all";
+static const char mal_enableflag[] = "mal_for_all";
 
 static bool
 is_exiting(void *data)
diff --git a/sql/backends/monet5/UDF/capi/capi.c 
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -36,9 +36,9 @@
 #pragma GCC diagnostic ignored "-Wclobbered"
 #endif
 
-const char *mprotect_enableflag = "enable_mprotect";
+static const char mprotect_enableflag[] = "enable_mprotect";
 static bool option_enable_mprotect = false;
-const char *longjmp_enableflag = "enable_longjmp";
+static const char longjmp_enableflag[] = "enable_longjmp";
 static bool option_enable_longjmp = false;
 
 typedef struct _allocated_region {
@@ -342,12 +342,14 @@ static void blob_initialize(struct cudf_
                bat_data->null_value = tpe##_nil;                               
       \
        }
 
-const char *debug_flag = "capi_use_debug";
-const char *cc_flag = "capi_cc";
-const char *cpp_flag = "capi_cpp";
+#ifdef NDEBUG
+static const char debug_flag[] = "capi_use_debug";
+#endif
+static const char cc_flag[] = "capi_cc";
+static const char cpp_flag[] = "capi_cpp";
 
-const char *cflags_pragma = "#pragma CFLAGS ";
-const char *ldflags_pragma = "#pragma LDFLAGS ";
+static const char cflags_pragma[] = "#pragma CFLAGS ";
+static const char ldflags_pragma[] = "#pragma LDFLAGS ";
 
 #define JIT_COMPILER_NAME "cc"
 #define JIT_CPP_COMPILER_NAME "c++"
@@ -481,7 +483,7 @@ static str CUDFeval(Client cntxt, MalBlk
                                                                           : 
JIT_CPP_COMPILER_NAME)
                                : (GDKgetenv(cc_flag) ? GDKgetenv(cc_flag) : 
JIT_COMPILER_NAME);
 
-       const char *struct_prefix = "struct cudf_data_struct_";
+       const char struct_prefix[] = "struct cudf_data_struct_";
        const char *funcname;
 
        BUN expression_hash = 0, funcname_hash = 0;
@@ -672,7 +674,7 @@ static str CUDFeval(Client cntxt, MalBlk
                // we place the temporary files in the DELDIR directory
                // because this will be removed again upon server startup
                const int RANDOM_NAME_SIZE = 32;
-               const char *prefix = TEMPDIR_NAME DIR_SEP_STR;
+               const char prefix[] = TEMPDIR_NAME DIR_SEP_STR;
                size_t prefix_size = strlen(prefix);
                char *deldirpath;
 
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -346,7 +346,7 @@ create_table_or_view(mvc *sql, char *sna
 
                if (c->def) {
                        /* TODO please don't place an auto incremented sequence 
in the default value */
-                       const char *next_value_for = "next value for 
\"sys\".\"seq_";
+                       const char next_value_for[] = "next value for 
\"sys\".\"seq_";
                        sql_rel *r = NULL;
 
                        sa_reset(nsa);
@@ -1983,7 +1983,7 @@ mvc_clear_table_wrap(Client cntxt, MalBl
                throw(SQL, "sql.clear_table", SQLSTATE(42000) "Table clear 
failed%s", clear_res == (BUN_NONE - 1) ? " due to conflict with another 
transaction" : "");
        if (restart_sequences) { /* restart the sequences if it's the case */
                sql_trans *tr = m->session->tr;
-               const char *next_value_for = "next value for ";
+               const char next_value_for[] = "next value for ";
 
                for (node *n = ol_first_node(t->columns); n; n = n->next) {
                        sql_column *col = n->data;
diff --git a/sql/backends/monet5/sql_bincopy.c 
b/sql/backends/monet5/sql_bincopy.c
--- a/sql/backends/monet5/sql_bincopy.c
+++ b/sql/backends/monet5/sql_bincopy.c
@@ -34,7 +34,7 @@
 static str
 load_trivial(BAT *bat, stream *s, const char *filename, bincopy_validate_t 
validate, int width, BUN rows_estimate, int *eof_seen)
 {
-       const char *mal_operator = "sql.importColumn";
+       const char mal_operator[] = "sql.importColumn";
        str msg = MAL_SUCCEED;
        int tt = BATttype(bat);
        const size_t asz = (size_t) ATOMsize(tt);
@@ -114,7 +114,7 @@ end:
 static str
 load_fixed_width(BAT *bat, stream *s, const char *filename, int width, bool 
byteswap, bincopy_decoder_t convert, bincopy_validate_t validate, size_t 
record_size, int *eof_reached)
 {
-       const char *mal_operator = "sql.importColumn";
+       const char mal_operator[] = "sql.importColumn";
        str msg = MAL_SUCCEED;
        bstream *bs = NULL;
 
@@ -184,7 +184,7 @@ end:
 static str
 load_column(type_record_t *rec, const char *name, BAT *bat, stream *s, int 
width, bool byteswap, BUN rows_estimate, int *eof_reached)
 {
-       const char *mal_operator = "sql.importColumn";
+       const char mal_operator[] = "sql.importColumn";
        BUN orig_count, new_count;
        str msg = MAL_SUCCEED;
        BUN rows_added;
@@ -328,7 +328,7 @@ mvc_bin_import_column_wrap(Client cntxt,
 static str
 write_out(const char *start, const char *end, stream *s)
 {
-       const char *mal_operator = "sql.export_bin_column";
+       const char mal_operator[] = "sql.export_bin_column";
        str msg = MAL_SUCCEED;
 
        const char *p = start;
@@ -356,7 +356,7 @@ dump_trivial(BAT *b, stream *s, BUN star
 static str
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to