Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 62649ba

Browse files
committed
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/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de
1 parent c525734 commit 62649ba

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

src/backend/commands/event_trigger.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef enum
8585
} event_trigger_command_tag_check_result;
8686

8787
/* XXX merge this with ObjectTypeMap? */
88-
static event_trigger_support_data event_trigger_support[] = {
88+
static const event_trigger_support_data event_trigger_support[] = {
8989
{"ACCESS METHOD", true},
9090
{"AGGREGATE", true},
9191
{"CAST", true},
@@ -282,7 +282,7 @@ static event_trigger_command_tag_check_result
282282
check_ddl_tag(const char *tag)
283283
{
284284
const char *obtypename;
285-
event_trigger_support_data *etsd;
285+
const event_trigger_support_data *etsd;
286286

287287
/*
288288
* Handle some idiosyncratic special cases.

src/backend/foreign/foreign.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ struct ConnectionOption
560560
*
561561
* The list is small - don't bother with bsearch if it stays so.
562562
*/
563-
static struct ConnectionOption libpq_conninfo_options[] = {
563+
static const struct ConnectionOption libpq_conninfo_options[] = {
564564
{"authtype", ForeignServerRelationId},
565565
{"service", ForeignServerRelationId},
566566
{"user", UserMappingRelationId},
@@ -587,7 +587,7 @@ static struct ConnectionOption libpq_conninfo_options[] = {
587587
static bool
588588
is_conninfo_option(const char *option, Oid context)
589589
{
590-
struct ConnectionOption *opt;
590+
const struct ConnectionOption *opt;
591591

592592
for (opt = libpq_conninfo_options; opt->optname; opt++)
593593
if (context == opt->optcontext && strcmp(opt->optname, option) == 0)
@@ -622,7 +622,7 @@ postgresql_fdw_validator(PG_FUNCTION_ARGS)
622622

623623
if (!is_conninfo_option(def->defname, catalog))
624624
{
625-
struct ConnectionOption *opt;
625+
const struct ConnectionOption *opt;
626626
StringInfoData buf;
627627

628628
/*

src/backend/libpq/pqcomm.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
170170
static int Setup_AF_UNIX(char *sock_path);
171171
#endif /* HAVE_UNIX_SOCKETS */
172172

173-
static PQcommMethods PqCommSocketMethods = {
173+
static const PQcommMethods PqCommSocketMethods = {
174174
socket_comm_reset,
175175
socket_flush,
176176
socket_flush_if_writable,
@@ -181,7 +181,7 @@ static PQcommMethods PqCommSocketMethods = {
181181
socket_endcopyout
182182
};
183183

184-
PQcommMethods *PqCommMethods = &PqCommSocketMethods;
184+
const PQcommMethods *PqCommMethods = &PqCommSocketMethods;
185185

186186
WaitEventSet *FeBeWaitSet;
187187

src/backend/libpq/pqmq.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void mq_putmessage_noblock(char msgtype, const char *s, size_t len);
3636
static void mq_startcopyout(void);
3737
static void mq_endcopyout(bool errorAbort);
3838

39-
static PQcommMethods PqCommMqMethods = {
39+
static const PQcommMethods PqCommMqMethods = {
4040
mq_comm_reset,
4141
mq_flush,
4242
mq_flush_if_writable,

src/backend/replication/basebackup.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static const char *excludeFiles[] =
190190
/*
191191
* List of files excluded from checksum validation.
192192
*/
193-
static const char *noChecksumFiles[] = {
193+
static const char *const noChecksumFiles[] = {
194194
"pg_control",
195195
"pg_filenode.map",
196196
"pg_internal.init",
@@ -1321,7 +1321,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
13211321
static bool
13221322
is_checksummed_file(const char *fullpath, const char *filename)
13231323
{
1324-
const char **f;
1324+
const char *const *f;
13251325

13261326
/* Check that the file is in a tablespace */
13271327
if (strncmp(fullpath, "./global/", 9) == 0 ||

src/backend/storage/lmgr/generate-lwlocknames.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
print $h "/* there is deliberately not an #ifndef LWLOCKNAMES_H here */\n\n";
2424
print $c $autogen, "\n";
2525

26-
print $c "char *MainLWLockNames[] = {";
26+
print $c "const char *const MainLWLockNames[] = {";
2727

2828
while (<$lwlocknames>)
2929
{

src/backend/utils/adt/cash.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ static const char *
3939
num_word(Cash value)
4040
{
4141
static char buf[128];
42-
static const char *small[] = {
42+
static const char *const small[] = {
4343
"zero", "one", "two", "three", "four", "five", "six", "seven",
4444
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
4545
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty",
4646
"thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
4747
};
48-
const char **big = small + 18;
48+
const char *const *big = small + 18;
4949
int tu = value % 100;
5050

5151
/* deal with the simple cases first */

src/include/libpq/libpq.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef struct
3333
void (*endcopyout) (bool errorAbort);
3434
} PQcommMethods;
3535

36-
extern PGDLLIMPORT PQcommMethods *PqCommMethods;
36+
extern const PGDLLIMPORT PQcommMethods *PqCommMethods;
3737

3838
#define pq_comm_reset() (PqCommMethods->comm_reset())
3939
#define pq_flush() (PqCommMethods->flush())

src/include/storage/lwlock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ typedef union LWLockMinimallyPadded
8888
} LWLockMinimallyPadded;
8989

9090
extern PGDLLIMPORT LWLockPadded *MainLWLockArray;
91-
extern char *MainLWLockNames[];
91+
extern const char *const MainLWLockNames[];
9292

9393
/* struct for storing named tranche information */
9494
typedef struct NamedLWLockTranche

0 commit comments

Comments
 (0)