summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2017-03-16 23:50:25 -0400
committerMichael Cahill <michael.cahill@mongodb.com>2017-03-17 14:50:25 +1100
commit360b43b33170a89587a737988477d0619008ec2a (patch)
treee2941b325dbfc13000f533c500e9743a2027eb3f
parent65ab67ed8d9777285dedf89cc506b9cffc52942e (diff)
downloadmongo-360b43b33170a89587a737988477d0619008ec2a.tar.gz
WT-3216 changes suggested by clang-tidy (#3328)
-rw-r--r--dist/api_err.py2
-rw-r--r--src/async/async_api.c10
-rw-r--r--src/block/block_addr.c2
-rw-r--r--src/block/block_ext.c11
-rw-r--r--src/block/block_read.c2
-rw-r--r--src/block/block_vrfy.c2
-rw-r--r--src/btree/bt_cursor.c12
-rw-r--r--src/btree/bt_debug.c2
-rw-r--r--src/btree/bt_io.c9
-rw-r--r--src/btree/bt_read.c6
-rw-r--r--src/btree/bt_split.c6
-rw-r--r--src/btree/bt_sync.c6
-rw-r--r--src/btree/bt_vrfy_dsk.c8
-rw-r--r--src/config/config_api.c10
-rw-r--r--src/conn/conn_sweep.c2
-rw-r--r--src/cursor/cur_join.c5
-rw-r--r--src/cursor/cur_json.c87
-rw-r--r--src/cursor/cur_metadata.c4
-rw-r--r--src/cursor/cur_stat.c1
-rw-r--r--src/cursor/cur_table.c4
-rw-r--r--src/evict/evict_lru.c12
-rw-r--r--src/include/api.h11
-rw-r--r--src/include/bitstring.i2
-rw-r--r--src/include/btmem.h16
-rw-r--r--src/include/cell.i16
-rw-r--r--src/include/column.i4
-rw-r--r--src/include/connection.h4
-rw-r--r--src/include/cursor.h8
-rw-r--r--src/include/dhandle.h12
-rw-r--r--src/include/intpack.i30
-rw-r--r--src/include/lint.h14
-rw-r--r--src/include/log.h10
-rw-r--r--src/include/misc.h18
-rw-r--r--src/include/mutex.i4
-rw-r--r--src/include/os.h2
-rw-r--r--src/include/packing.i44
-rw-r--r--src/include/schema.h7
-rw-r--r--src/include/session.h2
-rw-r--r--src/include/stat.h2
-rw-r--r--src/include/wiredtiger.in18
-rw-r--r--src/log/log.c14
-rw-r--r--src/lsm/lsm_cursor.c13
-rw-r--r--src/lsm/lsm_merge.c2
-rw-r--r--src/lsm/lsm_work_unit.c8
-rw-r--r--src/reconcile/rec_write.c17
-rw-r--r--src/support/crypto.c1
-rw-r--r--src/txn/txn_ckpt.c1
-rw-r--r--src/txn/txn_recover.c2
-rw-r--r--src/utilities/util_dump.c11
-rw-r--r--src/utilities/util_load.c4
-rw-r--r--src/utilities/util_main.c117
51 files changed, 304 insertions, 313 deletions
diff --git a/dist/api_err.py b/dist/api_err.py
index 82f961a4ac9..bd379ac8d70 100644
--- a/dist/api_err.py
+++ b/dist/api_err.py
@@ -82,7 +82,7 @@ for line in open('../src/include/wiredtiger.in', 'r'):
''.join('\n * ' + l for l in textwrap.wrap(
textwrap.dedent(err.long_desc).strip(), 77)) +
'\n' if err.long_desc else ''))
- tfile.write('#define\t%s\t%d\n' % (err.name, err.value))
+ tfile.write('#define\t%s\t(%d)\n' % (err.name, err.value))
if 'undoc' in err.flags:
tfile.write('/*! @endcond */\n')
tfile.write('/*\n')
diff --git a/src/async/async_api.c b/src/async/async_api.c
index 026a008188c..b9cc995f5a5 100644
--- a/src/async/async_api.c
+++ b/src/async/async_api.c
@@ -338,17 +338,15 @@ __wt_async_reconfig(WT_SESSION_IMPL *session, const char *cfg[])
* 2. If async is off, and the user wants it on, start it.
* 3. If not a toggle and async is off, we're done.
*/
- if (conn->async_cfg && !run) {
- /* Case 1 */
+ if (conn->async_cfg && !run) { /* Case 1 */
WT_TRET(__wt_async_flush(session));
ret = __wt_async_destroy(session);
conn->async_cfg = false;
return (ret);
- } else if (!conn->async_cfg && run)
- /* Case 2 */
+ }
+ if (!conn->async_cfg && run) /* Case 2 */
return (__async_start(session));
- else if (!conn->async_cfg)
- /* Case 3 */
+ if (!conn->async_cfg) /* Case 3 */
return (0);
/*
diff --git a/src/block/block_addr.c b/src/block/block_addr.c
index 580316bdfc6..a67efca62a3 100644
--- a/src/block/block_addr.c
+++ b/src/block/block_addr.c
@@ -226,7 +226,7 @@ __wt_block_ckpt_to_buffer(WT_SESSION_IMPL *session,
ci->discard.offset, ci->discard.size, ci->discard.checksum));
a = (uint64_t)ci->file_size;
WT_RET(__wt_vpack_uint(pp, 0, a));
- a = (uint64_t)ci->ckpt_size;
+ a = ci->ckpt_size;
WT_RET(__wt_vpack_uint(pp, 0, a));
return (0);
diff --git a/src/block/block_ext.c b/src/block/block_ext.c
index 26acc8c560f..e9357d73d1d 100644
--- a/src/block/block_ext.c
+++ b/src/block/block_ext.c
@@ -634,11 +634,11 @@ __wt_block_off_free(
*/
if ((ret = __wt_block_off_remove_overlap(
session, block, &block->live.alloc, offset, size)) == 0)
- ret = __block_merge(session, block,
- &block->live.avail, offset, (wt_off_t)size);
+ ret = __block_merge(
+ session, block, &block->live.avail, offset, size);
else if (ret == WT_NOTFOUND)
- ret = __block_merge(session, block,
- &block->live.discard, offset, (wt_off_t)size);
+ ret = __block_merge(
+ session, block, &block->live.discard, offset, size);
return (ret);
}
@@ -1247,7 +1247,8 @@ __wt_block_extlist_write(WT_SESSION_IMPL *session,
WT_DECL_RET;
WT_EXT *ext;
WT_PAGE_HEADER *dsk;
- size_t entries, size;
+ uint32_t entries;
+ size_t size;
uint8_t *p;
WT_RET(__block_extlist_dump(session, block, el, "write"));
diff --git a/src/block/block_read.c b/src/block/block_read.c
index 869a92b6ae1..8d4aec7df75 100644
--- a/src/block/block_read.c
+++ b/src/block/block_read.c
@@ -39,7 +39,7 @@ __wt_bm_preload(
(uint8_t *)bm->map + offset, size, bm->mapped_cookie);
if (!mapped && handle->fh_advise != NULL)
ret = handle->fh_advise(handle, (WT_SESSION *)session,
- (wt_off_t)offset, (wt_off_t)size, WT_FILE_HANDLE_WILLNEED);
+ offset, (wt_off_t)size, WT_FILE_HANDLE_WILLNEED);
if (ret != EBUSY && ret != ENOTSUP)
return (ret);
diff --git a/src/block/block_vrfy.c b/src/block/block_vrfy.c
index 94824ad19f8..154765ed079 100644
--- a/src/block/block_vrfy.c
+++ b/src/block/block_vrfy.c
@@ -22,7 +22,7 @@ static int __verify_set_file_size(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *);
((off) / (block)->allocsize - 1)
#ifdef HAVE_VERBOSE
#define WT_FRAG_TO_OFF(block, frag) \
- (((wt_off_t)(frag + 1)) * (block)->allocsize)
+ (((wt_off_t)((frag) + 1)) * (block)->allocsize)
#endif
/*
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index d6dc0991d3f..48ae1ad6d76 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -1108,11 +1108,7 @@ retry: WT_RET(__wt_btcur_search(start));
WT_ASSERT(session,
F_MASK((WT_CURSOR *)start, WT_CURSTD_KEY_SET) == WT_CURSTD_KEY_INT);
- /*
- * Reset ret each time through so that we don't loop forever in
- * the cursor equals case.
- */
- for (ret = 0;;) {
+ for (;;) {
if ((ret = rmfunc(session, start, 1)) != 0)
break;
@@ -1176,11 +1172,7 @@ retry: WT_RET(__wt_btcur_search(start));
WT_ASSERT(session,
F_MASK((WT_CURSOR *)start, WT_CURSTD_KEY_SET) == WT_CURSTD_KEY_INT);
- /*
- * Reset ret each time through so that we don't loop forever in
- * the cursor equals case.
- */
- for (ret = 0;;) {
+ for (;;) {
value = (const uint8_t *)start->iface.value.data;
if (*value != 0 &&
(ret = rmfunc(session, start, 1)) != 0)
diff --git a/src/btree/bt_debug.c b/src/btree/bt_debug.c
index d664da2ebd3..4989301468f 100644
--- a/src/btree/bt_debug.c
+++ b/src/btree/bt_debug.c
@@ -34,7 +34,7 @@ static const /* Output separator */
static int __debug_cell(WT_DBG *, const WT_PAGE_HEADER *, WT_CELL_UNPACK *);
static int __debug_cell_data(
- WT_DBG *, WT_PAGE *, int type, const char *, WT_CELL_UNPACK *);
+ WT_DBG *, WT_PAGE *, int, const char *, WT_CELL_UNPACK *);
static int __debug_col_skip(WT_DBG *, WT_INSERT_HEAD *, const char *, bool);
static int __debug_config(WT_SESSION_IMPL *, WT_DBG *, const char *);
static int __debug_dsk_cell(WT_DBG *, const WT_PAGE_HEADER *);
diff --git a/src/btree/bt_io.c b/src/btree/bt_io.c
index a8645f79dbe..b5e4d52394a 100644
--- a/src/btree/bt_io.c
+++ b/src/btree/bt_io.c
@@ -183,7 +183,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
size_t dst_len, len, result_len, size, src_len;
int compression_failed; /* Extension API, so not a bool. */
uint8_t *dst, *src;
- bool data_checksum, encrypted;
+ bool data_checksum, encrypted, timer;
btree = S2BT(session);
bm = btree->bm;
@@ -216,7 +216,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
&result_len));
WT_ASSERT(session,
dsk->mem_size == result_len + WT_BLOCK_COMPRESS_SKIP);
- ctmp->size = (uint32_t)result_len + WT_BLOCK_COMPRESS_SKIP;
+ ctmp->size = result_len + WT_BLOCK_COMPRESS_SKIP;
ip = ctmp;
} else {
WT_ASSERT(session, dsk->mem_size == buf->size);
@@ -357,7 +357,8 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
data_checksum = !compressed;
break;
}
- if (!F_ISSET(session, WT_SESSION_INTERNAL))
+ timer = !F_ISSET(session, WT_SESSION_INTERNAL);
+ if (timer)
__wt_epoch(session, &start);
/* Call the block manager to write the block. */
@@ -367,7 +368,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
bm, session, ip, addr, addr_sizep, data_checksum, checkpoint_io));
/* Update some statistics now that the write is done */
- if (!F_ISSET(session, WT_SESSION_INTERNAL)) {
+ if (timer) {
__wt_epoch(session, &stop);
WT_STAT_CONN_INCR(session, cache_write_app_count);
WT_STAT_CONN_INCRV(session, cache_write_app_time,
diff --git a/src/btree/bt_read.c b/src/btree/bt_read.c
index e87ddc082f2..b170a9fb900 100644
--- a/src/btree/bt_read.c
+++ b/src/btree/bt_read.c
@@ -369,6 +369,7 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref)
size_t addr_size;
uint32_t previous_state;
const uint8_t *addr;
+ bool timer;
btree = S2BT(session);
page = NULL;
@@ -408,10 +409,11 @@ __page_read(WT_SESSION_IMPL *session, WT_REF *ref)
* There's an address, read or map the backing disk page and build an
* in-memory version of the page.
*/
- if (!F_ISSET(session, WT_SESSION_INTERNAL))
+ timer = !F_ISSET(session, WT_SESSION_INTERNAL);
+ if (timer)
__wt_epoch(session, &start);
WT_ERR(__wt_bt_read(session, &tmp, addr, addr_size));
- if (!F_ISSET(session, WT_SESSION_INTERNAL)) {
+ if (timer) {
__wt_epoch(session, &stop);
WT_STAT_CONN_INCR(session, cache_read_app_count);
WT_STAT_CONN_INCRV(session, cache_read_app_time,
diff --git a/src/btree/bt_split.c b/src/btree/bt_split.c
index 6b2100ec7e3..b1bad760826 100644
--- a/src/btree/bt_split.c
+++ b/src/btree/bt_split.c
@@ -10,8 +10,8 @@
#define WT_MEM_TRANSFER(from_decr, to_incr, len) do { \
size_t __len = (len); \
- from_decr += __len; \
- to_incr += __len; \
+ (from_decr) += __len; \
+ (to_incr) += __len; \
} while (0)
/*
@@ -119,7 +119,7 @@ __wt_split_stash_discard(WT_SESSION_IMPL *session)
++i, ++stash) {
if (stash->p == NULL)
continue;
- else if (stash->split_gen >= oldest)
+ if (stash->split_gen >= oldest)
break;
/*
* It's a bad thing if another thread is in this memory after
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c
index 7bf15baa67f..cdb27752fb7 100644
--- a/src/btree/bt_sync.c
+++ b/src/btree/bt_sync.c
@@ -78,6 +78,7 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop)
uint64_t internal_bytes, internal_pages, leaf_bytes, leaf_pages;
uint64_t oldest_id, saved_pinned_id;
uint32_t flags;
+ bool timer;
conn = S2C(session);
btree = S2BT(session);
@@ -88,7 +89,8 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop)
internal_bytes = leaf_bytes = 0;
internal_pages = leaf_pages = 0;
- if (WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT))
+ timer = WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT);
+ if (timer)
__wt_epoch(session, &start);
switch (syncop) {
@@ -242,7 +244,7 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop)
break;
}
- if (WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT)) {
+ if (timer) {
__wt_epoch(session, &end);
__wt_verbose(session, WT_VERB_CHECKPOINT,
"__sync_file WT_SYNC_%s wrote: %" PRIu64
diff --git a/src/btree/bt_vrfy_dsk.c b/src/btree/bt_vrfy_dsk.c
index 3a6fd8261ba..a4071c44aee 100644
--- a/src/btree/bt_vrfy_dsk.c
+++ b/src/btree/bt_vrfy_dsk.c
@@ -203,7 +203,8 @@ __verify_dsk_row(
WT_ITEM *last;
enum { FIRST, WAS_KEY, WAS_VALUE } last_cell_type;
void *huffman;
- uint32_t cell_num, cell_type, i, key_cnt, prefix;
+ size_t prefix;
+ uint32_t cell_num, cell_type, i, key_cnt;
uint8_t *end;
int cmp;
@@ -343,8 +344,9 @@ __verify_dsk_row(
if (cell_num > 1 && prefix > last->size)
WT_ERR_VRFY(session,
"key %" PRIu32 " on page at %s has a prefix "
- "compression count of %" PRIu32 ", larger than "
- "the length of the previous key, %" WT_SIZET_FMT,
+ "compression count of %" WT_SIZET_FMT
+ ", larger than the length of the previous key, %"
+ WT_SIZET_FMT,
cell_num, tag, prefix, last->size);
/*
diff --git a/src/config/config_api.c b/src/config/config_api.c
index 05c5c1287a7..9f70ba65e9b 100644
--- a/src/config/config_api.c
+++ b/src/config/config_api.c
@@ -215,7 +215,7 @@ __wt_configure_method(WT_SESSION_IMPL *session,
WT_CONFIG_ENTRY *entry;
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
- size_t cnt;
+ size_t cnt, len;
char *newcheck_name, *p;
/*
@@ -276,11 +276,9 @@ __wt_configure_method(WT_SESSION_IMPL *session,
*/
WT_ERR(__wt_calloc_one(session, &entry));
entry->method = (*epp)->method;
- WT_ERR(__wt_calloc_def(session,
- strlen((*epp)->base) + strlen(",") + strlen(config) + 1, &p));
- (void)strcpy(p, (*epp)->base);
- (void)strcat(p, ",");
- (void)strcat(p, config);
+ len = strlen((*epp)->base) + strlen(",") + strlen(config) + 1;
+ WT_ERR(__wt_calloc_def(session, len, &p));
+ snprintf(p, len, "%s,%s", (*epp)->base, config);
entry->base = p;
/*
diff --git a/src/conn/conn_sweep.c b/src/conn/conn_sweep.c
index 8c186c63939..22d90b08438 100644
--- a/src/conn/conn_sweep.c
+++ b/src/conn/conn_sweep.c
@@ -10,7 +10,7 @@
#define WT_DHANDLE_CAN_DISCARD(dhandle) \
(!F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE | WT_DHANDLE_OPEN) && \
- dhandle->session_inuse == 0 && dhandle->session_ref == 0)
+ (dhandle)->session_inuse == 0 && (dhandle)->session_ref == 0)
/*
* __sweep_mark --
diff --git a/src/cursor/cur_join.c b/src/cursor/cur_join.c
index 013a64ef2d5..8df8e201173 100644
--- a/src/cursor/cur_join.c
+++ b/src/cursor/cur_join.c
@@ -270,7 +270,7 @@ again:
iter->positioned = true;
return (ret);
}
- else if (ret == WT_NOTFOUND) {
+ if (ret == WT_NOTFOUND) {
WT_RET(__curjoin_iter_close_all(iter->child));
entry->subjoin->iter = NULL;
iter->child = NULL;
@@ -518,8 +518,7 @@ __curjoin_entry_in_range(WT_SESSION_IMPL *session, WT_CURSOR_JOIN_ENTRY *entry,
}
if (disjunction && end == endmax)
return (WT_NOTFOUND);
- else
- return (0);
+ return (0);
}
typedef struct {
diff --git a/src/cursor/cur_json.c b/src/cursor/cur_json.c
index 5870d14273e..0ad3c4f4201 100644
--- a/src/cursor/cur_json.c
+++ b/src/cursor/cur_json.c
@@ -23,20 +23,20 @@ static int __json_pack_size(WT_SESSION_IMPL *, const char *, WT_CONFIG_ITEM *,
bool, const char *, size_t *);
#define WT_PACK_JSON_GET(session, pv, jstr) do { \
- switch (pv.type) { \
+ switch ((pv).type) { \
case 'x': \
break; \
case 's': \
case 'S': \
- WT_RET(json_string_arg(session, &jstr, &pv.u.item)); \
- pv.type = pv.type == 's' ? 'j' : 'J'; \
+ WT_RET(json_string_arg(session, &(jstr), &(pv).u.item));\
+ (pv).type = (pv).type == 's' ? 'j' : 'J'; \
break; \
case 'b': \
case 'h': \
case 'i': \
case 'l': \
case 'q': \
- WT_RET(json_int_arg(session, &jstr, &pv.u.i)); \
+ WT_RET(json_int_arg(session, &(jstr), &(pv).u.i)); \
break; \
case 'B': \
case 'H': \
@@ -46,11 +46,11 @@ static int __json_pack_size(WT_SESSION_IMPL *, const char *, WT_CONFIG_ITEM *,
case 'r': \
case 'R': \
case 't': \
- WT_RET(json_uint_arg(session, &jstr, &pv.u.u)); \
+ WT_RET(json_uint_arg(session, &(jstr), &(pv).u.u)); \
break; \
case 'u': \
- WT_RET(json_string_arg(session, &jstr, &pv.u.item)); \
- pv.type = 'K'; \
+ WT_RET(json_string_arg(session, &(jstr), &(pv).u.item));\
+ (pv).type = 'K'; \
break; \
/* User format strings have already been validated. */ \
WT_ILLEGAL_VALUE(session); \
@@ -304,7 +304,6 @@ __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor)
__wt_free(session, json->value_buf);
__wt_free(session, json);
}
- return;
}
/*
@@ -323,33 +322,32 @@ __wt_json_unpack_char(u_char ch, u_char *buf, size_t bufsz, bool force_unicode)
if (bufsz >= 1)
*buf = ch;
return (1);
- } else {
- abbrev = '\0';
- switch (ch) {
- case '\\':
- case '"':
- abbrev = ch;
- break;
- case '\f':
- abbrev = 'f';
- break;
- case '\n':
- abbrev = 'n';
- break;
- case '\r':
- abbrev = 'r';
- break;
- case '\t':
- abbrev = 't';
- break;
- }
- if (abbrev != '\0') {
- if (bufsz >= 2) {
- *buf++ = '\\';
- *buf = abbrev;
- }
- return (2);
+ }
+ abbrev = '\0';
+ switch (ch) {
+ case '\\':
+ case '"':
+ abbrev = ch;
+ break;
+ case '\f':
+ abbrev = 'f';
+ break;
+ case '\n':
+ abbrev = 'n';
+ break;
+ case '\r':
+ abbrev = 'r';
+ break;
+ case '\t':
+ abbrev = 't';
+ break;
+ }
+ if (abbrev != '\0') {
+ if (bufsz >= 2) {
+ *buf++ = '\\';
+ *buf = abbrev;
}
+ return (2);
}
}
if (bufsz >= 6) {
@@ -421,16 +419,16 @@ __wt_json_column_init(WT_CURSOR *cursor, const char *uri, const char *keyformat,
#define MATCH_KEYWORD(session, in, result, keyword, matchval) do { \
size_t _kwlen = strlen(keyword); \
if (strncmp(in, keyword, _kwlen) == 0 && \
- !__wt_isalnum((u_char)in[_kwlen])) { \
- in += _kwlen; \
- result = matchval; \
+ !__wt_isalnum((u_char)(in)[_kwlen])) { \
+ (in) += _kwlen; \
+ (result) = matchval; \
} else { \
- const char *_bad = in; \
- while (__wt_isalnum((u_char)*in)) \
- in++; \
+ const char *_bad = (in); \
+ while (__wt_isalnum((u_char)*(in))) \
+ (in)++; \
WT_RET_MSG(session, EINVAL, \
"unknown keyword \"%.*s\" in JSON", \
- (int)(in - _bad), _bad); \
+ (int)((in) - _bad), _bad); \
} \
} while (0)
@@ -692,12 +690,13 @@ json_uint_arg(WT_SESSION_IMPL *session, const char **jstr, uint64_t *up)
#define JSON_EXPECT_TOKEN_GET(session, jstr, tokval, start, sz) do { \
int __tok; \
- WT_RET(__wt_json_token((WT_SESSION *)session, jstr, &__tok, &start, &sz));\
- if (__tok != tokval) \
+ WT_RET(__wt_json_token( \
+ (WT_SESSION *)(session), jstr, &__tok, &(start), &(sz))); \
+ if (__tok != (tokval)) \
WT_RET_MSG(session, EINVAL, \
"expected JSON %s, got %s", \
__wt_json_tokname(tokval), __wt_json_tokname(__tok)); \
- jstr = start + sz; \
+ (jstr) = (start) + (sz); \
} while (0)
#define JSON_EXPECT_TOKEN(session, jstr, tokval) do { \
diff --git a/src/cursor/cur_metadata.c b/src/cursor/cur_metadata.c
index 10e2fdf28be..fbfc73956e2 100644
--- a/src/cursor/cur_metadata.c
+++ b/src/cursor/cur_metadata.c
@@ -16,7 +16,7 @@
WT_CURSOR_NEEDKEY(cursor); \
WT_ERR(__wt_buf_set(session, \
&((WT_CURSOR_METADATA *)(cursor))->file_cursor->key, \
- cursor->key.data, cursor->key.size)); \
+ (cursor)->key.data, (cursor)->key.size)); \
F_SET(((WT_CURSOR_METADATA *)(cursor))->file_cursor, \
WT_CURSTD_KEY_EXT); \
} while (0)
@@ -25,7 +25,7 @@
WT_CURSOR_NEEDVALUE(cursor); \
WT_ERR(__wt_buf_set(session, \
&((WT_CURSOR_METADATA *)(cursor))->file_cursor->value, \
- cursor->value.data, cursor->value.size)); \
+ (cursor)->value.data, (cursor)->value.size)); \
F_SET(((WT_CURSOR_METADATA *)(cursor))->file_cursor, \
WT_CURSTD_VALUE_EXT); \
} while (0)
diff --git a/src/cursor/cur_stat.c b/src/cursor/cur_stat.c
index 5fde64c74ca..c5ccdb1b649 100644
--- a/src/cursor/cur_stat.c
+++ b/src/cursor/cur_stat.c
@@ -163,7 +163,6 @@ static void
__curstat_set_value(WT_CURSOR *cursor, ...)
{
WT_UNUSED(cursor);
- return;
}
/*
diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c
index 72eec177449..ef2c0ac5163 100644
--- a/src/cursor/cur_table.c
+++ b/src/cursor/cur_table.c
@@ -14,8 +14,8 @@ static int __curtable_update(WT_CURSOR *cursor);
#define APPLY_CG(ctable, f) do { \
WT_CURSOR **__cp; \
u_int __i; \
- for (__i = 0, __cp = ctable->cg_cursors; \
- __i < WT_COLGROUPS(ctable->table); \
+ for (__i = 0, __cp = (ctable)->cg_cursors; \
+ __i < WT_COLGROUPS((ctable)->table); \
__i++, __cp++) \
WT_TRET((*__cp)->f(*__cp)); \
} while (0)
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index 6863533acfb..84c9990832d 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -934,7 +934,6 @@ __evict_tune_workers(WT_SESSION_IMPL *session)
cache = conn->cache;
WT_ASSERT(session, conn->evict_threads.threads[0]->session == session);
- pgs_evicted_persec_cur = 0;
if (conn->evict_tune_stable)
return (0);
@@ -966,7 +965,8 @@ __evict_tune_workers(WT_SESSION_IMPL *session)
pgs_evicted_persec_cur = (delta_pages * WT_THOUSAND) / delta_msec;
conn->evict_tune_num_points++;
- /* Keep track of the maximum eviction throughput seen and the number
+ /*
+ * Keep track of the maximum eviction throughput seen and the number
* of workers corresponding to that throughput.
*/
if (pgs_evicted_persec_cur > conn->evict_tune_pg_sec_max) {
@@ -2116,6 +2116,7 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full)
WT_TXN_GLOBAL *txn_global;
WT_TXN_STATE *txn_state;
uint64_t init_evict_count, max_pages_evicted;
+ bool timer;
conn = S2C(session);
cache = conn->cache;
@@ -2136,7 +2137,9 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full)
__wt_evict_server_wake(session);
/* Track how long application threads spend doing eviction. */
- if (WT_STAT_ENABLED(session) && !F_ISSET(session, WT_SESSION_INTERNAL))
+ timer =
+ WT_STAT_ENABLED(session) && !F_ISSET(session, WT_SESSION_INTERNAL);
+ if (timer)
__wt_epoch(session, &enter);
for (init_evict_count = cache->pages_evict;; ret = 0) {
@@ -2202,8 +2205,7 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full)
}
}
-err: if (WT_STAT_ENABLED(session) &&
- !F_ISSET(session, WT_SESSION_INTERNAL)) {
+err: if (timer) {
__wt_epoch(session, &leave);
WT_STAT_CONN_INCRV(session,
application_cache_time, WT_TIMEDIFF_US(leave, enter));
diff --git a/src/include/api.h b/src/include/api.h
index 1fa777ed5cc..a3636eb8040 100644
--- a/src/include/api.h
+++ b/src/include/api.h
@@ -19,7 +19,7 @@
__wt_verbose((s), WT_VERB_API, "CALL: " #h ":" #n)
#define API_CALL(s, h, n, dh, config, cfg) do { \
- const char *cfg[] = \
+ const char *(cfg)[] = \
{ WT_CONFIG_BASE(s, h##_##n), config, NULL }; \
API_SESSION_INIT(s, h, n, dh); \
WT_ERR(WT_SESSION_CHECK_PANIC(s)); \
@@ -62,15 +62,16 @@
if (__autotxn) { \
if (F_ISSET(&(s)->txn, WT_TXN_AUTOCOMMIT)) \
F_CLR(&(s)->txn, WT_TXN_AUTOCOMMIT); \
- else if (ret == 0 && !F_ISSET(&(s)->txn, WT_TXN_ERROR)) \
- ret = __wt_txn_commit((s), NULL); \
+ else if ((ret) == 0 && \
+ !F_ISSET(&(s)->txn, WT_TXN_ERROR)) \
+ (ret) = __wt_txn_commit((s), NULL); \
else { \
if (retry) \
WT_TRET(__wt_session_copy_values(s)); \
WT_TRET(__wt_txn_rollback((s), NULL)); \
- if ((ret == 0 || ret == WT_ROLLBACK) && \
+ if (((ret) == 0 || (ret) == WT_ROLLBACK) && \
(retry)) { \
- ret = 0; \
+ (ret) = 0; \
continue; \
} \
WT_TRET(__wt_session_reset_cursors(s, false)); \
diff --git a/src/include/bitstring.i b/src/include/bitstring.i
index 08746beb9b9..118dc0bba01 100644
--- a/src/include/bitstring.i
+++ b/src/include/bitstring.i
@@ -230,7 +230,7 @@ __bit_getv(uint8_t *bitf, uint64_t entry, uint8_t width)
#define __BIT_GET(len, mask) \
case len: \
if (__bit_test(bitf, bit)) \
- value |= mask; \
+ value |= (mask); \
++bit \
/* FALLTHROUGH */
diff --git a/src/include/btmem.h b/src/include/btmem.h
index 39ca223aebf..f1bb08d2699 100644
--- a/src/include/btmem.h
+++ b/src/include/btmem.h
@@ -507,7 +507,7 @@ struct __wt_page {
#define WT_INTL_INDEX_GET_SAFE(page) \
((page)->u.intl.__index)
#define WT_INTL_INDEX_GET(session, page, pindex) do { \
- WT_ASSERT(session, session->split_gen != 0); \
+ WT_ASSERT(session, (session)->split_gen != 0); \
(pindex) = WT_INTL_INDEX_GET_SAFE(page); \
} while (0)
#define WT_INTL_INDEX_SET(page, v) do { \
@@ -868,7 +868,7 @@ struct __wt_col {
* Return the 0-based array offset based on a WT_COL reference.
*/
#define WT_COL_SLOT(page, cip) \
- ((uint32_t)(((WT_COL *)cip) - (page)->pg_var))
+ ((uint32_t)(((WT_COL *)(cip)) - (page)->pg_var))
/*
* WT_IKEY --
@@ -977,10 +977,10 @@ struct __wt_insert {
} key;
} u;
-#define WT_INSERT_KEY_SIZE(ins) (((WT_INSERT *)ins)->u.key.size)
+#define WT_INSERT_KEY_SIZE(ins) (((WT_INSERT *)(ins))->u.key.size)
#define WT_INSERT_KEY(ins) \
- ((void *)((uint8_t *)(ins) + ((WT_INSERT *)ins)->u.key.offset))
-#define WT_INSERT_RECNO(ins) (((WT_INSERT *)ins)->u.recno)
+ ((void *)((uint8_t *)(ins) + ((WT_INSERT *)(ins))->u.key.offset))
+#define WT_INSERT_RECNO(ins) (((WT_INSERT *)(ins))->u.recno)
WT_INSERT *next[0]; /* forward-linked skip list */
};
@@ -989,9 +989,9 @@ struct __wt_insert {
* Skiplist helper macros.
*/
#define WT_SKIP_FIRST(ins_head) \
- (((ins_head) == NULL) ? NULL : ((WT_INSERT_HEAD *)ins_head)->head[0])
+ (((ins_head) == NULL) ? NULL : ((WT_INSERT_HEAD *)(ins_head))->head[0])
#define WT_SKIP_LAST(ins_head) \
- (((ins_head) == NULL) ? NULL : ((WT_INSERT_HEAD *)ins_head)->tail[0])
+ (((ins_head) == NULL) ? NULL : ((WT_INSERT_HEAD *)(ins_head))->tail[0])
#define WT_SKIP_NEXT(ins) ((ins)->next[0])
#define WT_SKIP_FOREACH(ins, ins_head) \
for ((ins) = WT_SKIP_FIRST(ins_head); \
@@ -1004,7 +1004,7 @@ struct __wt_insert {
#define WT_PAGE_ALLOC_AND_SWAP(s, page, dest, v, count) do { \
if (((v) = (dest)) == NULL) { \
WT_ERR(__wt_calloc_def(s, count, &(v))); \
- if (__wt_atomic_cas_ptr(&dest, NULL, v)) \
+ if (__wt_atomic_cas_ptr(&(dest), NULL, v)) \
__wt_cache_page_inmem_incr( \
s, page, (count) * sizeof(*(v))); \
else \
diff --git a/src/include/cell.i b/src/include/cell.i
index c130768e595..71c2515daf0 100644
--- a/src/include/cell.i
+++ b/src/include/cell.i
@@ -361,14 +361,12 @@ __wt_cell_pack_leaf_key(WT_CELL *cell, uint8_t prefix, size_t size)
cell->__chunk[0] = (uint8_t)
((byte << WT_CELL_SHORT_SHIFT) | WT_CELL_KEY_SHORT);
return (1);
- } else {
- byte = (uint8_t)size; /* Type + length */
- cell->__chunk[0] = (uint8_t)
- ((byte << WT_CELL_SHORT_SHIFT) |
- WT_CELL_KEY_SHORT_PFX);
- cell->__chunk[1] = prefix; /* Prefix */
- return (2);
}
+ byte = (uint8_t)size; /* Type + length */
+ cell->__chunk[0] = (uint8_t)
+ ((byte << WT_CELL_SHORT_SHIFT) | WT_CELL_KEY_SHORT_PFX);
+ cell->__chunk[1] = prefix; /* Prefix */
+ return (2);
}
if (prefix == 0) {
@@ -569,8 +567,8 @@ __wt_cell_unpack_safe(
*/
#define WT_CELL_LEN_CHK(t, len) do { \
if (start != NULL && \
- ((uint8_t *)t < (uint8_t *)start || \
- (((uint8_t *)t) + (len)) > (uint8_t *)end)) \
+ ((uint8_t *)(t) < (uint8_t *)start || \
+ (((uint8_t *)(t)) + (len)) > (uint8_t *)end)) \
return (WT_ERROR); \
} while (0)
diff --git a/src/include/column.i b/src/include/column.i
index c1b45a1f4e0..07b627315e6 100644
--- a/src/include/column.i
+++ b/src/include/column.i
@@ -108,7 +108,7 @@ __col_insert_search_match(WT_INSERT_HEAD *ins_head, uint64_t recno)
/* Fast path the check for values at the end of the skiplist. */
if (recno > WT_INSERT_RECNO(ret_ins))
return (NULL);
- else if (recno == WT_INSERT_RECNO(ret_ins))
+ if (recno == WT_INSERT_RECNO(ret_ins))
return (ret_ins);
/*
@@ -127,7 +127,7 @@ __col_insert_search_match(WT_INSERT_HEAD *ins_head, uint64_t recno)
if (cmp == 0) /* Exact match: return */
return (*insp);
- else if (cmp > 0) /* Keep going at this level */
+ if (cmp > 0) /* Keep going at this level */
insp = &(*insp)->next[i];
else { /* Drop down a level */
--i;
diff --git a/src/include/connection.h b/src/include/connection.h
index ce483d3291a..6c23492e926 100644
--- a/src/include/connection.h
+++ b/src/include/connection.h
@@ -127,7 +127,7 @@ struct __wt_named_extractor {
F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST_WRITE)); \
TAILQ_INSERT_HEAD(&(conn)->dhqh, dhandle, q); \
TAILQ_INSERT_HEAD(&(conn)->dhhash[bucket], dhandle, hashq); \
- ++conn->dhandle_count; \
+ ++(conn)->dhandle_count; \
} while (0)
#define WT_CONN_DHANDLE_REMOVE(conn, dhandle, bucket) do { \
@@ -135,7 +135,7 @@ struct __wt_named_extractor {
F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST_WRITE)); \
TAILQ_REMOVE(&(conn)->dhqh, dhandle, q); \
TAILQ_REMOVE(&(conn)->dhhash[bucket], dhandle, hashq); \
- --conn->dhandle_count; \
+ --(conn)->dhandle_count; \
} while (0)
/*
diff --git a/src/include/cursor.h b/src/include/cursor.h
index 31c8963a486..f32b4250d30 100644
--- a/src/include/cursor.h
+++ b/src/include/cursor.h
@@ -73,7 +73,7 @@ struct __wt_cursor_backup {
#define WT_CURBACKUP_LOCKER 0x01 /* Hot-backup started */
uint8_t flags;
};
-#define WT_CURSOR_BACKUP_ID(cursor) (((WT_CURSOR_BACKUP *)cursor)->maxid)
+#define WT_CURSOR_BACKUP_ID(cursor) (((WT_CURSOR_BACKUP *)(cursor))->maxid)
struct __wt_cursor_btree {
WT_CURSOR iface;
@@ -474,7 +474,7 @@ struct __wt_cursor_stat {
* Return a reference to a statistic cursor's stats structures.
*/
#define WT_CURSOR_STATS(cursor) \
- (((WT_CURSOR_STAT *)cursor)->stats)
+ (((WT_CURSOR_STAT *)(cursor))->stats)
struct __wt_cursor_table {
WT_CURSOR iface;
@@ -493,7 +493,7 @@ struct __wt_cursor_table {
};
#define WT_CURSOR_PRIMARY(cursor) \
- (((WT_CURSOR_TABLE *)cursor)->cg_cursors[0])
+ (((WT_CURSOR_TABLE *)(cursor))->cg_cursors[0])
#define WT_CURSOR_RECNO(cursor) WT_STREQ((cursor)->key_format, "r")
@@ -550,4 +550,4 @@ struct __wt_cursor_table {
} while (0)
#define WT_CURSOR_RAW_OK \
- WT_CURSTD_DUMP_HEX | WT_CURSTD_DUMP_PRINT | WT_CURSTD_RAW
+ (WT_CURSTD_DUMP_HEX | WT_CURSTD_DUMP_PRINT | WT_CURSTD_RAW)
diff --git a/src/include/dhandle.h b/src/include/dhandle.h
index 4f318e7bccf..8861e96112b 100644
--- a/src/include/dhandle.h
+++ b/src/include/dhandle.h
@@ -38,20 +38,20 @@
(((WT_CURSOR_BTREE *)((s)->meta_cursor))->btree->dhandle)
#define WT_DHANDLE_ACQUIRE(dhandle) \
- (void)__wt_atomic_add32(&dhandle->session_ref, 1)
+ (void)__wt_atomic_add32(&(dhandle)->session_ref, 1)
#define WT_DHANDLE_RELEASE(dhandle) \
- (void)__wt_atomic_sub32(&dhandle->session_ref, 1)
+ (void)__wt_atomic_sub32(&(dhandle)->session_ref, 1)
#define WT_DHANDLE_NEXT(session, dhandle, head, field) do { \
WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST));\
- if (dhandle == NULL) \
- dhandle = TAILQ_FIRST(head); \
+ if ((dhandle) == NULL) \
+ (dhandle) = TAILQ_FIRST(head); \
else { \
WT_DHANDLE_RELEASE(dhandle); \
- dhandle = TAILQ_NEXT(dhandle, field); \
+ (dhandle) = TAILQ_NEXT(dhandle, field); \
} \
- if (dhandle != NULL) \
+ if ((dhandle) != NULL) \
WT_DHANDLE_ACQUIRE(dhandle); \
} while (0)
diff --git a/src/include/intpack.i b/src/include/intpack.i
index e8bea58cede..a534de9d9a8 100644
--- a/src/include/intpack.i
+++ b/src/include/intpack.i
@@ -59,21 +59,21 @@
/* Count the leading zero bytes. */
#if defined(__GNUC__)
#define WT_LEADING_ZEROS(x, i) \
- (i = (x == 0) ? (int)sizeof(x) : __builtin_clzll(x) >> 3)
+ ((i) = ((x) == 0) ? (int)sizeof(x) : __builtin_clzll(x) >> 3)
#elif defined(_MSC_VER)
#define WT_LEADING_ZEROS(x, i) do { \
- if (x == 0) i = (int)sizeof(x); \
+ if ((x) == 0) (i) = (int)sizeof(x); \
else { \
unsigned long __index; \
_BitScanReverse64(&__index, x); \
__index = 63 ^ __index; \
- i = (int)(__index >> 3); } \
+ (i) = (int)(__index >> 3); } \
} while (0)
#else
#define WT_LEADING_ZEROS(x, i) do { \
uint64_t __x = (x); \
uint64_t __m = (uint64_t)0xff << 56; \
- for (i = 0; !(__x & __m) && i != 8; i++) \
+ for ((i) = 0; !(__x & __m) && (i) != 8; (i)++) \
__m >>= 8; \
} while (0)
#endif
@@ -231,7 +231,8 @@ __wt_vpack_int(uint8_t **pp, size_t maxlen, int64_t x)
if (x < NEG_2BYTE_MIN) {
*p = NEG_MULTI_MARKER;
return (__wt_vpack_negint(pp, maxlen, (uint64_t)x));
- } else if (x < NEG_1BYTE_MIN) {
+ }
+ if (x < NEG_1BYTE_MIN) {
WT_SIZE_CHECK_PACK(2, maxlen);
x -= NEG_2BYTE_MIN;
*p++ = NEG_2BYTE_MARKER | GET_BITS(x, 13, 8);
@@ -358,12 +359,10 @@ __wt_vsize_uint(uint64_t x)
{
if (x <= POS_1BYTE_MAX)
return (1);
- else if (x <= POS_2BYTE_MAX + 1) {
+ if (x <= POS_2BYTE_MAX + 1)
return (2);
- } else {
- x -= POS_2BYTE_MAX + 1;
- return (__wt_vsize_posint(x));
- }
+ x -= POS_2BYTE_MAX + 1;
+ return (__wt_vsize_posint(x));
}
/*
@@ -373,13 +372,12 @@ __wt_vsize_uint(uint64_t x)
static inline size_t
__wt_vsize_int(int64_t x)
{
- if (x < NEG_2BYTE_MIN) {
+ if (x < NEG_2BYTE_MIN)
return (__wt_vsize_negint((uint64_t)x));
- } else if (x < NEG_1BYTE_MIN) {
+ if (x < NEG_1BYTE_MIN)
return (2);
- } else if (x < 0) {
+ if (x < 0)
return (1);
- } else
- /* For non-negative values, use the unsigned code above. */
- return (__wt_vsize_uint((uint64_t)x));
+ /* For non-negative values, use the unsigned code above. */
+ return (__wt_vsize_uint((uint64_t)x));
}
diff --git a/src/include/lint.h b/src/include/lint.h
index e20a83144ee..2d0f47988b7 100644
--- a/src/include/lint.h
+++ b/src/include/lint.h
@@ -29,9 +29,9 @@ __wt_atomic_fetch_add##name(type *vp, type v) \
{ \
type orig; \
\
- old = *vp; \
+ orig = *vp; \
*vp += v; \
- return (old); \
+ return (orig); \
} \
static inline ret \
__wt_atomic_store##name(type *vp, type v) \
@@ -40,7 +40,7 @@ __wt_atomic_store##name(type *vp, type v) \
\
orig = *vp; \
*vp = v; \
- return (old); \
+ return (orig); \
} \
static inline ret \
__wt_atomic_sub##name(type *vp, type v) \
@@ -49,9 +49,9 @@ __wt_atomic_sub##name(type *vp, type v) \
return (*vp); \
} \
static inline bool \
-__wt_atomic_cas##name(type *vp, type old, type new) \
+__wt_atomic_cas##name(type *vp, type orig, type new) \
{ \
- if (*vp == old) { \
+ if (*vp == orig) { \
*vp = new; \
return (true); \
} \
@@ -75,8 +75,8 @@ WT_ATOMIC_FUNC(size, size_t, size_t)
* Pointer compare and swap.
*/
static inline bool
-__wt_atomic_cas_ptr(void *vp, void *old, void *new) {
- if (*(void **)vp == old) {
+__wt_atomic_cas_ptr(void *vp, void *orig, void *new) {
+ if (*(void **)vp == orig) {
*(void **)vp = new;
return (true);
}
diff --git a/src/include/log.h b/src/include/log.h
index a6be3582b4d..f0999ba316b 100644
--- a/src/include/log.h
+++ b/src/include/log.h
@@ -86,8 +86,8 @@ union __wt_lsn {
* The high bit is reserved for the special states. If the high bit is
* set (WT_LOG_SLOT_RESERVED) then we are guaranteed to be in a special state.
*/
-#define WT_LOG_SLOT_FREE -1 /* Not in use */
-#define WT_LOG_SLOT_WRITTEN -2 /* Slot data written, not processed */
+#define WT_LOG_SLOT_FREE (-1) /* Not in use */
+#define WT_LOG_SLOT_WRITTEN (-2) /* Slot data written, not processed */
/*
* We allocate the buffer size, but trigger a slot switch when we cross
@@ -144,8 +144,8 @@ union __wt_lsn {
/* Slot is in use, but closed to new joins */
#define WT_LOG_SLOT_CLOSED(state) \
(WT_LOG_SLOT_ACTIVE(state) && \
- (FLD64_ISSET((uint64_t)state, WT_LOG_SLOT_CLOSE) && \
- !FLD64_ISSET((uint64_t)state, WT_LOG_SLOT_RESERVED)))
+ (FLD64_ISSET((uint64_t)(state), WT_LOG_SLOT_CLOSE) && \
+ !FLD64_ISSET((uint64_t)(state), WT_LOG_SLOT_RESERVED)))
/* Slot is in use, all data copied into buffer */
#define WT_LOG_SLOT_INPROGRESS(state) \
(WT_LOG_SLOT_RELEASED(state) != WT_LOG_SLOT_JOINED(state))
@@ -185,7 +185,7 @@ struct __wt_logslot {
#define WT_WITH_SLOT_LOCK(session, log, op) do { \
WT_ASSERT(session, !F_ISSET(session, WT_SESSION_LOCKED_SLOT)); \
WT_WITH_LOCK_WAIT(session, \
- &log->log_slot_lock, WT_SESSION_LOCKED_SLOT, op); \
+ &(log)->log_slot_lock, WT_SESSION_LOCKED_SLOT, op); \
} while (0)
struct __wt_myslot {
diff --git a/src/include/misc.h b/src/include/misc.h
index 7aba397e173..9161a215fdc 100644
--- a/src/include/misc.h
+++ b/src/include/misc.h
@@ -63,7 +63,7 @@
#define WT_MAX(a, b) ((a) < (b) ? (b) : (a))
/* Elements in an array. */
-#define WT_ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
+#define WT_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
/* 10 level skip lists, 1/4 have a link to the next element. */
#define WT_SKIP_MAXDEPTH 10
@@ -181,14 +181,14 @@
*/
#define WT_BINARY_SEARCH(key, arrayp, n, found) do { \
uint32_t __base, __indx, __limit; \
- found = false; \
+ (found) = false; \
for (__base = 0, __limit = (n); __limit != 0; __limit >>= 1) { \
__indx = __base + (__limit >> 1); \
- if ((arrayp)[__indx] < key) { \
+ if ((arrayp)[__indx] < (key)) { \
__base = __indx + 1; \
--__limit; \
- } else if ((arrayp)[__indx] == key) { \
- found = true; \
+ } else if ((arrayp)[__indx] == (key)) { \
+ (found) = true; \
break; \
} \
} \
@@ -207,8 +207,8 @@
/* Check if a string matches a prefix. */
#define WT_PREFIX_MATCH(str, pfx) \
- (((const char *)(str))[0] == ((const char *)pfx)[0] && \
- strncmp((str), (pfx), strlen(pfx)) == 0)
+ (((const char *)(str))[0] == ((const char *)(pfx))[0] && \
+ strncmp(str, pfx, strlen(pfx)) == 0)
/* Check if a string matches a prefix, and move past it. */
#define WT_PREFIX_SKIP(str, pfx) \
@@ -225,8 +225,8 @@
/* Check if a string matches a byte string of len bytes. */
#define WT_STRING_MATCH(str, bytes, len) \
- (((const char *)str)[0] == ((const char *)bytes)[0] && \
- strncmp(str, bytes, len) == 0 && (str)[(len)] == '\0')
+ (((const char *)(str))[0] == ((const char *)(bytes))[0] && \
+ strncmp(str, bytes, len) == 0 && (str)[len] == '\0')
/*
* Macro that produces a string literal that isn't wrapped in quotes, to avoid
diff --git a/src/include/mutex.i b/src/include/mutex.i
index 6b83cb280d3..640706284c3 100644
--- a/src/include/mutex.i
+++ b/src/include/mutex.i
@@ -316,6 +316,6 @@ __wt_spin_trylock_track(WT_SESSION_IMPL *session, WT_SPINLOCK *t)
stats = (int64_t **)S2C(session)->stats;
stats[session->stat_bucket][t->stat_count_off]++;
return (0);
- } else
- return (__wt_spin_trylock(session, t));
+ }
+ return (__wt_spin_trylock(session, t));
}
diff --git a/src/include/os.h b/src/include/os.h
index 8505649a1fd..73d89268392 100644
--- a/src/include/os.h
+++ b/src/include/os.h
@@ -67,7 +67,7 @@
#define WT_TIMECMP(t1, t2) \
((t1).tv_sec < (t2).tv_sec ? -1 : \
- (t1).tv_sec == (t2.tv_sec) ? \
+ (t1).tv_sec == (t2).tv_sec ? \
(t1).tv_nsec < (t2).tv_nsec ? -1 : \
(t1).tv_nsec == (t2).tv_nsec ? 0 : 1 : 1)
diff --git a/src/include/packing.i b/src/include/packing.i
index 8ba3dd536ac..d79afe6d4a2 100644
--- a/src/include/packing.i
+++ b/src/include/packing.i
@@ -206,43 +206,43 @@ next: if (pack->cur == pack->end)
#define WT_PACK_GET(session, pv, ap) do { \
WT_ITEM *__item; \
- switch (pv.type) { \
+ switch ((pv).type) { \
case 'x': \
break; \
case 's': \
case 'S': \
- pv.u.s = va_arg(ap, const char *); \
+ (pv).u.s = va_arg(ap, const char *); \
break; \
case 'U': \
case 'u': \
__item = va_arg(ap, WT_ITEM *); \
- pv.u.item.data = __item->data; \
- pv.u.item.size = __item->size; \
+ (pv).u.item.data = __item->data; \
+ (pv).u.item.size = __item->size; \
break; \
case 'b': \
case 'h': \
case 'i': \
- pv.u.i = va_arg(ap, int); \
+ (pv).u.i = va_arg(ap, int); \
break; \
case 'B': \
case 'H': \
case 'I': \
case 't': \
- pv.u.u = va_arg(ap, unsigned int); \
+ (pv).u.u = va_arg(ap, unsigned int); \
break; \
case 'l': \
- pv.u.i = va_arg(ap, long); \
+ (pv).u.i = va_arg(ap, long); \
break; \
case 'L': \
- pv.u.u = va_arg(ap, unsigned long); \
+ (pv).u.u = va_arg(ap, unsigned long); \
break; \
case 'q': \
- pv.u.i = va_arg(ap, int64_t); \
+ (pv).u.i = va_arg(ap, int64_t); \
break; \
case 'Q': \
case 'r': \
case 'R': \
- pv.u.u = va_arg(ap, uint64_t); \
+ (pv).u.u = va_arg(ap, uint64_t); \
break; \
/* User format strings have already been validated. */ \
WT_ILLEGAL_VALUE(session); \
@@ -556,47 +556,47 @@ __unpack_read(WT_SESSION_IMPL *session,
#define WT_UNPACK_PUT(session, pv, ap) do { \
WT_ITEM *__item; \
- switch (pv.type) { \
+ switch ((pv).type) { \
case 'x': \
break; \
case 's': \
case 'S': \
- *va_arg(ap, const char **) = pv.u.s; \
+ *va_arg(ap, const char **) = (pv).u.s; \
break; \
case 'U': \
case 'u': \
__item = va_arg(ap, WT_ITEM *); \
- __item->data = pv.u.item.data; \
- __item->size = pv.u.item.size; \
+ __item->data = (pv).u.item.data; \
+ __item->size = (pv).u.item.size; \
break; \
case 'b': \
- *va_arg(ap, int8_t *) = (int8_t)pv.u.i; \
+ *va_arg(ap, int8_t *) = (int8_t)(pv).u.i; \
break; \
case 'h': \
- *va_arg(ap, int16_t *) = (short)pv.u.i; \
+ *va_arg(ap, int16_t *) = (short)(pv).u.i; \
break; \
case 'i': \
case 'l': \
- *va_arg(ap, int32_t *) = (int32_t)pv.u.i; \
+ *va_arg(ap, int32_t *) = (int32_t)(pv).u.i; \
break; \
case 'q': \
- *va_arg(ap, int64_t *) = pv.u.i; \
+ *va_arg(ap, int64_t *) = (pv).u.i; \
break; \
case 'B': \
case 't': \
- *va_arg(ap, uint8_t *) = (uint8_t)pv.u.u; \
+ *va_arg(ap, uint8_t *) = (uint8_t)(pv).u.u; \
break; \
case 'H': \
- *va_arg(ap, uint16_t *) = (uint16_t)pv.u.u; \
+ *va_arg(ap, uint16_t *) = (uint16_t)(pv).u.u; \
break; \
case 'I': \
case 'L': \
- *va_arg(ap, uint32_t *) = (uint32_t)pv.u.u; \
+ *va_arg(ap, uint32_t *) = (uint32_t)(pv).u.u; \
break; \
case 'Q': \
case 'r': \
case 'R': \
- *va_arg(ap, uint64_t *) = pv.u.u; \
+ *va_arg(ap, uint64_t *) = (pv).u.u; \
break; \
/* User format strings have already been validated. */ \
WT_ILLEGAL_VALUE(session); \
diff --git a/src/include/schema.h b/src/include/schema.h
index 9a6e1e54e80..50e141d9921 100644
--- a/src/include/schema.h
+++ b/src/include/schema.h
@@ -107,10 +107,11 @@ struct __wt_table {
* Acquire a lock if available, perform an operation, drop the lock.
*/
#define WT_WITH_LOCK_NOWAIT(session, ret, lock, flag, op) do { \
- ret = 0; \
+ (ret) = 0; \
if (F_ISSET(session, (flag))) { \
op; \
- } else if ((ret = __wt_spin_trylock_track(session, lock)) == 0) {\
+ } else if (((ret) = \
+ __wt_spin_trylock_track(session, lock)) == 0) { \
F_SET(session, (flag)); \
op; \
F_CLR(session, (flag)); \
@@ -248,7 +249,7 @@ struct __wt_table {
WT_SESSION_LOCKED_HANDLE_LIST)); \
if (F_ISSET(session, WT_SESSION_LOCKED_TABLE_WRITE)) { \
op; \
- } else if ((ret = __wt_try_writelock(session, \
+ } else if (((ret) = __wt_try_writelock(session, \
&S2C(session)->table_lock)) == 0) { \
F_SET(session, WT_SESSION_LOCKED_TABLE_WRITE); \
op; \
diff --git a/src/include/session.h b/src/include/session.h
index dec97cff5d3..674e92671b1 100644
--- a/src/include/session.h
+++ b/src/include/session.h
@@ -87,7 +87,7 @@ struct __wt_session_impl {
void *meta_track_sub; /* Child transaction / save point */
size_t meta_track_alloc; /* Currently allocated */
int meta_track_nest; /* Nesting level of meta transaction */
-#define WT_META_TRACKING(session) (session->meta_track_next != NULL)
+#define WT_META_TRACKING(session) ((session)->meta_track_next != NULL)
/*
* Each session keeps a cache of table handles. The set of handles
diff --git a/src/include/stat.h b/src/include/stat.h
index 8b2e78a4ed5..ed3d588b7d3 100644
--- a/src/include/stat.h
+++ b/src/include/stat.h
@@ -72,7 +72,7 @@
* and the session ID is a small, monotonically increasing number.
*/
#define WT_STATS_SLOT_ID(session) \
- ((session)->id) % WT_COUNTER_SLOTS
+ (((session)->id) % WT_COUNTER_SLOTS)
/*
* Statistic structures are arrays of int64_t's. We have functions to read/write
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index 5dd9a720e31..7223aeae0f6 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -36,7 +36,7 @@ extern "C" {
#if defined(DOXYGEN) || defined(SWIG)
#define __F(func) func
#else
-#define __F(func) (*func)
+#define __F(func) (*(func))
#endif
#ifdef SWIG
@@ -3073,27 +3073,27 @@ const char *wiredtiger_version(int *majorp, int *minorp, int *patchp);
* transaction is in progress, it should be rolled back and the operation
* retried in a new transaction.
*/
-#define WT_ROLLBACK -31800
+#define WT_ROLLBACK (-31800)
/*!
* Attempt to insert an existing key.
* This error is generated when the application attempts to insert a record with
* the same key as an existing record without the 'overwrite' configuration to
* WT_SESSION::open_cursor.
*/
-#define WT_DUPLICATE_KEY -31801
+#define WT_DUPLICATE_KEY (-31801)
/*!
* Non-specific WiredTiger error.
* This error is returned when an error is not covered by a specific error
* return.
*/
-#define WT_ERROR -31802
+#define WT_ERROR (-31802)
/*!
* Item not found.
* This error indicates an operation did not find a value to return. This
* includes cursor search and other operations where no record matched the
* cursor's search key such as WT_CURSOR::update or WT_CURSOR::remove.
*/
-#define WT_NOTFOUND -31803
+#define WT_NOTFOUND (-31803)
/*!
* WiredTiger library panic.
* This error indicates an underlying problem that requires the application exit
@@ -3101,17 +3101,17 @@ const char *wiredtiger_version(int *majorp, int *minorp, int *patchp);
* returned from a WiredTiger interface, no further WiredTiger calls are
* required.
*/
-#define WT_PANIC -31804
+#define WT_PANIC (-31804)
/*! @cond internal */
/*! Restart the operation (internal). */
-#define WT_RESTART -31805
+#define WT_RESTART (-31805)
/*! @endcond */
/*!
* Recovery must be run to continue.
* This error is generated when wiredtiger_open is configured to return an error
* if recovery is required to use the database.
*/
-#define WT_RUN_RECOVERY -31806
+#define WT_RUN_RECOVERY (-31806)
/*!
* Operation would overflow cache.
* This error is only generated when wiredtiger_open is configured to run in-
@@ -3120,7 +3120,7 @@ const char *wiredtiger_version(int *majorp, int *minorp, int *patchp);
* progress, it should be rolled back and the operation retried in a new
* transaction.
*/
-#define WT_CACHE_FULL -31807
+#define WT_CACHE_FULL (-31807)
/*
* Error return section: END
* DO NOT EDIT: automatically built by dist/api_err.py.
diff --git a/src/log/log.c b/src/log/log.c
index 3477ca52502..05234619d32 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -309,14 +309,11 @@ void
__wt_log_written_reset(WT_SESSION_IMPL *session)
{
WT_CONNECTION_IMPL *conn;
- WT_LOG *log;
conn = S2C(session);
- if (!FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
- return;
- log = conn->log;
- log->log_written = 0;
- return;
+
+ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
+ conn->log->log_written = 0;
}
/*
@@ -1775,9 +1772,8 @@ advance:
if (eol)
/* Found a hole. This LSN is the end. */
break;
- else
- /* Last record in log. Look for more. */
- goto advance;
+ /* Last record in log. Look for more. */
+ goto advance;
}
rdup_len = __wt_rduppo2(reclen, allocsize);
if (reclen > allocsize) {
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index bd1daaa6915..2a34240de46 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -10,10 +10,10 @@
#define WT_FORALL_CURSORS(clsm, c, i) \
for ((i) = (clsm)->nchunks; (i) > 0;) \
- if (((c) = (clsm)->chunks[--i]->cursor) != NULL)
+ if (((c) = (clsm)->chunks[--(i)]->cursor) != NULL)
#define WT_LSM_CURCMP(s, lsm_tree, c1, c2, cmp) \
- __wt_compare(s, (lsm_tree)->collator, &(c1)->key, &(c2)->key, &cmp)
+ __wt_compare(s, (lsm_tree)->collator, &(c1)->key, &(c2)->key, &(cmp))
static int __clsm_lookup(WT_CURSOR_LSM *, WT_ITEM *);
static int __clsm_open_cursors(WT_CURSOR_LSM *, bool, u_int, uint32_t);
@@ -1223,7 +1223,8 @@ __clsm_lookup(WT_CURSOR_LSM *clsm, WT_ITEM *value)
WT_LSM_TREE_STAT_INCR(
session, clsm->lsm_tree->bloom_miss);
continue;
- } else if (ret == 0)
+ }
+ if (ret == 0)
WT_LSM_TREE_STAT_INCR(
session, clsm->lsm_tree->bloom_hit);
WT_ERR(ret);
@@ -1328,7 +1329,8 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp)
if ((ret = c->search_near(c, &cmp)) == WT_NOTFOUND) {
ret = 0;
continue;
- } else if (ret != 0)
+ }
+ if (ret != 0)
goto err;
/* Do we have an exact match? */
@@ -1348,7 +1350,8 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp)
if ((ret = c->next(c)) == WT_NOTFOUND) {
ret = 0;
continue;
- } else if (ret != 0)
+ }
+ if (ret != 0)
goto err;
}
diff --git a/src/lsm/lsm_merge.c b/src/lsm/lsm_merge.c
index ceb5f03a2f5..a06b736bf0a 100644
--- a/src/lsm/lsm_merge.c
+++ b/src/lsm/lsm_merge.c
@@ -187,7 +187,7 @@ __lsm_merge_span(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree,
continue;
if (F_ISSET(chunk, WT_LSM_CHUNK_BLOOM) || chunk->generation > 0)
break;
- else if (FLD_ISSET(lsm_tree->bloom, WT_LSM_BLOOM_OFF) &&
+ if (FLD_ISSET(lsm_tree->bloom, WT_LSM_BLOOM_OFF) &&
F_ISSET(chunk, WT_LSM_CHUNK_ONDISK))
break;
}
diff --git a/src/lsm/lsm_work_unit.c b/src/lsm/lsm_work_unit.c
index 0b0801a8cca..358c43eab96 100644
--- a/src/lsm/lsm_work_unit.c
+++ b/src/lsm/lsm_work_unit.c
@@ -230,7 +230,7 @@ __wt_lsm_work_bloom(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
if (__wt_atomic_cas32(&chunk->bloom_busy, 0, 1)) {
if (!F_ISSET(chunk, WT_LSM_CHUNK_BLOOM)) {
ret = __lsm_bloom_create(
- session, lsm_tree, chunk, (u_int)i);
+ session, lsm_tree, chunk, i);
/*
* Record if we were successful so that we can
* later push a merge work unit.
@@ -662,7 +662,8 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
if (drop_ret == EBUSY) {
++skipped;
continue;
- } else if (drop_ret != ENOENT)
+ }
+ if (drop_ret != ENOENT)
WT_ERR(drop_ret);
flush_metadata = true;
@@ -673,7 +674,8 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
if (drop_ret == EBUSY) {
++skipped;
continue;
- } else if (drop_ret != ENOENT)
+ }
+ if (drop_ret != ENOENT)
WT_ERR(drop_ret);
flush_metadata = true;
}
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 88d4397fcb5..23f654caa70 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -1395,7 +1395,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r,
*/
#define WT_CHILD_RELEASE(session, hazard, ref) do { \
if (hazard) { \
- hazard = false; \
+ (hazard) = false; \
WT_TRET( \
__wt_page_release(session, ref, WT_READ_NO_EVICT)); \
} \
@@ -1737,7 +1737,7 @@ __rec_copy_incr(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_KV *kv)
* WT_CELLs are typically small, 1 or 2 bytes -- don't call memcpy, do
* the copy in-line.
*/
- for (p = (uint8_t *)r->first_free,
+ for (p = r->first_free,
t = (uint8_t *)&kv->cell, len = kv->cell_len; len > 0; --len)
*p++ = *t++;
@@ -2889,7 +2889,7 @@ no_slots:
len = WT_PTRDIFF(
r->first_free, (uint8_t *)dsk + dsk_dst->mem_size);
dsk_start = WT_PAGE_HEADER_BYTE(btree, dsk);
- (void)memmove(dsk_start, (uint8_t *)r->first_free - len, len);
+ (void)memmove(dsk_start, r->first_free - len, len);
r->entries -= r->raw_entries[result_slots - 1];
r->first_free = dsk_start + len;
@@ -3605,16 +3605,7 @@ __wt_bulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk)
r = cbulk->reconcile;
r->is_bulk_load = true;
- recno = WT_RECNO_OOB; /* -Werror=maybe-uninitialized */
- switch (btree->type) {
- case BTREE_COL_FIX:
- case BTREE_COL_VAR:
- recno = 1;
- break;
- case BTREE_ROW:
- recno = WT_RECNO_OOB;
- break;
- }
+ recno = btree->type == BTREE_ROW ? WT_RECNO_OOB : 1;
return (__rec_split_init(
session, r, cbulk->leaf, recno, btree->maxleafpage));
diff --git a/src/support/crypto.c b/src/support/crypto.c
index ab94ec2c829..cce0d228832 100644
--- a/src/support/crypto.c
+++ b/src/support/crypto.c
@@ -133,5 +133,4 @@ __wt_encrypt_size(WT_SESSION_IMPL *session,
return;
*sizep = incoming_size + kencryptor->size_const + WT_ENCRYPT_LEN_SIZE;
- return;
}
diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
index 80cdf1cd39b..6c97922f7e1 100644
--- a/src/txn/txn_ckpt.c
+++ b/src/txn/txn_ckpt.c
@@ -422,7 +422,6 @@ __checkpoint_reduce_dirty_cache(WT_SESSION_IMPL *session)
__wt_sleep(0, stepdown_us / 10);
__wt_epoch(session, &stop);
current_us = WT_TIMEDIFF_US(stop, last);
- total_ms = WT_TIMEDIFF_MS(stop, start);
bytes_written_total =
cache->bytes_written - bytes_written_start;
diff --git a/src/txn/txn_recover.c b/src/txn/txn_recover.c
index 2d8a77a69e6..30932195b1e 100644
--- a/src/txn/txn_recover.c
+++ b/src/txn/txn_recover.c
@@ -93,7 +93,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r,
"%s op %" PRIu32 " to file %" PRIu32 " at LSN %" PRIu32 \
"/%" PRIu32, \
cursor == NULL ? "Skipping" : "Applying", \
- optype, fileid, lsnp->l.file, lsnp->l.offset); \
+ optype, fileid, (lsnp)->l.file, (lsnp)->l.offset); \
if (cursor == NULL) \
break
diff --git a/src/utilities/util_dump.c b/src/utilities/util_dump.c
index cded40a8b45..947fa7bf9ef 100644
--- a/src/utilities/util_dump.c
+++ b/src/utilities/util_dump.c
@@ -504,17 +504,18 @@ dump_prefix(WT_SESSION *session, bool hex, bool json)
(void)wiredtiger_version(&vmajor, &vminor, &vpatch);
+ if (json && printf(
+ " \"%s\" : \"%d (%d.%d.%d)\",\n",
+ DUMP_JSON_VERSION_MARKER, DUMP_JSON_CURRENT_VERSION,
+ vmajor, vminor, vpatch) < 0)
+ return (util_err(session, EIO, NULL));
+
if (!json && (printf(
"WiredTiger Dump (WiredTiger Version %d.%d.%d)\n",
vmajor, vminor, vpatch) < 0 ||
printf("Format=%s\n", hex ? "hex" : "print") < 0 ||
printf("Header\n") < 0))
return (util_err(session, EIO, NULL));
- else if (json && printf(
- " \"%s\" : \"%d (%d.%d.%d)\",\n",
- DUMP_JSON_VERSION_MARKER, DUMP_JSON_CURRENT_VERSION,
- vmajor, vminor, vpatch) < 0)
- return (util_err(session, EIO, NULL));
return (0);
}
diff --git a/src/utilities/util_load.c b/src/utilities/util_load.c
index ca77643eb49..d31fa4c9d08 100644
--- a/src/utilities/util_load.c
+++ b/src/utilities/util_load.c
@@ -80,8 +80,8 @@ util_load(WT_SESSION *session, int argc, char *argv[])
if (no_overwrite)
flags |= LOAD_JSON_NO_OVERWRITE;
return (util_load_json(session, filename, flags));
- } else
- return (load_dump(session));
+ }
+ return (load_dump(session));
}
/*
diff --git a/src/utilities/util_main.c b/src/utilities/util_main.c
index 7157f0d90fe..68e3b0f1bc5 100644
--- a/src/utilities/util_main.c
+++ b/src/utilities/util_main.c
@@ -20,7 +20,43 @@ static const char *command; /* Command name */
#define REC_LOGOFF "log=(enabled=false)"
#define REC_RECOVER "log=(recover=on)"
-static int usage(void);
+static void
+usage(void)
+{
+ fprintf(stderr,
+ "WiredTiger Data Engine (version %d.%d)\n",
+ WIREDTIGER_VERSION_MAJOR, WIREDTIGER_VERSION_MINOR);
+ fprintf(stderr,
+ "global options:\n"
+ "\t" "-C\t" "wiredtiger_open configuration\n"
+ "\t" "-h\t" "database directory\n"
+ "\t" "-L\t" "turn logging off for debug-mode\n"
+ "\t" "-R\t" "run recovery if configured\n"
+ "\t" "-V\t" "display library version and exit\n"
+ "\t" "-v\t" "verbose\n");
+ fprintf(stderr,
+ "commands:\n"
+ "\t" "alter\t alter an object\n"
+ "\t" "backup\t database backup\n"
+ "\t" "compact\t compact an object\n"
+ "\t" "copyright copyright information\n"
+ "\t" "create\t create an object\n"
+ "\t" "drop\t drop an object\n"
+ "\t" "dump\t dump an object\n"
+ "\t" "list\t list database objects\n"
+ "\t" "load\t load an object\n"
+ "\t" "loadtext load an object from a text file\n"
+ "\t" "printlog display the database log\n"
+ "\t" "read\t read values from an object\n"
+ "\t" "rebalance rebalance an object\n"
+ "\t" "rename\t rename an object\n"
+ "\t" "salvage\t salvage a file\n"
+ "\t" "stat\t display statistics for an object\n"
+ "\t" "truncate truncate an object, removing all content\n"
+ "\t" "upgrade\t upgrade an object\n"
+ "\t" "verify\t verify an object\n"
+ "\t" "write\t write values to an object\n");
+}
int
main(int argc, char *argv[])
@@ -73,8 +109,9 @@ main(int argc, char *argv[])
cmd_config = __wt_optarg;
break;
case 'E': /* secret key */
+ free(secretkey); /* lint: set more than once */
if ((secretkey = strdup(__wt_optarg)) == NULL) {
- ret = util_err(NULL, errno, NULL);
+ (void)util_err(NULL, errno, NULL);
goto err;
}
memset(__wt_optarg, 0, strlen(__wt_optarg));
@@ -92,24 +129,27 @@ main(int argc, char *argv[])
break;
case 'V': /* version */
printf("%s\n", wiredtiger_version(NULL, NULL, NULL));
- return (EXIT_SUCCESS);
+ goto done;
case 'v': /* verbose */
verbose = true;
break;
case '?':
default:
- return (usage());
+ usage();
+ goto err;
}
if (logoff && recover) {
fprintf(stderr, "Only one of -L and -R is allowed.\n");
- return (EXIT_FAILURE);
+ goto err;
}
argc -= __wt_optind;
argv += __wt_optind;
/* The next argument is the command name. */
- if (argc < 1)
- return (usage());
+ if (argc < 1) {
+ usage();
+ goto err;
+ }
command = argv[0];
/* Reset getopt. */
@@ -130,7 +170,7 @@ main(int argc, char *argv[])
func = util_compact;
else if (strcmp(command, "copyright") == 0) {
util_copyright();
- return (EXIT_SUCCESS);
+ goto done;
} else if (strcmp(command, "create") == 0) {
func = util_create;
config = "create";
@@ -194,8 +234,10 @@ main(int argc, char *argv[])
default:
break;
}
- if (func == NULL)
- return (usage());
+ if (func == NULL) {
+ usage();
+ goto err;
+ }
/* Build the configuration string. */
len = 10; /* some slop */
@@ -212,7 +254,7 @@ main(int argc, char *argv[])
}
len += strlen(rec_config);
if ((p = malloc(len)) == NULL) {
- ret = util_err(NULL, errno, NULL);
+ (void)util_err(NULL, errno, NULL);
goto err;
}
(void)snprintf(p, len, "%s,%s,%s%s%s%s",
@@ -223,19 +265,24 @@ main(int argc, char *argv[])
/* Open the database and a session. */
if ((ret = wiredtiger_open(home,
verbose ? verbose_handler : NULL, config, &conn)) != 0) {
- ret = util_err(NULL, ret, NULL);
+ (void)util_err(NULL, ret, NULL);
goto err;
}
if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) {
- ret = util_err(NULL, ret, NULL);
+ (void)util_err(NULL, ret, NULL);
goto err;
}
/* Call the function. */
ret = func(session, argc, argv);
+ if (0) {
+err: ret = 1;
+ }
+done:
+
/* Close the database. */
-err: if (conn != NULL && (tret = conn->close(conn, NULL)) != 0 && ret == 0)
+ if (conn != NULL && (tret = conn->close(conn, NULL)) != 0 && ret == 0)
ret = tret;
free(p);
@@ -244,46 +291,6 @@ err: if (conn != NULL && (tret = conn->close(conn, NULL)) != 0 && ret == 0)
return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
-static int
-usage(void)
-{
- fprintf(stderr,
- "WiredTiger Data Engine (version %d.%d)\n",
- WIREDTIGER_VERSION_MAJOR, WIREDTIGER_VERSION_MINOR);
- fprintf(stderr,
- "global options:\n"
- "\t" "-C\t" "wiredtiger_open configuration\n"
- "\t" "-h\t" "database directory\n"
- "\t" "-L\t" "turn logging off for debug-mode\n"
- "\t" "-R\t" "run recovery if configured\n"
- "\t" "-V\t" "display library version and exit\n"
- "\t" "-v\t" "verbose\n");
- fprintf(stderr,
- "commands:\n"
- "\t" "alter\t alter an object\n"
- "\t" "backup\t database backup\n"
- "\t" "compact\t compact an object\n"
- "\t" "copyright copyright information\n"
- "\t" "create\t create an object\n"
- "\t" "drop\t drop an object\n"
- "\t" "dump\t dump an object\n"
- "\t" "list\t list database objects\n"
- "\t" "load\t load an object\n"
- "\t" "loadtext load an object from a text file\n"
- "\t" "printlog display the database log\n"
- "\t" "read\t read values from an object\n"
- "\t" "rebalance rebalance an object\n"
- "\t" "rename\t rename an object\n"
- "\t" "salvage\t salvage a file\n"
- "\t" "stat\t display statistics for an object\n"
- "\t" "truncate truncate an object, removing all content\n"
- "\t" "upgrade\t upgrade an object\n"
- "\t" "verify\t verify an object\n"
- "\t" "write\t write values to an object\n");
-
- return (EXIT_FAILURE);
-}
-
/*
* util_uri --
* Build a name.
@@ -314,7 +321,7 @@ util_uri(WT_SESSION *session, const char *s, const char *type)
* the default type for the operation.
*/
if (strchr(s, ':') != NULL)
- strcpy(name, s);
+ snprintf(name, len, "%s", s);
else
snprintf(name, len, "%s:%s", type, s);
return (name);