Mark misc static global variables as const
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 6 Aug 2024 20:04:48 +0000 (23:04 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 6 Aug 2024 20:04:48 +0000 (23:04 +0300)
Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi

contrib/btree_gist/btree_interval.c
contrib/oid2name/oid2name.c
src/backend/access/transam/xlogprefetcher.c
src/common/sha1.c
src/pl/plpython/plpy_cursorobject.c

index b0afdf02bb55456eb028828d0d934f6ef3bc672f..156f2cebac5dc061d27f644c33cbd22ccae9dd55 100644 (file)
@@ -113,7 +113,7 @@ static const gbtree_ninfo tinfo =
 Interval *
 abs_interval(Interval *a)
 {
-   static Interval zero = {0, 0, 0};
+   static const Interval zero = {0, 0, 0};
 
    if (DatumGetBool(DirectFunctionCall2(interval_lt,
                                         IntervalPGetDatum(a),
index e8c1e2c97bd2ff198949487054070905bbc5b716..c2785848f557fb774310bca94cb33e2b243a21f3 100644 (file)
@@ -62,7 +62,7 @@ void      sql_exec_dumpalltbspc(PGconn *conn, struct options *opts);
 void
 get_opts(int argc, char **argv, struct options *my_opts)
 {
-   static struct option long_options[] = {
+   static const struct option long_options[] = {
        {"dbname", required_argument, NULL, 'd'},
        {"host", required_argument, NULL, 'h'},
        {"host", required_argument, NULL, 'H'}, /* deprecated */
index 84023d61baf302cf3e69ef426dd6b429eb37f3ba..2dc2fb760a20d3231b3640b3037457239eca1343 100644 (file)
@@ -362,7 +362,7 @@ XLogPrefetcher *
 XLogPrefetcherAllocate(XLogReaderState *reader)
 {
    XLogPrefetcher *prefetcher;
-   static HASHCTL hash_table_ctl = {
+   const HASHCTL hash_table_ctl = {
        .keysize = sizeof(RelFileLocator),
        .entrysize = sizeof(XLogPrefetcherFilter)
    };
index 0525c4ff31652de7e0bd2f41101dcdea63456f0b..abfbd1c087d967de32c9ea88e359b4559928a215 100644 (file)
@@ -61,7 +61,7 @@
 #include "sha1_int.h"
 
 /* constant table */
-static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
+static const uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
 
 #define K(t)   _K[(t) / 20]
 
index 57e8f8ec2170bba11b57f2d5b829fe57374e3d17..24f2ac8c46bee2509f05b2be318ed3412f9ae3cc 100644 (file)
@@ -27,7 +27,7 @@ static PyObject *PLy_cursor_iternext(PyObject *self);
 static PyObject *PLy_cursor_fetch(PyObject *self, PyObject *args);
 static PyObject *PLy_cursor_close(PyObject *self, PyObject *unused);
 
-static char PLy_cursor_doc[] = "Wrapper around a PostgreSQL cursor";
+static const char PLy_cursor_doc[] = "Wrapper around a PostgreSQL cursor";
 
 static PyMethodDef PLy_cursor_methods[] = {
    {"fetch", PLy_cursor_fetch, METH_VARARGS, NULL},