diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-09-24 18:17:53 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2015-09-24 18:17:53 -0400 |
commit | 5ed3f85cc3f59c6cce8adb851909285c92ef3760 (patch) | |
tree | 82587cc80e1f2460b853dbd98ea1bad7a44f55d5 /src/utilities | |
parent | cc74b07d6916c827015abf27bd09b28c38c98e69 (diff) | |
download | mongo-5ed3f85cc3f59c6cce8adb851909285c92ef3760.tar.gz |
Boolean conversion pass over utilities.
Diffstat (limited to 'src/utilities')
-rw-r--r-- | src/utilities/util.h | 4 | ||||
-rw-r--r-- | src/utilities/util_backup.c | 4 | ||||
-rw-r--r-- | src/utilities/util_dump.c | 44 | ||||
-rw-r--r-- | src/utilities/util_list.c | 17 | ||||
-rw-r--r-- | src/utilities/util_load.c | 54 | ||||
-rw-r--r-- | src/utilities/util_load_json.c | 31 | ||||
-rw-r--r-- | src/utilities/util_loadtext.c | 19 | ||||
-rw-r--r-- | src/utilities/util_main.c | 12 | ||||
-rw-r--r-- | src/utilities/util_misc.c | 6 | ||||
-rw-r--r-- | src/utilities/util_printlog.c | 7 | ||||
-rw-r--r-- | src/utilities/util_read.c | 11 | ||||
-rw-r--r-- | src/utilities/util_stat.c | 7 | ||||
-rw-r--r-- | src/utilities/util_verify.c | 13 | ||||
-rw-r--r-- | src/utilities/util_write.c | 11 |
14 files changed, 126 insertions, 114 deletions
diff --git a/src/utilities/util.h b/src/utilities/util.h index 692b02e63f2..08d0537956f 100644 --- a/src/utilities/util.h +++ b/src/utilities/util.h @@ -16,7 +16,7 @@ typedef struct { extern const char *home; /* Home directory */ extern const char *progname; /* Program name */ extern const char *usage_prefix; /* Global arguments */ -extern int verbose; /* Verbose flag */ +extern bool verbose; /* Verbose flag */ extern WT_EVENT_HANDLER *verbose_handler; @@ -41,7 +41,7 @@ int util_loadtext(WT_SESSION *, int, char *[]); char *util_name(WT_SESSION *, const char *, const char *); int util_printlog(WT_SESSION *, int, char *[]); int util_read(WT_SESSION *, int, char *[]); -int util_read_line(WT_SESSION *, ULINE *, int, int *); +int util_read_line(WT_SESSION *, ULINE *, bool, bool *); int util_rename(WT_SESSION *, int, char *[]); int util_salvage(WT_SESSION *, int, char *[]); int util_stat(WT_SESSION *, int, char *[]); diff --git a/src/utilities/util_backup.c b/src/utilities/util_backup.c index 0eca4b3103a..d07c99afc19 100644 --- a/src/utilities/util_backup.c +++ b/src/utilities/util_backup.c @@ -21,7 +21,7 @@ static char *cbuf; static int append_target(WT_SESSION *session, const char *target, char **bufp) { - static int first = 1; + static bool first = true; static size_t len = 0, remain = 0; static char *buf = NULL; @@ -34,7 +34,7 @@ append_target(WT_SESSION *session, const char *target, char **bufp) *bufp = buf; } if (first) { - first = 0; + first = false; strcpy(buf, "target=("); } else buf[strlen(buf) - 1] = ','; /* overwrite previous ")" */ diff --git a/src/utilities/util_dump.c b/src/utilities/util_dump.c index f4913d1e907..7dfac50b724 100644 --- a/src/utilities/util_dump.c +++ b/src/utilities/util_dump.c @@ -8,7 +8,7 @@ #include "util.h" -static int dump_config(WT_SESSION *, const char *, int); +static int dump_config(WT_SESSION *, const char *, bool); static int dump_json_begin(WT_SESSION *); static int dump_json_end(WT_SESSION *); static int dump_json_separator(WT_SESSION *); @@ -18,8 +18,8 @@ static int dump_json_table_cg( WT_SESSION *, WT_CURSOR *, const char *, const char *, const char *); static int dump_json_table_config(WT_SESSION *, const char *); static int dump_json_table_end(WT_SESSION *); -static int dump_prefix(WT_SESSION *, int); -static int dump_record(WT_CURSOR *, int, int); +static int dump_prefix(WT_SESSION *, bool); +static int dump_record(WT_CURSOR *, bool, bool); static int dump_suffix(WT_SESSION *); static int dump_table_config(WT_SESSION *, WT_CURSOR *, const char *); static int dump_table_config_type( @@ -34,10 +34,11 @@ util_dump(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; size_t len; - int ch, hex, i, json, reverse; + int ch, i; + bool hex, json, reverse; char *checkpoint, *config, *name; - hex = json = reverse = 0; + hex = json = reverse = false; checkpoint = config = name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "c:f:jrx")) != EOF) switch (ch) { @@ -50,13 +51,13 @@ util_dump(WT_SESSION *session, int argc, char *argv[]) session, errno, "%s: reopen", __wt_optarg)); break; case 'j': - json = 1; + json = true; break; case 'r': - reverse = 1; + reverse = true; break; case 'x': - hex = 1; + hex = true; break; case '?': default: @@ -141,7 +142,7 @@ err: ret = 1; * Dump the config for the uri. */ static int -dump_config(WT_SESSION *session, const char *uri, int hex) +dump_config(WT_SESSION *session, const char *uri, bool hex) { WT_CURSOR *cursor; WT_DECL_RET; @@ -270,13 +271,14 @@ static int dump_json_table_cg(WT_SESSION *session, WT_CURSOR *cursor, const char *name, const char *entry, const char *header) { + static const char * const indent = " "; WT_DECL_RET; + int exact; + bool once; const char *key, *skip, *value; - int exact, once; char *jsonconfig; - static const char * const indent = " "; - once = 0; + once = false; if (printf(" \"%s\" : [", header) < 0) return (util_err(session, EIO, NULL)); @@ -328,15 +330,15 @@ match: if ((ret = cursor->get_key(cursor, &key)) != 0) "%s \"uri\" : \"%s\",\n" "%s \"config\" : \"%s\"\n" "%s}", - (once == 0 ? "" : ","), + once ? "," : "", indent, indent, key, indent, jsonconfig, indent); free(jsonconfig); if (ret < 0) return (util_err(session, EIO, NULL)); - once = 1; + once = true; } - if (printf("%s]", (once == 0 ? "" : "\n ")) < 0) + if (printf("%s]", once ? "\n " : "") < 0) return (util_err(session, EIO, NULL)); if (ret == 0 || ret == WT_NOTFOUND) return (0); @@ -544,7 +546,7 @@ match: if ((ret = cursor->get_key(cursor, &key)) != 0) * Output the dump file header prefix. */ static int -dump_prefix(WT_SESSION *session, int hex) +dump_prefix(WT_SESSION *session, bool hex) { int vmajor, vminor, vpatch; @@ -565,16 +567,16 @@ dump_prefix(WT_SESSION *session, int hex) * with JSON formatting if needed. */ static int -dump_record(WT_CURSOR *cursor, int reverse, int json) +dump_record(WT_CURSOR *cursor, bool reverse, bool json) { WT_DECL_RET; WT_SESSION *session; const char *infix, *key, *prefix, *suffix, *value; - int once; + bool once; session = cursor->session; - once = 0; + once = false; if (json) { prefix = "\n{\n"; infix = ",\n"; @@ -590,10 +592,10 @@ dump_record(WT_CURSOR *cursor, int reverse, int json) return (util_cerr(cursor, "get_key", ret)); if ((ret = cursor->get_value(cursor, &value)) != 0) return (util_cerr(cursor, "get_value", ret)); - if (printf("%s%s%s%s%s%s", (json && once) ? "," : "", + if (printf("%s%s%s%s%s%s", json && once ? "," : "", prefix, key, infix, value, suffix) < 0) return (util_err(session, EIO, NULL)); - once = 1; + once = true; } if (json && once && printf("\n") < 0) return (util_err(session, EIO, NULL)); diff --git a/src/utilities/util_list.c b/src/utilities/util_list.c index 1d35f2efc72..99a1455a74e 100644 --- a/src/utilities/util_list.c +++ b/src/utilities/util_list.c @@ -8,7 +8,7 @@ #include "util.h" -static int list_print(WT_SESSION *, const char *, int, int); +static int list_print(WT_SESSION *, const char *, bool, bool); static int list_print_checkpoint(WT_SESSION *, const char *); static int usage(void); @@ -16,18 +16,19 @@ int util_list(WT_SESSION *session, int argc, char *argv[]) { WT_DECL_RET; - int cflag, ch, vflag; + int ch; + bool cflag, vflag; char *name; - cflag = vflag = 0; + cflag = vflag = false; name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "cv")) != EOF) switch (ch) { case 'c': - cflag = 1; + cflag = true; break; case 'v': - vflag = 1; + vflag = true; break; case '?': default: @@ -59,11 +60,11 @@ util_list(WT_SESSION *session, int argc, char *argv[]) * List the high-level objects in the database. */ static int -list_print(WT_SESSION *session, const char *name, int cflag, int vflag) +list_print(WT_SESSION *session, const char *name, bool cflag, bool vflag) { WT_CURSOR *cursor; WT_DECL_RET; - int found; + bool found; const char *key, *value; /* Open the metadata file. */ @@ -93,7 +94,7 @@ list_print(WT_SESSION *session, const char *name, int cflag, int vflag) if (name != NULL) { if (!WT_PREFIX_MATCH(key, name)) continue; - found = 1; + found = true; } /* diff --git a/src/utilities/util_load.c b/src/utilities/util_load.c index f4f173b90c2..a40fa60361f 100644 --- a/src/utilities/util_load.c +++ b/src/utilities/util_load.c @@ -9,25 +9,25 @@ #include "util.h" #include "util_load.h" -static int config_read(WT_SESSION *, char ***, int *); +static int config_read(WT_SESSION *, char ***, bool *); static int config_rename(WT_SESSION *, char **, const char *); static int format(WT_SESSION *); static int insert(WT_CURSOR *, const char *); static int load_dump(WT_SESSION *); static int usage(void); -static int append; /* -a append (ignore record number keys) */ -static char *cmdname; /* -r rename */ -static char **cmdconfig; /* configuration pairs */ -static int json; /* -j input is JSON format */ -static int no_overwrite; /* -n don't overwrite existing data */ +static bool append = false; /* -a append (ignore number keys) */ +static char *cmdname; /* -r rename */ +static char **cmdconfig; /* configuration pairs */ +static bool json = false; /* -j input is JSON format */ +static bool no_overwrite = false; /* -n don't overwrite existing data */ int util_load(WT_SESSION *session, int argc, char *argv[]) { + uint32_t flags; int ch; const char *filename; - uint32_t flags; flags = 0; @@ -35,7 +35,7 @@ util_load(WT_SESSION *session, int argc, char *argv[]) while ((ch = __wt_getopt(progname, argc, argv, "af:jnr:")) != EOF) switch (ch) { case 'a': /* append (ignore record number keys) */ - append = 1; + append = true; break; case 'f': /* input file */ if (freopen(__wt_optarg, "r", stdin) == NULL) @@ -46,10 +46,10 @@ util_load(WT_SESSION *session, int argc, char *argv[]) filename = __wt_optarg; break; case 'j': /* input is JSON */ - json = 1; + json = true; break; case 'n': /* don't overwrite existing data */ - no_overwrite = 1; + no_overwrite = true; break; case 'r': /* rename */ cmdname = __wt_optarg; @@ -62,7 +62,7 @@ util_load(WT_SESSION *session, int argc, char *argv[]) argv += __wt_optind; /* -a and -o are mutually exclusive. */ - if (append == 1 && no_overwrite == 1) + if (append && no_overwrite) return (util_err(session, EINVAL, "the -a (append) and -n (no-overwrite) flags are mutually " "exclusive")); @@ -93,12 +93,13 @@ load_dump(WT_SESSION *session) { WT_CURSOR *cursor; WT_DECL_RET; - int hex, tret; + int tret; + bool hex; char **list, **tlist, *uri, config[64]; cursor = NULL; list = NULL; /* -Wuninitialized */ - hex = 0; /* -Wuninitialized */ + hex = false; /* -Wuninitialized */ uri = NULL; /* Read the metadata file. */ @@ -217,11 +218,12 @@ config_list_free(CONFIG_LIST *clp) * Read the config lines and do some basic validation. */ static int -config_read(WT_SESSION *session, char ***listp, int *hexp) +config_read(WT_SESSION *session, char ***listp, bool *hexp) { ULINE l; WT_DECL_RET; - int entry, eof, max_entry; + int entry, max_entry; + bool eof; const char *s; char **list, **tlist; @@ -229,31 +231,31 @@ config_read(WT_SESSION *session, char ***listp, int *hexp) memset(&l, 0, sizeof(l)); /* Header line #1: "WiredTiger Dump" and a WiredTiger version. */ - if (util_read_line(session, &l, 0, &eof)) + if (util_read_line(session, &l, false, &eof)) return (1); s = "WiredTiger Dump "; if (strncmp(l.mem, s, strlen(s)) != 0) return (format(session)); /* Header line #2: "Format={hex,print}". */ - if (util_read_line(session, &l, 0, &eof)) + if (util_read_line(session, &l, false, &eof)) return (1); if (strcmp(l.mem, "Format=print") == 0) - *hexp = 0; + *hexp = false; else if (strcmp(l.mem, "Format=hex") == 0) - *hexp = 1; + *hexp = true; else return (format(session)); /* Header line #3: "Header". */ - if (util_read_line(session, &l, 0, &eof)) + if (util_read_line(session, &l, false, &eof)) return (1); if (strcmp(l.mem, "Header") != 0) return (format(session)); /* Now, read in lines until we get to the end of the headers. */ for (entry = max_entry = 0, list = NULL;; ++entry) { - if ((ret = util_read_line(session, &l, 0, &eof)) != 0) + if ((ret = util_read_line(session, &l, false, &eof)) != 0) goto err; if (strcmp(l.mem, "Data") == 0) break; @@ -350,8 +352,8 @@ int config_update(WT_SESSION *session, char **list) { WT_DECL_RET; - int found; size_t cnt; + int found; const char *p, **cfg; char **configp, **listp; @@ -513,7 +515,7 @@ insert(WT_CURSOR *cursor, const char *name) WT_DECL_RET; WT_SESSION *session; uint64_t insert_count; - int eof; + bool eof; session = cursor->session; @@ -528,14 +530,14 @@ insert(WT_CURSOR *cursor, const char *name) * and ignore it (a dump with "append" set), or not read it at * all (flat-text load). */ - if (util_read_line(session, &key, 1, &eof)) + if (util_read_line(session, &key, true, &eof)) return (1); - if (eof == 1) + if (eof) break; if (!append) cursor->set_key(cursor, key.mem); - if (util_read_line(session, &value, 0, &eof)) + if (util_read_line(session, &value, false, &eof)) return (1); cursor->set_value(cursor, value.mem); diff --git a/src/utilities/util_load_json.c b/src/utilities/util_load_json.c index 2604348e56b..c7d4893ae20 100644 --- a/src/utilities/util_load_json.c +++ b/src/utilities/util_load_json.c @@ -28,8 +28,8 @@ typedef struct { WT_SESSION *session; /* associated session */ ULINE line; /* current line */ const char *p; /* points to cur position in line.mem */ - int ateof; /* current token is EOF */ - int peeking; /* peeking at next token */ + bool ateof; /* current token is EOF */ + bool peeking; /* peeking at next token */ int toktype; /* next token, defined by __wt_json_token() */ const char *tokstart; /* next token start (points into line.mem) */ size_t toklen; /* next token length */ @@ -71,8 +71,8 @@ json_column_group_index(WT_SESSION *session, JSON_INPUT_STATE *ins, CONFIG_LIST *clp, int idx) { WT_DECL_RET; + bool isconfig; char *config, *p, *uri; - int isconfig; uri = NULL; config = NULL; @@ -144,8 +144,8 @@ static int json_kvraw_append(WT_SESSION *session, JSON_INPUT_STATE *ins, const char *str, size_t len) { - char *tmp; size_t needsize; + char *tmp; if (len > 0) { needsize = strlen(ins->kvraw) + len + 2; @@ -213,12 +213,13 @@ json_data(WT_SESSION *session, { WT_CURSOR *cursor; WT_DECL_RET; - char config[64], *endp, *uri; - const char *keyformat; - int isrec, nfield, nkeys, toktype, tret; size_t keystrlen; ssize_t gotnolen; uint64_t gotno, recno; + int nfield, nkeys, toktype, tret; + bool isrec; + char config[64], *endp, *uri; + const char *keyformat; cursor = NULL; uri = NULL; @@ -246,7 +247,7 @@ json_data(WT_SESSION *session, goto err; } keyformat = cursor->key_format; - isrec = (strcmp(keyformat, "r") == 0); + isrec = strcmp(keyformat, "r") == 0; for (nkeys = 0; *keyformat; keyformat++) if (!isdigit(*keyformat)) nkeys++; @@ -345,10 +346,10 @@ json_top_level(WT_SESSION *session, JSON_INPUT_STATE *ins, uint32_t flags) { CONFIG_LIST cl; WT_DECL_RET; - char *config, *tableuri; int toktype; static const char *json_markers[] = { "\"config\"", "\"colgroups\"", "\"indices\"", "\"data\"", NULL }; + char *config, *tableuri; memset(&cl, 0, sizeof(cl)); tableuri = NULL; @@ -462,7 +463,7 @@ json_peek(WT_SESSION *session, JSON_INPUT_STATE *ins) ins->kvrawstart = 0; } if (util_read_line( - session, &ins->line, 1, &ins->ateof)) { + session, &ins->line, true, &ins->ateof)) { ins->toktype = -1; ret = -1; goto err; @@ -476,7 +477,7 @@ json_peek(WT_SESSION *session, JSON_INPUT_STATE *ins) &ins->toktype, &ins->tokstart, &ins->toklen) != 0) ins->toktype = -1; - ins->peeking = 1; + ins->peeking = true; } if (0) { err: if (ret == 0) @@ -498,7 +499,7 @@ json_expect(WT_SESSION *session, JSON_INPUT_STATE *ins, int wanttok) if (json_peek(session, ins) < 0) return (1); ins->p += ins->toklen; - ins->peeking = 0; + ins->peeking = false; if (ins->toktype != wanttok) { fprintf(stderr, "%s: %d: %" WT_SIZET_FMT ": expected %s, got %s\n", @@ -532,7 +533,7 @@ json_skip(WT_SESSION *session, JSON_INPUT_STATE *ins, const char **matches) for (match = matches; *match != NULL; match++) if ((hit = strstr(ins->p, *match)) != NULL) goto out; - if (util_read_line(session, &ins->line, 1, &ins->ateof)) { + if (util_read_line(session, &ins->line, true, &ins->ateof)) { ins->toktype = -1; return (1); } @@ -545,7 +546,7 @@ out: /* Set to this token. */ ins->p = hit; - ins->peeking = 0; + ins->peeking = false; ins->toktype = 0; (void)json_peek(session, ins); return (0); @@ -563,7 +564,7 @@ util_load_json(WT_SESSION *session, const char *filename, uint32_t flags) memset(&instate, 0, sizeof(instate)); instate.session = session; - if (util_read_line(session, &instate.line, 0, &instate.ateof)) + if (util_read_line(session, &instate.line, false, &instate.ateof)) return (1); instate.p = (const char *)instate.line.mem; instate.linenum = 1; diff --git a/src/utilities/util_loadtext.c b/src/utilities/util_loadtext.c index c200198a0a1..c6cd264c423 100644 --- a/src/utilities/util_loadtext.c +++ b/src/utilities/util_loadtext.c @@ -8,7 +8,7 @@ #include "util.h" -static int insert(WT_CURSOR *, const char *, int); +static int insert(WT_CURSOR *, const char *, bool); static int text(WT_SESSION *, const char *); static int usage(void); @@ -50,7 +50,8 @@ text(WT_SESSION *session, const char *uri) { WT_CURSOR *cursor; WT_DECL_RET; - int readkey, tret; + int tret; + bool readkey; /* * Open the cursor, configured to append new records (in the case of @@ -74,7 +75,7 @@ text(WT_SESSION *session, const char *uri) return (util_err(session, EINVAL, "the loadtext command can only load objects configured " "for record number or string keys, and string values")); - readkey = strcmp(cursor->key_format, "r") == 0 ? 0 : 1; + readkey = strcmp(cursor->key_format, "r") != 0; /* Insert the records */ ret = insert(cursor, uri, readkey); @@ -100,13 +101,13 @@ text(WT_SESSION *session, const char *uri) * Read and insert data. */ static int -insert(WT_CURSOR *cursor, const char *name, int readkey) +insert(WT_CURSOR *cursor, const char *name, bool readkey) { ULINE key, value; WT_DECL_RET; WT_SESSION *session; uint64_t insert_count; - int eof; + bool eof; session = cursor->session; @@ -122,15 +123,15 @@ insert(WT_CURSOR *cursor, const char *name, int readkey) * all (flat-text load). */ if (readkey) { - if (util_read_line(session, &key, 1, &eof)) + if (util_read_line(session, &key, true, &eof)) return (1); - if (eof == 1) + if (eof) break; cursor->set_key(cursor, key.mem); } - if (util_read_line(session, &value, readkey ? 0 : 1, &eof)) + if (util_read_line(session, &value, !readkey, &eof)) return (1); - if (eof == 1) + if (eof) break; cursor->set_value(cursor, value.mem); diff --git a/src/utilities/util_main.c b/src/utilities/util_main.c index 348460e95e0..9cbda08690e 100644 --- a/src/utilities/util_main.c +++ b/src/utilities/util_main.c @@ -12,7 +12,7 @@ const char *home = "."; /* Home directory */ const char *progname; /* Program name */ /* Global arguments */ const char *usage_prefix = "[-LRVv] [-C config] [-E secretkey] [-h home]"; -int verbose; /* Verbose flag */ +bool verbose = false; /* Verbose flag */ static const char *command; /* Command name */ @@ -30,7 +30,7 @@ main(int argc, char *argv[]) WT_SESSION *session; size_t len; int ch, major_v, minor_v, tret, (*func)(WT_SESSION *, int, char *[]); - int logoff, recover; + bool logoff, recover; char *p, *secretkey; const char *cmd_config, *config, *p1, *p2, *p3, *rec_config; @@ -66,7 +66,7 @@ main(int argc, char *argv[]) * needed, the user can specify -R to run recovery. */ rec_config = REC_ERROR; - logoff = recover = 0; + logoff = recover = false; /* Check for standard options. */ while ((ch = __wt_getopt(progname, argc, argv, "C:E:h:LRVv")) != EOF) switch (ch) { @@ -85,17 +85,17 @@ main(int argc, char *argv[]) break; case 'L': /* no logging */ rec_config = REC_LOGOFF; - logoff = 1; + logoff = true; break; case 'R': /* recovery */ rec_config = REC_RECOVER; - recover = 1; + recover = true; break; case 'V': /* version */ printf("%s\n", wiredtiger_version(NULL, NULL, NULL)); return (EXIT_SUCCESS); case 'v': /* verbose */ - verbose = 1; + verbose = true; break; case '?': default: diff --git a/src/utilities/util_misc.c b/src/utilities/util_misc.c index f14ad7119bd..76cb37b30dc 100644 --- a/src/utilities/util_misc.c +++ b/src/utilities/util_misc.c @@ -44,14 +44,14 @@ util_err(WT_SESSION *session, int e, const char *fmt, ...) * Read a line from stdin into a ULINE. */ int -util_read_line(WT_SESSION *session, ULINE *l, int eof_expected, int *eofp) +util_read_line(WT_SESSION *session, ULINE *l, bool eof_expected, bool *eofp) { static uint64_t line = 0; size_t len; int ch; ++line; - *eofp = 0; + *eofp = false; if (l->memsize == 0) { if ((l->mem = realloc(l->mem, l->memsize + 1024)) == NULL) @@ -62,7 +62,7 @@ util_read_line(WT_SESSION *session, ULINE *l, int eof_expected, int *eofp) if ((ch = getchar()) == EOF) { if (len == 0) { if (eof_expected) { - *eofp = 1; + *eofp = true; return (0); } return (util_err(session, 0, diff --git a/src/utilities/util_printlog.c b/src/utilities/util_printlog.c index 4ec2d0b7e1c..d202b09b228 100644 --- a/src/utilities/util_printlog.c +++ b/src/utilities/util_printlog.c @@ -14,9 +14,10 @@ int util_printlog(WT_SESSION *session, int argc, char *argv[]) { WT_DECL_RET; - int ch, printable; + int ch; + bool printable; - printable = 0; + printable = false; while ((ch = __wt_getopt(progname, argc, argv, "f:p")) != EOF) switch (ch) { case 'f': /* output file */ @@ -27,7 +28,7 @@ util_printlog(WT_SESSION *session, int argc, char *argv[]) } break; case 'p': - printable = 1; + printable = true; break; case '?': default: diff --git a/src/utilities/util_read.c b/src/utilities/util_read.c index fe9f5541d6e..a2fcc330c7d 100644 --- a/src/utilities/util_read.c +++ b/src/utilities/util_read.c @@ -16,7 +16,8 @@ util_read(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; uint64_t recno; - int ch, rkey, rval; + int ch; + bool rkey, rval; const char *uri, *value; while ((ch = __wt_getopt(progname, argc, argv, "")) != EOF) @@ -51,7 +52,7 @@ util_read(WT_SESSION *session, int argc, char *argv[]) progname); return (1); } - rkey = strcmp(cursor->key_format, "r") == 0 ? 1 : 0; + rkey = strcmp(cursor->key_format, "r") == 0; if (strcmp(cursor->value_format, "S") != 0) { fprintf(stderr, "%s: read command only possible when the value format is " @@ -64,7 +65,7 @@ util_read(WT_SESSION *session, int argc, char *argv[]) * Run through the keys, returning non-zero on error or if any requested * key isn't found. */ - for (rval = 0; *++argv != NULL;) { + for (rval = false; *++argv != NULL;) { if (rkey) { if (util_str2recno(session, *argv, &recno)) return (1); @@ -81,14 +82,14 @@ util_read(WT_SESSION *session, int argc, char *argv[]) break; case WT_NOTFOUND: (void)util_err(session, 0, "%s: not found", *argv); - rval = 1; + rval = true; break; default: return (util_cerr(cursor, "search", ret)); } } - return (rval); + return (rval ? 1 : 0); } static int diff --git a/src/utilities/util_stat.c b/src/utilities/util_stat.c index 77c420f8dee..b7558ee3be0 100644 --- a/src/utilities/util_stat.c +++ b/src/utilities/util_stat.c @@ -16,11 +16,12 @@ util_stat(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; size_t urilen; - int ch, objname_free; + int ch; + bool objname_free; const char *config, *pval, *desc; char *objname, *uri; - objname_free = 0; + objname_free = false; objname = uri = NULL; config = NULL; while ((ch = __wt_getopt(progname, argc, argv, "af")) != EOF) @@ -56,7 +57,7 @@ util_stat(WT_SESSION *session, int argc, char *argv[]) case 1: if ((objname = util_name(session, *argv, "table")) == NULL) return (1); - objname_free = 1; + objname_free = true; break; default: return (usage()); diff --git a/src/utilities/util_verify.c b/src/utilities/util_verify.c index 9d95a6c9022..12f76e9d4ed 100644 --- a/src/utilities/util_verify.c +++ b/src/utilities/util_verify.c @@ -15,18 +15,19 @@ util_verify(WT_SESSION *session, int argc, char *argv[]) { WT_DECL_RET; size_t size; - int ch, dump_address, dump_blocks, dump_pages, dump_shape; + int ch; + bool dump_address, dump_blocks, dump_pages, dump_shape; char *config, *dump_offsets, *name; - dump_address = dump_blocks = dump_pages = dump_shape = 0; + dump_address = dump_blocks = dump_pages = dump_shape = false; config = dump_offsets = name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "d:")) != EOF) switch (ch) { case 'd': if (strcmp(__wt_optarg, "dump_address") == 0) - dump_address = 1; + dump_address = true; else if (strcmp(__wt_optarg, "dump_blocks") == 0) - dump_blocks = 1; + dump_blocks = true; else if ( WT_PREFIX_MATCH(__wt_optarg, "dump_offsets=")) { if (dump_offsets != NULL) { @@ -38,9 +39,9 @@ util_verify(WT_SESSION *session, int argc, char *argv[]) dump_offsets = __wt_optarg + strlen("dump_offsets="); } else if (strcmp(__wt_optarg, "dump_pages") == 0) - dump_pages = 1; + dump_pages = true; else if (strcmp(__wt_optarg, "dump_shape") == 0) - dump_shape = 1; + dump_shape = true; else return (usage()); break; diff --git a/src/utilities/util_write.c b/src/utilities/util_write.c index e5eafa5ab25..7871040411b 100644 --- a/src/utilities/util_write.c +++ b/src/utilities/util_write.c @@ -16,18 +16,19 @@ util_write(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; uint64_t recno; - int append, ch, overwrite, rkey; + int ch; + bool append, overwrite, rkey; const char *uri; char config[100]; - append = overwrite = 0; + append = overwrite = false; while ((ch = __wt_getopt(progname, argc, argv, "ao")) != EOF) switch (ch) { case 'a': - append = 1; + append = true; break; case 'o': - overwrite = 1; + overwrite = true; break; case '?': default: @@ -68,7 +69,7 @@ util_write(WT_SESSION *session, int argc, char *argv[]) progname); return (1); } - rkey = strcmp(cursor->key_format, "r") == 0 ? 1 : 0; + rkey = strcmp(cursor->key_format, "r") == 0; if (strcmp(cursor->value_format, "S") != 0) { fprintf(stderr, "%s: write command only possible when the value format is " |