Skip to content

Commit 7221b4f

Browse files
author
Neil Conway
committed
Code cleanup: mark some variables with the "const" modifier, when they
are initialized with a string literal. Patch from Stefan Huehner.
1 parent b9954fb commit 7221b4f

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.255 2007/03/17 01:15:55 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.256 2007/03/18 16:50:42 neilc Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -106,9 +106,9 @@ typedef struct
106106
* ----------
107107
*/
108108
static SPIPlanPtr plan_getrulebyoid = NULL;
109-
static char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1";
109+
static const char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1";
110110
static SPIPlanPtr plan_getviewrule = NULL;
111-
static char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
111+
static const char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
112112

113113

114114
/* ----------

src/bin/initdb/initdb.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.134 2007/02/20 23:49:38 momjian Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.135 2007/03/18 16:50:43 neilc Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -727,7 +727,7 @@ get_encoding_id(char *encoding_name)
727727
struct encoding_match
728728
{
729729
enum pg_enc pg_enc_code;
730-
char *system_enc_name;
730+
const char *system_enc_name;
731731
};
732732

733733
struct encoding_match encoding_match_list[] = {
@@ -1481,8 +1481,8 @@ static void
14811481
setup_auth(void)
14821482
{
14831483
PG_CMD_DECL;
1484-
char **line;
1485-
static char *pg_authid_setup[] = {
1484+
const char **line;
1485+
static const char *pg_authid_setup[] = {
14861486
/*
14871487
* Create triggers to ensure manual updates to shared catalogs will be
14881488
* reflected into their "flat file" copies.
@@ -1623,8 +1623,8 @@ static void
16231623
setup_depend(void)
16241624
{
16251625
PG_CMD_DECL;
1626-
char **line;
1627-
static char *pg_depend_setup[] = {
1626+
const char **line;
1627+
static const char *pg_depend_setup[] = {
16281628
/*
16291629
* Make PIN entries in pg_depend for all objects made so far in the
16301630
* tables that the dependency code handles. This is overkill (the
@@ -1990,8 +1990,8 @@ static void
19901990
make_template0(void)
19911991
{
19921992
PG_CMD_DECL;
1993-
char **line;
1994-
static char *template0_setup[] = {
1993+
const char **line;
1994+
static const char *template0_setup[] = {
19951995
"CREATE DATABASE template0;\n",
19961996
"UPDATE pg_database SET "
19971997
" datistemplate = 't', "
@@ -2045,8 +2045,8 @@ static void
20452045
make_postgres(void)
20462046
{
20472047
PG_CMD_DECL;
2048-
char **line;
2049-
static char *postgres_setup[] = {
2048+
const char **line;
2049+
static const char *postgres_setup[] = {
20502050
"CREATE DATABASE postgres;\n",
20512051
NULL
20522052
};

src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.33 2007/03/03 20:02:27 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.34 2007/03/18 16:50:43 neilc Exp $
1010
*/
1111
#include "postgres.h"
1212

@@ -72,7 +72,7 @@ main(int argc, char *argv[])
7272
char pgctime_str[128];
7373
char ckpttime_str[128];
7474
char sysident_str[32];
75-
char *strftime_fmt = "%c";
75+
const char *strftime_fmt = "%c";
7676
const char *progname;
7777

7878
set_pglocale_pgservice(argv[0], "pg_controldata");

src/bin/pg_ctl/pg_ctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.78 2007/02/10 14:58:55 petere Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.79 2007/03/18 16:50:44 neilc Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -91,7 +91,7 @@ static char *post_opts = NULL;
9191
static const char *progname;
9292
static char *log_file = NULL;
9393
static char *postgres_path = NULL;
94-
static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
94+
static const char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
9595
static char *register_username = NULL;
9696
static char *register_password = NULL;
9797
static char *argv0 = NULL;

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.142 2007/02/19 15:05:06 mha Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.143 2007/03/18 16:50:44 neilc Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -37,7 +37,7 @@
3737

3838
const char *progname;
3939

40-
static char *modulename = gettext_noop("archiver");
40+
static const char *modulename = gettext_noop("archiver");
4141

4242

4343
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,

src/bin/pg_dump/pg_backup_custom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.37 2007/02/19 15:05:06 mha Exp $
22+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.38 2007/03/18 16:50:44 neilc Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -91,7 +91,7 @@ static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te);
9191
static pgoff_t _getFilePos(ArchiveHandle *AH, lclContext *ctx);
9292
static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush);
9393

94-
static char *modulename = gettext_noop("custom archiver");
94+
static const char *modulename = gettext_noop("custom archiver");
9595

9696

9797

src/bin/pg_dump/pg_backup_files.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*
2222
* IDENTIFICATION
23-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.31 2007/02/19 15:05:06 mha Exp $
23+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.32 2007/03/18 16:50:44 neilc Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -65,7 +65,7 @@ typedef struct
6565
char *filename;
6666
} lclTocEntry;
6767

68-
static char *modulename = gettext_noop("file archiver");
68+
static const char *modulename = gettext_noop("file archiver");
6969
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
7070
static void _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char *fname);
7171

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.57 2007/02/19 15:05:06 mha Exp $
19+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.58 2007/03/18 16:50:44 neilc Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -102,7 +102,7 @@ typedef struct
102102
char *filename;
103103
} lclTocEntry;
104104

105-
static char *modulename = gettext_noop("tar archiver");
105+
static const char *modulename = gettext_noop("tar archiver");
106106

107107
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
108108

src/bin/pg_dump/pg_dump_sort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.17 2007/01/23 17:54:50 tgl Exp $
12+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.18 2007/03/18 16:50:44 neilc Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
1616
#include "pg_backup_archiver.h"
1717

1818

19-
static char *modulename = gettext_noop("sorter");
19+
static const char *modulename = gettext_noop("sorter");
2020

2121
/*
2222
* Sort priority for object types when dumping a pre-7.3 database.

src/bin/psql/describe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.153 2007/03/16 08:28:01 mha Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.154 2007/03/18 16:50:44 neilc Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "describe.h"
@@ -1360,7 +1360,7 @@ describeOneTableDetails(const char *schemaname,
13601360
/* print inherits */
13611361
for (i = 0; i < inherits_count; i++)
13621362
{
1363-
char *s = _("Inherits");
1363+
const char *s = _("Inherits");
13641364

13651365
if (i == 0)
13661366
printfPQExpBuffer(&buf, "%s: %s", s, PQgetvalue(result6, i, 0));
@@ -1374,7 +1374,7 @@ describeOneTableDetails(const char *schemaname,
13741374

13751375
if (verbose)
13761376
{
1377-
char *s = _("Has OIDs");
1377+
const char *s = _("Has OIDs");
13781378

13791379
printfPQExpBuffer(&buf, "%s: %s", s,
13801380
(tableinfo.hasoids ? _("yes") : _("no")));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy