Skip to content

Commit bab0bd7

Browse files
committed
Use 'const char *' for pointers to static strings.
Make g++ 4.2.3 happy for -Werror.
1 parent 1216811 commit bab0bd7

15 files changed

+25
-23
lines changed

dhash/dhblock_chash_srv.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ dhblock_chash_srv::stats (vec<dstat> &s)
8585
void
8686
dhblock_chash_srv::store (chordID key, str d, u_int32_t expire, cb_dhstat cb)
8787
{
88-
char *action;
88+
const char *action;
8989

9090
if (1) { // without maintaining our own merkle tree, we can't know
9191
action = "N"; // New

dhash/dhblock_srv.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dhblock_srv::~dhblock_srv ()
4545
str
4646
dhblock_srv::prefix () const
4747
{
48-
char *p = "unknown";
48+
const char *p = "unknown";
4949
switch (ctype) {
5050
case DHASH_CONTENTHASH:
5151
p = "chash";

lsd/adbd.C

+3-3
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ dbns::insert (const chordID &key, DBT &data, u_int32_t auxdata, u_int32_t exptim
423423
DBT skey;
424424
id_to_dbt (key, &skey);
425425

426-
char *err = "";
426+
const char *err = "";
427427
int ret;
428428
if (exptime > timenow + expire_buffer) {
429429
// Only add to Merkle tree if this object is worth repairing.
@@ -568,7 +568,7 @@ dbns::del (const chordID &key, u_int32_t auxdata)
568568
}
569569

570570
// Only attempt to update Merkle tree if object was present.
571-
char *err = "";
571+
const char *err = "";
572572
if (hasaux ()) {
573573
err = "mtree->remove aux";
574574
r = mtree->remove (key, auxdata, t);
@@ -834,7 +834,7 @@ dbns::expire (u_int32_t limit, u_int32_t deadline)
834834
chordID id = dbt_to_id (key);
835835
warnx ("%d.%06d ", int (tsnow.tv_sec), int (tsnow.tv_nsec/1000))
836836
<< name << ": Expiring " << id << "\n";
837-
char *err = "";
837+
const char *err = "";
838838
do {
839839
err = "mtree->remove";
840840
if (hasaux ()) {

lsd/lsd.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ enum routing_mode_t {
9292

9393
struct routing_mode_desc {
9494
routing_mode_t m;
95-
char *cmdline;
96-
char *desc;
95+
const char *cmdline;
96+
const char *desc;
9797
vnode_producer_t producer;
9898
};
9999

lsd/lsdctl.C

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
bool opt_verbose;
99
bool opt_quiet;
1010
int opt_timeout (120);
11-
char *control_socket = "/tmp/lsdctl-sock";
11+
const char *control_socket = "/tmp/lsdctl-sock";
1212

1313
/* Prototypes for table. */
1414
void lsdctl_help (int argc, char *argv[]);
@@ -397,7 +397,9 @@ int
397397
main (int argc, char *argv[])
398398
{
399399
setprogname (argv[0]);
400-
putenv ("POSIXLY_CORRECT=1"); // Prevents Linux from reordering options
400+
// Prevents Linux from reordering options
401+
if (setenv ("POSIXLY_CORRECT", "1", 1) != 0)
402+
fatal ("setenv: %m\n");
401403

402404
int ch;
403405
while ((ch = getopt (argc, argv, "S:t:vq")) != -1)

maint/maintd.C

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
#include "maint_policy.h"
1515

1616
// {{{ Globals
17-
static char *ctlsock;
18-
static char *logfname;
19-
static char *localdatapath;
17+
static const char *ctlsock;
18+
static const char *logfname;
19+
static const char *localdatapath;
2020

2121
static vec<ptr<maintainer> > maintainers;
2222

@@ -26,7 +26,7 @@ enum maint_mode_t {
2626
} maint_mode;
2727
struct maint_mode_desc {
2828
maint_mode_t m;
29-
char *cmdline;
29+
const char *cmdline;
3030
maintainer_producer_t producer;
3131
} maint_modes[] = {
3232
{ MAINT_CARBONITE, "carbonite",
@@ -41,7 +41,7 @@ enum sync_mode_t {
4141
} sync_mode;
4242
struct sync_mode_desc {
4343
sync_mode_t m;
44-
char *cmdline;
44+
const char *cmdline;
4545
syncer_producer_t producer;
4646
} sync_modes[] = {
4747
{ SYNC_MERKLE, "merkle", &merkle_sync::produce_syncer }

merkle/merkle_tree_bdb.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ merkle_tree_bdb::init_db (bool ro)
304304
r = dbfe_txn_begin (dbe, &t);
305305

306306
// BTree makes the most sense for a tree structure.
307-
char *err = "";
307+
const char *err = "";
308308
do {
309309
err = "nodedb->create";
310310
r = db_create (&nodedb, dbe, 0);

tools/dbdump.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <dbfe.h>
55
#include <adb_prot.h>
66

7-
static char *usage = "usage: dbdump [-t|-m] dbhome\n";
7+
static const char *usage = "usage: dbdump [-t|-m] dbhome\n";
88

99
static DB_ENV* dbe = NULL;
1010
static DB *metadatadb = NULL;

tools/lsdping.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void doit (chord_node dst, int seqno) {
4444
}
4545
}
4646

47-
static char *usage = "lsdping: [-n numpersecond] host port vnodenum";
47+
static const char *usage = "lsdping: [-n numpersecond] host port vnodenum";
4848

4949
int
5050
main (int argc, char *argv[])

tools/maintwalk.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ usage ()
2929
static chordID wellknown_ID = -1;
3030
// Sequential is what we believe is the correct sequencing of nodes
3131
static vec<chord_node> sequential;
32-
static char *localdatapath;
32+
static const char *localdatapath;
3333
static u_int64_t totalbytes = 0;
3434
static u_int64_t starttime = 0;
3535

tools/nodeq.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "rpclib.h"
1414

15-
char *usage = "Usage: nodeq [-m] [-r] host port vnode\n";
15+
const char *usage = "Usage: nodeq [-m] [-r] host port vnode\n";
1616

1717
int outstanding = 0;
1818
int errors = 0;

utils/dbfe.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dbGetImplInfo() {
6262
dbOptions::dbOptions() {}
6363

6464
int verifyOption (const char *optionSig) {
65-
vec<char *> allowed = dbGetImplInfo()->supportedOptions;
65+
vec<const char *> allowed = dbGetImplInfo()->supportedOptions;
6666
for (unsigned int i=0; i < allowed.size(); i++)
6767
if (memcmp(allowed[i], optionSig, strlen(allowed[i])) == 0) return 1;
6868
return 0;

utils/dbfe.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct dbOptions {
108108
};
109109

110110
struct dbImplInfo {
111-
vec<char *> supportedOptions;
111+
vec<const char *> supportedOptions;
112112

113113
dbImplInfo() { };
114114
};

utils/modlogger.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
int modlogger::logfd = 2;
55
int modlogger::maxprio = modlogger::INFO;
66

7-
modlogger::modlogger (char *module, int p) : prio (p)
7+
modlogger::modlogger (const char *module, int p) : prio (p)
88
{
99
/* Don't expect to be outputting, so don't make syscall */
1010
if (prio > maxprio)

utils/modlogger.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class modlogger : public strbuf {
1818
INFO = 1,
1919
TRACE = 2
2020
};
21-
explicit modlogger (char *module, int prio = INFO);
21+
explicit modlogger (const char *module, int prio = INFO);
2222
~modlogger ();
2323
const modlogger &operator () (const char *fmt, ...) const
2424
__attribute__ ((format (printf, 2, 3)));

0 commit comments

Comments
 (0)