summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2018-10-16 03:45:30 +0000
committerAndres Freund2018-10-16 04:01:14 +0000
commit62649bad831fb69b5d9644470acc413a35cddea6 (patch)
treee0d99a747615337e515290eb634c2f74fb2df2b6
parentc5257345ef61922468cd9abd887c3cb6c38792cb (diff)
Correct constness of a few variables.
This allows the compiler / linker to mark affected pages as read-only. There's other cases, but they're a bit more invasive, and should go through some review. These are easy. They were found with objdump -j .data -t src/backend/postgres|awk '{print $4, $5, $6}'|sort -r|less Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/backend/commands/event_trigger.c4
-rw-r--r--src/backend/foreign/foreign.c6
-rw-r--r--src/backend/libpq/pqcomm.c4
-rw-r--r--src/backend/libpq/pqmq.c2
-rw-r--r--src/backend/replication/basebackup.c4
-rw-r--r--src/backend/storage/lmgr/generate-lwlocknames.pl2
-rw-r--r--src/backend/utils/adt/cash.c4
-rw-r--r--src/include/libpq/libpq.h2
-rw-r--r--src/include/storage/lwlock.h2
9 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index 9a702e4097e..20a3a786929 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -85,7 +85,7 @@ typedef enum
} event_trigger_command_tag_check_result;
/* XXX merge this with ObjectTypeMap? */
-static event_trigger_support_data event_trigger_support[] = {
+static const event_trigger_support_data event_trigger_support[] = {
{"ACCESS METHOD", true},
{"AGGREGATE", true},
{"CAST", true},
@@ -282,7 +282,7 @@ static event_trigger_command_tag_check_result
check_ddl_tag(const char *tag)
{
const char *obtypename;
- event_trigger_support_data *etsd;
+ const event_trigger_support_data *etsd;
/*
* Handle some idiosyncratic special cases.
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index eac78a5d315..a0bcc042cea 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -560,7 +560,7 @@ struct ConnectionOption
*
* The list is small - don't bother with bsearch if it stays so.
*/
-static struct ConnectionOption libpq_conninfo_options[] = {
+static const struct ConnectionOption libpq_conninfo_options[] = {
{"authtype", ForeignServerRelationId},
{"service", ForeignServerRelationId},
{"user", UserMappingRelationId},
@@ -587,7 +587,7 @@ static struct ConnectionOption libpq_conninfo_options[] = {
static bool
is_conninfo_option(const char *option, Oid context)
{
- struct ConnectionOption *opt;
+ const struct ConnectionOption *opt;
for (opt = libpq_conninfo_options; opt->optname; opt++)
if (context == opt->optcontext && strcmp(opt->optname, option) == 0)
@@ -622,7 +622,7 @@ postgresql_fdw_validator(PG_FUNCTION_ARGS)
if (!is_conninfo_option(def->defname, catalog))
{
- struct ConnectionOption *opt;
+ const struct ConnectionOption *opt;
StringInfoData buf;
/*
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index a4f6d4deeb4..0c9593d4cc9 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -170,7 +170,7 @@ static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
static int Setup_AF_UNIX(char *sock_path);
#endif /* HAVE_UNIX_SOCKETS */
-static PQcommMethods PqCommSocketMethods = {
+static const PQcommMethods PqCommSocketMethods = {
socket_comm_reset,
socket_flush,
socket_flush_if_writable,
@@ -181,7 +181,7 @@ static PQcommMethods PqCommSocketMethods = {
socket_endcopyout
};
-PQcommMethods *PqCommMethods = &PqCommSocketMethods;
+const PQcommMethods *PqCommMethods = &PqCommSocketMethods;
WaitEventSet *FeBeWaitSet;
diff --git a/src/backend/libpq/pqmq.c b/src/backend/libpq/pqmq.c
index 4fbc6b5115d..6eaed5bf0cf 100644
--- a/src/backend/libpq/pqmq.c
+++ b/src/backend/libpq/pqmq.c
@@ -36,7 +36,7 @@ static void mq_putmessage_noblock(char msgtype, const char *s, size_t len);
static void mq_startcopyout(void);
static void mq_endcopyout(bool errorAbort);
-static PQcommMethods PqCommMqMethods = {
+static const PQcommMethods PqCommMqMethods = {
mq_comm_reset,
mq_flush,
mq_flush_if_writable,
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 91ae4489552..b20f6c379c6 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -190,7 +190,7 @@ static const char *excludeFiles[] =
/*
* List of files excluded from checksum validation.
*/
-static const char *noChecksumFiles[] = {
+static const char *const noChecksumFiles[] = {
"pg_control",
"pg_filenode.map",
"pg_internal.init",
@@ -1321,7 +1321,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
static bool
is_checksummed_file(const char *fullpath, const char *filename)
{
- const char **f;
+ const char *const *f;
/* Check that the file is in a tablespace */
if (strncmp(fullpath, "./global/", 9) == 0 ||
diff --git a/src/backend/storage/lmgr/generate-lwlocknames.pl b/src/backend/storage/lmgr/generate-lwlocknames.pl
index 3913b3dc016..241f68ee573 100644
--- a/src/backend/storage/lmgr/generate-lwlocknames.pl
+++ b/src/backend/storage/lmgr/generate-lwlocknames.pl
@@ -23,7 +23,7 @@ print $h $autogen;
print $h "/* there is deliberately not an #ifndef LWLOCKNAMES_H here */\n\n";
print $c $autogen, "\n";
-print $c "char *MainLWLockNames[] = {";
+print $c "const char *const MainLWLockNames[] = {";
while (<$lwlocknames>)
{
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c
index c787dd34191..c92e9d5046a 100644
--- a/src/backend/utils/adt/cash.c
+++ b/src/backend/utils/adt/cash.c
@@ -39,13 +39,13 @@ static const char *
num_word(Cash value)
{
static char buf[128];
- static const char *small[] = {
+ static const char *const small[] = {
"zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty",
"thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
};
- const char **big = small + 18;
+ const char *const *big = small + 18;
int tu = value % 100;
/* deal with the simple cases first */
diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h
index 36baf6b9199..c7762f68a6b 100644
--- a/src/include/libpq/libpq.h
+++ b/src/include/libpq/libpq.h
@@ -33,7 +33,7 @@ typedef struct
void (*endcopyout) (bool errorAbort);
} PQcommMethods;
-extern PGDLLIMPORT PQcommMethods *PqCommMethods;
+extern const PGDLLIMPORT PQcommMethods *PqCommMethods;
#define pq_comm_reset() (PqCommMethods->comm_reset())
#define pq_flush() (PqCommMethods->flush())
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index c21bfe2f666..b2dcb732872 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -88,7 +88,7 @@ typedef union LWLockMinimallyPadded
} LWLockMinimallyPadded;
extern PGDLLIMPORT LWLockPadded *MainLWLockArray;
-extern char *MainLWLockNames[];
+extern const char *const MainLWLockNames[];
/* struct for storing named tranche information */
typedef struct NamedLWLockTranche