summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2015-09-25 09:47:19 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2015-09-29 16:56:36 +1000
commit4b6157e191d644603e6c0642aed1e9f07eee596d (patch)
treea3bc4859b2dac87d4cbc571e8b9fefe2377f49c5 /src
parentd1dff562e256cf3726f8ec229feced879f212096 (diff)
downloadmongo-4b6157e191d644603e6c0642aed1e9f07eee596d.tar.gz
WT-2112 Use bool in more places
Merge pull request #2216 from wiredtiger/more-bool (cherry picked from commit 53638a10713925406f92d20fa840a94cd2cfa22a)
Diffstat (limited to 'src')
-rw-r--r--src/async/async_api.c23
-rw-r--r--src/block/block_write.c4
-rw-r--r--src/btree/bt_curnext.c2
-rw-r--r--src/btree/bt_curprev.c2
-rw-r--r--src/btree/bt_cursor.c10
-rw-r--r--src/btree/bt_delete.c2
-rw-r--r--src/btree/bt_split.c7
-rw-r--r--src/config/config.c22
-rw-r--r--src/config/config_check.c26
-rw-r--r--src/config/config_collapse.c2
-rw-r--r--src/conn/conn_api.c12
-rw-r--r--src/conn/conn_cache.c4
-rw-r--r--src/conn/conn_cache_pool.c6
-rw-r--r--src/conn/conn_ckpt.c8
-rw-r--r--src/conn/conn_dhandle.c4
-rw-r--r--src/conn/conn_handle.c2
-rw-r--r--src/conn/conn_log.c34
-rw-r--r--src/conn/conn_open.c7
-rw-r--r--src/conn/conn_stat.c10
-rw-r--r--src/conn/conn_sweep.c6
-rw-r--r--src/cursor/cur_backup.c49
-rw-r--r--src/cursor/cur_bulk.c8
-rw-r--r--src/cursor/cur_dump.c15
-rw-r--r--src/cursor/cur_file.c11
-rw-r--r--src/cursor/cur_index.c6
-rw-r--r--src/cursor/cur_json.c85
-rw-r--r--src/cursor/cur_std.c6
-rw-r--r--src/cursor/cur_table.c20
-rw-r--r--src/evict/evict_file.c2
-rw-r--r--src/evict/evict_lru.c11
-rw-r--r--src/evict/evict_page.c4
-rw-r--r--src/include/btree.i22
-rw-r--r--src/include/cursor.h4
-rw-r--r--src/include/cursor.i2
-rw-r--r--src/include/extern.h66
-rw-r--r--src/include/misc.i2
-rw-r--r--src/include/os.h2
-rw-r--r--src/include/packing.i4
-rw-r--r--src/include/schema.h2
-rw-r--r--src/include/serial.i6
-rw-r--r--src/log/log.c81
-rw-r--r--src/log/log_auto.c3
-rw-r--r--src/lsm/lsm_cursor.c100
-rw-r--r--src/lsm/lsm_manager.c10
-rw-r--r--src/lsm/lsm_merge.c27
-rw-r--r--src/lsm/lsm_meta.c6
-rw-r--r--src/lsm/lsm_stat.c8
-rw-r--r--src/lsm/lsm_tree.c89
-rw-r--r--src/lsm/lsm_work_unit.c27
-rw-r--r--src/lsm/lsm_worker.c14
-rw-r--r--src/meta/meta_apply.c4
-rw-r--r--src/meta/meta_track.c10
-rw-r--r--src/os_posix/os_dir.c6
-rw-r--r--src/os_posix/os_dlopen.c2
-rw-r--r--src/os_posix/os_flock.c2
-rw-r--r--src/os_posix/os_mtx_cond.c14
-rw-r--r--src/os_posix/os_open.c15
-rw-r--r--src/os_posix/os_priv.c2
-rw-r--r--src/os_win/os_dir.c6
-rw-r--r--src/os_win/os_dlopen.c2
-rw-r--r--src/os_win/os_flock.c2
-rw-r--r--src/os_win/os_mtx_cond.c14
-rw-r--r--src/os_win/os_open.c15
-rw-r--r--src/os_win/os_priv.c2
-rw-r--r--src/reconcile/rec_write.c120
-rw-r--r--src/schema/schema_create.c38
-rw-r--r--src/schema/schema_drop.c13
-rw-r--r--src/schema/schema_list.c4
-rw-r--r--src/schema/schema_open.c30
-rw-r--r--src/schema/schema_plan.c32
-rw-r--r--src/schema/schema_rename.c6
-rw-r--r--src/schema/schema_stat.c7
-rw-r--r--src/schema/schema_truncate.c3
-rw-r--r--src/schema/schema_worker.c10
-rw-r--r--src/session/session_api.c13
-rw-r--r--src/session/session_dhandle.c8
-rw-r--r--src/support/err.c19
-rw-r--r--src/support/global.c8
-rw-r--r--src/support/hazard.c6
-rw-r--r--src/txn/txn.c4
-rw-r--r--src/txn/txn_ckpt.c65
-rw-r--r--src/txn/txn_log.c11
-rw-r--r--src/txn/txn_nsnap.c367
-rw-r--r--src/txn/txn_recover.c25
-rw-r--r--src/utilities/util.h4
-rw-r--r--src/utilities/util_backup.c4
-rw-r--r--src/utilities/util_dump.c48
-rw-r--r--src/utilities/util_list.c17
-rw-r--r--src/utilities/util_load.c52
-rw-r--r--src/utilities/util_load_json.c31
-rw-r--r--src/utilities/util_loadtext.c19
-rw-r--r--src/utilities/util_main.c12
-rw-r--r--src/utilities/util_misc.c6
-rw-r--r--src/utilities/util_printlog.c7
-rw-r--r--src/utilities/util_read.c11
-rw-r--r--src/utilities/util_stat.c7
-rw-r--r--src/utilities/util_verify.c13
-rw-r--r--src/utilities/util_write.c11
98 files changed, 1202 insertions, 810 deletions
diff --git a/src/async/async_api.c b/src/async/async_api.c
index cd232af5340..6ce4288d04b 100644
--- a/src/async/async_api.c
+++ b/src/async/async_api.c
@@ -52,8 +52,8 @@ __async_get_format(WT_CONNECTION_IMPL *conn, const char *uri,
* Insert it at the head expecting LRU usage. We need a real session
* for the cursor.
*/
- WT_RET(
- __wt_open_internal_session(conn, "async-cursor", 1, 1, &session));
+ WT_RET(__wt_open_internal_session(
+ conn, "async-cursor", true, true, &session));
__wt_spin_lock(session, &async->ops_lock);
WT_ERR(__wt_calloc_one(session, &af));
WT_ERR(__wt_strdup(session, uri, &af->uri));
@@ -171,7 +171,7 @@ retry:
*/
static int
__async_config(WT_SESSION_IMPL *session,
- WT_CONNECTION_IMPL *conn, const char **cfg, int *runp)
+ WT_CONNECTION_IMPL *conn, const char **cfg, bool *runp)
{
WT_CONFIG_ITEM cval;
@@ -240,7 +240,8 @@ __async_start(WT_SESSION_IMPL *session)
async = conn->async;
TAILQ_INIT(&async->formatqh);
WT_RET(__wt_spin_init(session, &async->ops_lock, "ops"));
- WT_RET(__wt_cond_alloc(session, "async flush", 0, &async->flush_cond));
+ WT_RET(__wt_cond_alloc(
+ session, "async flush", false, &async->flush_cond));
WT_RET(__wt_async_op_init(session));
/*
@@ -255,8 +256,8 @@ __async_start(WT_SESSION_IMPL *session)
* workers and we may want to selectively stop some workers
* while leaving the rest running.
*/
- WT_RET(__wt_open_internal_session(
- conn, "async-worker", 1, 1, &async->worker_sessions[i]));
+ WT_RET(__wt_open_internal_session(conn,
+ "async-worker", true, true, &async->worker_sessions[i]));
F_SET(async->worker_sessions[i], WT_SESSION_SERVER_ASYNC);
}
for (i = 0; i < conn->async_workers; i++) {
@@ -278,12 +279,12 @@ int
__wt_async_create(WT_SESSION_IMPL *session, const char *cfg[])
{
WT_CONNECTION_IMPL *conn;
- int run;
+ bool run;
conn = S2C(session);
/* Handle configuration. */
- run = 0;
+ run = false;
WT_RET(__async_config(session, conn, cfg, &run));
/* If async is not configured, we're done. */
@@ -303,7 +304,7 @@ __wt_async_reconfig(WT_SESSION_IMPL *session, const char *cfg[])
WT_CONNECTION_IMPL *conn, tmp_conn;
WT_DECL_RET;
WT_SESSION *wt_session;
- int run;
+ bool run;
uint32_t i;
conn = S2C(session);
@@ -370,8 +371,8 @@ __wt_async_reconfig(WT_SESSION_IMPL *session, const char *cfg[])
/*
* Each worker has its own session.
*/
- WT_RET(__wt_open_internal_session(conn,
- "async-worker", 1, 1, &async->worker_sessions[i]));
+ WT_RET(__wt_open_internal_session(conn, "async-worker",
+ true, true, &async->worker_sessions[i]));
F_SET(async->worker_sessions[i],
WT_SESSION_SERVER_ASYNC);
}
diff --git a/src/block/block_write.c b/src/block/block_write.c
index 3ebd2c22266..135158a6d7c 100644
--- a/src/block/block_write.c
+++ b/src/block/block_write.c
@@ -269,10 +269,10 @@ __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block,
* the block-extend function may release the lock).
* Release any locally acquired lock.
*/
- local_locked = 0;
+ local_locked = false;
if (!caller_locked) {
__wt_spin_lock(session, &block->live_lock);
- local_locked = 1;
+ local_locked = true;
}
ret = __wt_block_alloc(session, block, &offset, (wt_off_t)align_size);
if (ret == 0)
diff --git a/src/btree/bt_curnext.c b/src/btree/bt_curnext.c
index 0e3b7207edf..4720dc685e5 100644
--- a/src/btree/bt_curnext.c
+++ b/src/btree/bt_curnext.c
@@ -414,7 +414,7 @@ __wt_btcur_next(WT_CURSOR_BTREE *cbt, bool truncating)
if (truncating)
LF_SET(WT_READ_TRUNCATE);
- WT_RET(__cursor_func_init(cbt, 0));
+ WT_RET(__cursor_func_init(cbt, false));
/*
* If we aren't already iterating in the right direction, there's
diff --git a/src/btree/bt_curprev.c b/src/btree/bt_curprev.c
index 661dd99558b..f79351c86e8 100644
--- a/src/btree/bt_curprev.c
+++ b/src/btree/bt_curprev.c
@@ -503,7 +503,7 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating)
if (truncating)
LF_SET(WT_READ_TRUNCATE);
- WT_RET(__cursor_func_init(cbt, 0));
+ WT_RET(__cursor_func_init(cbt, false));
/*
* If we aren't already iterating in the right direction, there's
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index 0b5d9e118d4..4ecc6a5e5b9 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -446,7 +446,7 @@ __wt_btcur_insert(WT_CURSOR_BTREE *cbt)
__wt_btree_evictable(session, true);
}
-retry: WT_RET(__cursor_func_init(cbt, 1));
+retry: WT_RET(__cursor_func_init(cbt, true));
switch (btree->type) {
case BTREE_COL_FIX:
@@ -555,7 +555,7 @@ __wt_btcur_update_check(WT_CURSOR_BTREE *cbt)
btree = cbt->btree;
session = (WT_SESSION_IMPL *)cursor->session;
-retry: WT_RET(__cursor_func_init(cbt, 1));
+retry: WT_RET(__cursor_func_init(cbt, true));
switch (btree->type) {
case BTREE_ROW:
@@ -602,7 +602,7 @@ __wt_btcur_remove(WT_CURSOR_BTREE *cbt)
if (btree->type == BTREE_ROW)
WT_RET(__cursor_size_chk(session, &cursor->key));
-retry: WT_RET(__cursor_func_init(cbt, 1));
+retry: WT_RET(__cursor_func_init(cbt, true));
switch (btree->type) {
case BTREE_COL_FIX:
@@ -698,7 +698,7 @@ __wt_btcur_update(WT_CURSOR_BTREE *cbt)
__wt_btree_evictable(session, true);
}
-retry: WT_RET(__cursor_func_init(cbt, 1));
+retry: WT_RET(__cursor_func_init(cbt, true));
switch (btree->type) {
case BTREE_COL_FIX:
@@ -781,7 +781,7 @@ __wt_btcur_next_random(WT_CURSOR_BTREE *cbt)
WT_STAT_FAST_CONN_INCR(session, cursor_next);
WT_STAT_FAST_DATA_INCR(session, cursor_next);
- WT_RET(__cursor_func_init(cbt, 1));
+ WT_RET(__cursor_func_init(cbt, true));
WT_WITH_PAGE_INDEX(session,
ret = __wt_row_random(session, cbt));
diff --git a/src/btree/bt_delete.c b/src/btree/bt_delete.c
index 1e3ab0dc151..1da2923489c 100644
--- a/src/btree/bt_delete.c
+++ b/src/btree/bt_delete.c
@@ -126,7 +126,7 @@ __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp)
* future reconciliation of the child leaf page that will dirty it as
* we write the tree.
*/
- WT_ERR(__wt_page_parent_modify_set(session, ref, 0));
+ WT_ERR(__wt_page_parent_modify_set(session, ref, false));
/*
* Record the change in the transaction structure and set the change's
diff --git a/src/btree/bt_split.c b/src/btree/bt_split.c
index b553a823b2e..7d7e88db918 100644
--- a/src/btree/bt_split.c
+++ b/src/btree/bt_split.c
@@ -1067,7 +1067,7 @@ err: if (!complete)
* list into a separate page.
*/
int
-__wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref, int *splitp)
+__wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref)
{
WT_DECL_RET;
WT_DECL_ITEM(key);
@@ -1078,8 +1078,6 @@ __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref, int *splitp)
size_t page_decr, parent_incr, right_incr;
int i;
- *splitp = 0;
-
page = ref->page;
right = NULL;
page_decr = parent_incr = right_incr = 0;
@@ -1315,9 +1313,6 @@ __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref, int *splitp)
WT_ERR(ret);
}
- /* Let our caller know that we split. */
- *splitp = 1;
-
WT_STAT_FAST_CONN_INCR(session, cache_inmem_split);
WT_STAT_FAST_DATA_INCR(session, cache_inmem_split);
diff --git a/src/config/config.c b/src/config/config.c
index fbb5a528ec7..92f917915e1 100644
--- a/src/config/config.c
+++ b/src/config/config.c
@@ -580,30 +580,30 @@ __wt_config_next(WT_CONFIG *conf, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value)
*/
static int
__config_getraw(
- WT_CONFIG *cparser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value, int top)
+ WT_CONFIG *cparser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value, bool top)
{
WT_CONFIG sparser;
WT_CONFIG_ITEM k, v, subk;
WT_DECL_RET;
- int found;
+ bool found;
- found = 0;
+ found = false;
while ((ret = __config_next(cparser, &k, &v)) == 0) {
if (k.type != WT_CONFIG_ITEM_STRING &&
k.type != WT_CONFIG_ITEM_ID)
continue;
if (k.len == key->len && strncmp(key->str, k.str, k.len) == 0) {
*value = v;
- found = 1;
+ found = true;
} else if (k.len < key->len && key->str[k.len] == '.' &&
strncmp(key->str, k.str, k.len) == 0) {
subk.str = key->str + k.len + 1;
subk.len = (key->len - k.len) - 1;
WT_RET(__wt_config_initn(
cparser->session, &sparser, v.str, v.len));
- if ((ret =
- __config_getraw(&sparser, &subk, value, 0)) == 0)
- found = 1;
+ if ((ret = __config_getraw(
+ &sparser, &subk, value, false)) == 0)
+ found = true;
WT_RET_NOTFOUND_OK(ret);
}
}
@@ -629,7 +629,7 @@ __wt_config_get(WT_SESSION_IMPL *session,
for (found = 0; *cfg != NULL; cfg++) {
WT_RET(__wt_config_init(session, &cparser, *cfg));
- if ((ret = __config_getraw(&cparser, key, value, 1)) == 0)
+ if ((ret = __config_getraw(&cparser, key, value, true)) == 0)
found = 1;
else if (ret != WT_NOTFOUND)
return (ret);
@@ -679,7 +679,7 @@ __wt_config_getone(WT_SESSION_IMPL *session,
WT_CONFIG cparser;
WT_RET(__wt_config_init(session, &cparser, config));
- return (__config_getraw(&cparser, key, value, 1));
+ return (__config_getraw(&cparser, key, value, true));
}
/*
@@ -695,7 +695,7 @@ __wt_config_getones(WT_SESSION_IMPL *session,
{ key, strlen(key), 0, WT_CONFIG_ITEM_STRING };
WT_RET(__wt_config_init(session, &cparser, config));
- return (__config_getraw(&cparser, &key_item, value, 1));
+ return (__config_getraw(&cparser, &key_item, value, true));
}
/*
@@ -755,7 +755,7 @@ __wt_config_subgetraw(WT_SESSION_IMPL *session,
WT_CONFIG cparser;
WT_RET(__wt_config_initn(session, &cparser, cfg->str, cfg->len));
- return (__config_getraw(&cparser, key, value, 1));
+ return (__config_getraw(&cparser, key, value, true));
}
/*
diff --git a/src/config/config_check.c b/src/config/config_check.c
index 391209104c7..20ecc9f5db3 100644
--- a/src/config/config_check.c
+++ b/src/config/config_check.c
@@ -245,7 +245,8 @@ config_check(WT_SESSION_IMPL *session,
WT_CONFIG parser, cparser, sparser;
WT_CONFIG_ITEM k, v, ck, cv, dummy;
WT_DECL_RET;
- int badtype, found, i;
+ int i;
+ bool badtype, found;
/*
* The config_len parameter is optional, and allows passing in strings
@@ -272,27 +273,26 @@ config_check(WT_SESSION_IMPL *session,
(int)k.len, k.str);
if (strcmp(checks[i].type, "boolean") == 0) {
- badtype = (v.type != WT_CONFIG_ITEM_BOOL &&
+ badtype = v.type != WT_CONFIG_ITEM_BOOL &&
(v.type != WT_CONFIG_ITEM_NUM ||
- (v.val != 0 && v.val != 1)));
+ (v.val != 0 && v.val != 1));
} else if (strcmp(checks[i].type, "category") == 0) {
/* Deal with categories of the form: XXX=(XXX=blah). */
ret = config_check(session,
checks[i].subconfigs,
k.str + strlen(checks[i].name) + 1, v.len);
if (ret != EINVAL)
- badtype = 0;
+ badtype = false;
else
- badtype = 1;
+ badtype = true;
} else if (strcmp(checks[i].type, "format") == 0) {
- badtype = 0;
+ badtype = false;
} else if (strcmp(checks[i].type, "int") == 0) {
- badtype = (v.type != WT_CONFIG_ITEM_NUM);
+ badtype = v.type != WT_CONFIG_ITEM_NUM;
} else if (strcmp(checks[i].type, "list") == 0) {
- badtype = (v.len > 0 &&
- v.type != WT_CONFIG_ITEM_STRUCT);
+ badtype = v.len > 0 && v.type != WT_CONFIG_ITEM_STRUCT;
} else if (strcmp(checks[i].type, "string") == 0) {
- badtype = 0;
+ badtype = false;
} else
WT_RET_MSG(session, EINVAL,
"unknown configuration type: '%s'",
@@ -338,18 +338,18 @@ config_check(WT_SESSION_IMPL *session,
*/
WT_RET(__wt_config_subinit(session,
&sparser, &v));
- found = 1;
+ found = true;
while (found &&
(ret = __wt_config_next(&sparser,
&v, &dummy)) == 0) {
ret = __wt_config_subgetraw(
session, &cv, &v, &dummy);
- found = (ret == 0);
+ found = ret == 0;
}
} else {
ret = __wt_config_subgetraw(session,
&cv, &v, &dummy);
- found = (ret == 0);
+ found = ret == 0;
}
if (ret != 0 && ret != WT_NOTFOUND)
diff --git a/src/config/config_collapse.c b/src/config/config_collapse.c
index 23cb03c9b3a..448bf69152b 100644
--- a/src/config/config_collapse.c
+++ b/src/config/config_collapse.c
@@ -90,7 +90,7 @@ err: __wt_scr_free(session, &tmp);
* the qsort stable.
*/
typedef struct {
- char *k, *v; /* key, value */
+ char *k, *v; /* key, value */
size_t gen; /* generation */
} WT_CONFIG_MERGE_ENTRY;
diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c
index 7188ff8b0b4..1b7b709ed4d 100644
--- a/src/conn/conn_api.c
+++ b/src/conn/conn_api.c
@@ -679,11 +679,12 @@ __conn_load_extension(
*/
WT_ERR(__wt_config_gets(session, cfg, "entry", &cval));
WT_ERR(__wt_strndup(session, cval.str, cval.len, &init_name));
- WT_ERR(__wt_dlsym(session, dlh, init_name, 1, &load));
+ WT_ERR(__wt_dlsym(session, dlh, init_name, true, &load));
WT_ERR(__wt_config_gets(session, cfg, "terminate", &cval));
WT_ERR(__wt_strndup(session, cval.str, cval.len, &terminate_name));
- WT_ERR(__wt_dlsym(session, dlh, terminate_name, 0, &dlh->terminate));
+ WT_ERR(
+ __wt_dlsym(session, dlh, terminate_name, false, &dlh->terminate));
/* Call the load function last, it simplifies error handling. */
WT_ERR(load(wt_conn, (WT_CONFIG_ARG *)cfg));
@@ -914,7 +915,6 @@ __conn_open_session(WT_CONNECTION *wt_conn,
WT_UNUSED(cfg);
WT_ERR(__wt_open_session(conn, event_handler, config, &session_ret));
-
*wt_sessionp = &session_ret->iface;
err: API_END_RET_NOTFOUND_MAP(session, ret);
@@ -1265,7 +1265,7 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[])
* is holding it, we're done. The file may be zero-length, and that's
* OK, the underlying call supports locking past the end-of-file.
*/
- if (__wt_bytelock(conn->lock_fh, (wt_off_t)0, 1) != 0)
+ if (__wt_bytelock(conn->lock_fh, (wt_off_t)0, true) != 0)
WT_ERR_MSG(session, EBUSY,
"WiredTiger database is already being managed by another "
"process");
@@ -1292,12 +1292,12 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[])
* Lock the WiredTiger file (for backward compatibility reasons as
* described above). Immediately release the lock, it's just a test.
*/
- if (__wt_bytelock(fh, (wt_off_t)0, 1) != 0) {
+ if (__wt_bytelock(fh, (wt_off_t)0, true) != 0) {
WT_ERR_MSG(session, EBUSY,
"WiredTiger database is already being managed by another "
"process");
}
- WT_ERR(__wt_bytelock(fh, (wt_off_t)0, 0));
+ WT_ERR(__wt_bytelock(fh, (wt_off_t)0, false));
/*
* If the size of the file is zero, we created it, fill it in. If the
diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c
index a3d01b40414..3abfc0dfa85 100644
--- a/src/conn/conn_cache.c
+++ b/src/conn/conn_cache.c
@@ -145,9 +145,9 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[])
"eviction target must be lower than the eviction trigger");
WT_ERR(__wt_cond_alloc(session,
- "cache eviction server", 0, &cache->evict_cond));
+ "cache eviction server", false, &cache->evict_cond));
WT_ERR(__wt_cond_alloc(session,
- "eviction waiters", 0, &cache->evict_waiter_cond));
+ "eviction waiters", false, &cache->evict_waiter_cond));
WT_ERR(__wt_spin_init(session, &cache->evict_lock, "cache eviction"));
WT_ERR(__wt_spin_init(session, &cache->evict_walk_lock, "cache walk"));
diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c
index c0656004df2..8febdff1fbc 100644
--- a/src/conn/conn_cache_pool.c
+++ b/src/conn/conn_cache_pool.c
@@ -92,7 +92,7 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg)
WT_ERR(__wt_spin_init(
session, &cp->cache_pool_lock, "cache shared pool"));
WT_ERR(__wt_cond_alloc(session,
- "cache pool server", 0, &cp->cache_pool_cond));
+ "cache pool server", false, &cp->cache_pool_cond));
__wt_process.cache_pool = cp;
WT_ERR(__wt_verbose(session,
@@ -229,7 +229,7 @@ __wt_conn_cache_pool_open(WT_SESSION_IMPL *session)
* it in the main thread to avoid shutdown races
*/
if ((ret = __wt_open_internal_session(
- conn, "cache-pool", 0, 0, &cache->cp_session)) != 0)
+ conn, "cache-pool", false, false, &cache->cp_session)) != 0)
WT_RET_MSG(NULL, ret,
"Failed to create session for cache pool");
@@ -397,7 +397,7 @@ __cache_pool_balance(WT_SESSION_IMPL *session)
bool adjusted;
cp = __wt_process.cache_pool;
- adjusted = 0;
+ adjusted = false;
highest = 0;
__wt_spin_lock(NULL, &cp->cache_pool_lock);
diff --git a/src/conn/conn_ckpt.c b/src/conn/conn_ckpt.c
index a2e985ee1ea..6598c567de9 100644
--- a/src/conn/conn_ckpt.c
+++ b/src/conn/conn_ckpt.c
@@ -131,7 +131,7 @@ __ckpt_server_start(WT_CONNECTION_IMPL *conn)
F_SET(conn, WT_CONN_SERVER_CHECKPOINT);
/* The checkpoint server gets its own session. */
WT_RET(__wt_open_internal_session(
- conn, "checkpoint-server", 1, 1, &conn->ckpt_session));
+ conn, "checkpoint-server", true, true, &conn->ckpt_session));
session = conn->ckpt_session;
/*
@@ -140,8 +140,8 @@ __ckpt_server_start(WT_CONNECTION_IMPL *conn)
*/
F_SET(session, WT_SESSION_CAN_WAIT);
- WT_RET(
- __wt_cond_alloc(session, "checkpoint server", 0, &conn->ckpt_cond));
+ WT_RET(__wt_cond_alloc(
+ session, "checkpoint server", false, &conn->ckpt_cond));
/*
* Start the thread.
@@ -164,7 +164,7 @@ __wt_checkpoint_server_create(WT_SESSION_IMPL *session, const char *cfg[])
bool start;
conn = S2C(session);
- start = 0;
+ start = false;
/* If there is already a server running, shut it down. */
if (conn->ckpt_session != NULL)
diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c
index 048a0d6bd92..fed0012b211 100644
--- a/src/conn/conn_dhandle.c
+++ b/src/conn/conn_dhandle.c
@@ -536,7 +536,7 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle,
WT_SAVE_DHANDLE(session,
ret = func(session, cfg));
if (WT_META_TRACKING(session))
- WT_TRET(__wt_meta_track_handle_lock(session, 0));
+ WT_TRET(__wt_meta_track_handle_lock(session, false));
else
WT_TRET(__wt_session_release_btree(session));
} else if (ret == EBUSY)
@@ -715,7 +715,7 @@ __wt_conn_dhandle_close_all(
dhandle->name, dhandle->checkpoint,
NULL, WT_DHANDLE_EXCLUSIVE | WT_DHANDLE_LOCK_ONLY));
if (WT_META_TRACKING(session))
- WT_ERR(__wt_meta_track_handle_lock(session, 0));
+ WT_ERR(__wt_meta_track_handle_lock(session, false));
/*
* We have an exclusive lock, which means there are no cursors
diff --git a/src/conn/conn_handle.c b/src/conn/conn_handle.c
index a9b52e8a6fe..8ef8fa5c7db 100644
--- a/src/conn/conn_handle.c
+++ b/src/conn/conn_handle.c
@@ -68,7 +68,7 @@ __wt_connection_init(WT_CONNECTION_IMPL *conn)
WT_RET(__wt_spin_init(
session, &conn->lsm_manager.switch_lock, "LSM switch queue lock"));
WT_RET(__wt_cond_alloc(
- session, "LSM worker cond", 0, &conn->lsm_manager.work_cond));
+ session, "LSM worker cond", false, &conn->lsm_manager.work_cond));
/*
* Generation numbers.
diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c
index 817e7197d11..427b6a956b7 100644
--- a/src/conn/conn_log.c
+++ b/src/conn/conn_log.c
@@ -107,7 +107,8 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
WT_DECL_RET;
WT_LOG *log;
uint32_t lognum, min_lognum;
- u_int i, locked, logcount;
+ u_int i, logcount;
+ bool locked;
char **logfiles;
conn = S2C(session);
@@ -140,7 +141,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
* if we are the backup.
*/
__wt_spin_lock(session, &conn->hot_backup_lock);
- locked = 1;
+ locked = true;
if (conn->hot_backup == 0 || backup_file != 0) {
for (i = 0; i < logcount; i++) {
WT_ERR(__wt_log_extract_lognum(
@@ -151,7 +152,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file)
}
}
__wt_spin_unlock(session, &conn->hot_backup_lock);
- locked = 0;
+ locked = false;
__wt_log_files_free(session, logfiles, logcount);
logfiles = NULL;
logcount = 0;
@@ -217,7 +218,7 @@ __log_prealloc_once(WT_SESSION_IMPL *session)
*/
for (i = reccount; i < (u_int)conn->log_prealloc; i++) {
WT_ERR(__wt_log_allocfile(
- session, ++log->prep_fileid, WT_LOG_PREPNAME, 1));
+ session, ++log->prep_fileid, WT_LOG_PREPNAME, true));
WT_STAT_FAST_CONN_INCR(session, log_prealloc_files);
}
@@ -240,7 +241,8 @@ __wt_log_truncate_files(
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_LOG *log;
- uint32_t backup_file, locked;
+ uint32_t backup_file;
+ bool locked;
WT_UNUSED(cfg);
conn = S2C(session);
@@ -258,10 +260,10 @@ __wt_log_truncate_files(
"log_truncate_files: Archive once up to %" PRIu32,
backup_file));
WT_RET(__wt_writelock(session, log->log_archive_lock));
- locked = 1;
+ locked = true;
WT_ERR(__log_archive_once(session, backup_file));
WT_ERR(__wt_writeunlock(session, log->log_archive_lock));
- locked = 0;
+ locked = false;
err:
if (locked)
WT_RET(__wt_writeunlock(session, log->log_archive_lock));
@@ -567,8 +569,10 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[])
WT_INIT_LSN(&log->write_lsn);
WT_INIT_LSN(&log->write_start_lsn);
log->fileid = 0;
- WT_RET(__wt_cond_alloc(session, "log sync", 0, &log->log_sync_cond));
- WT_RET(__wt_cond_alloc(session, "log write", 0, &log->log_write_cond));
+ WT_RET(__wt_cond_alloc(
+ session, "log sync", false, &log->log_sync_cond));
+ WT_RET(__wt_cond_alloc(
+ session, "log write", false, &log->log_write_cond));
WT_RET(__wt_log_open(session));
WT_RET(__wt_log_slot_init(session));
@@ -595,9 +599,9 @@ __wt_logmgr_open(WT_SESSION_IMPL *session)
* If logging is enabled, this thread runs.
*/
WT_RET(__wt_open_internal_session(
- conn, "log-close-server", 0, 0, &conn->log_file_session));
+ conn, "log-close-server", false, false, &conn->log_file_session));
WT_RET(__wt_cond_alloc(conn->log_file_session,
- "log close server", 0, &conn->log_file_cond));
+ "log close server", false, &conn->log_file_cond));
/*
* Start the log file close thread.
@@ -611,9 +615,9 @@ __wt_logmgr_open(WT_SESSION_IMPL *session)
* If logging is enabled, this thread runs.
*/
WT_RET(__wt_open_internal_session(
- conn, "log-wrlsn-server", 0, 0, &conn->log_wrlsn_session));
+ conn, "log-wrlsn-server", false, false, &conn->log_wrlsn_session));
WT_RET(__wt_cond_alloc(conn->log_wrlsn_session,
- "log write lsn server", 0, &conn->log_wrlsn_cond));
+ "log write lsn server", false, &conn->log_wrlsn_cond));
WT_RET(__wt_thread_create(conn->log_wrlsn_session,
&conn->log_wrlsn_tid, __log_wrlsn_server, conn->log_wrlsn_session));
conn->log_wrlsn_tid_set = 1;
@@ -636,9 +640,9 @@ __wt_logmgr_open(WT_SESSION_IMPL *session)
} else {
/* The log server gets its own session. */
WT_RET(__wt_open_internal_session(
- conn, "log-server", 0, 0, &conn->log_session));
+ conn, "log-server", false, false, &conn->log_session));
WT_RET(__wt_cond_alloc(conn->log_session,
- "log server", 0, &conn->log_cond));
+ "log server", false, &conn->log_cond));
/*
* Start the thread.
diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c
index 1f34da7e7c5..c86a6e039eb 100644
--- a/src/conn/conn_open.c
+++ b/src/conn/conn_open.c
@@ -36,7 +36,8 @@ __wt_connection_open(WT_CONNECTION_IMPL *conn, const char *cfg[])
* threads because those may allocate and use session resources that
* need to get cleaned up on close.
*/
- WT_RET(__wt_open_internal_session(conn, "connection", 1, 0, &session));
+ WT_RET(__wt_open_internal_session(
+ conn, "connection", true, false, &session));
/*
* The connection's default session is originally a static structure,
@@ -92,7 +93,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
* transaction ID will catch up with the current ID.
*/
for (;;) {
- __wt_txn_update_oldest(session, 1);
+ __wt_txn_update_oldest(session, true);
if (txn_global->oldest_id == txn_global->current)
break;
__wt_yield();
@@ -130,7 +131,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn)
*/
if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
WT_TRET(__wt_txn_checkpoint_log(
- session, 1, WT_TXN_LOG_CKPT_STOP, NULL));
+ session, true, WT_TXN_LOG_CKPT_STOP, NULL));
F_CLR(conn, WT_CONN_LOG_SERVER_RUN);
WT_TRET(__wt_logmgr_destroy(session));
diff --git a/src/conn/conn_stat.c b/src/conn/conn_stat.c
index 9668b906686..707047a1542 100644
--- a/src/conn/conn_stat.c
+++ b/src/conn/conn_stat.c
@@ -254,8 +254,8 @@ __statlog_lsm_apply(WT_SESSION_IMPL *session)
break;
for (p = S2C(session)->stat_sources; *p != NULL; ++p)
if (WT_PREFIX_MATCH(lsm_tree->name, *p)) {
- WT_ERR(__wt_lsm_tree_get(
- session, lsm_tree->name, 0, &list[cnt++]));
+ WT_ERR(__wt_lsm_tree_get(session,
+ lsm_tree->name, false, &list[cnt++]));
break;
}
}
@@ -443,11 +443,11 @@ __statlog_start(WT_CONNECTION_IMPL *conn)
F_SET(conn, WT_CONN_SERVER_STATISTICS);
/* The statistics log server gets its own session. */
WT_RET(__wt_open_internal_session(
- conn, "statlog-server", 1, 1, &conn->stat_session));
+ conn, "statlog-server", true, true, &conn->stat_session));
session = conn->stat_session;
WT_RET(__wt_cond_alloc(
- session, "statistics log server", 0, &conn->stat_cond));
+ session, "statistics log server", false, &conn->stat_cond));
/*
* Start the thread.
@@ -477,7 +477,7 @@ __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[])
bool start;
conn = S2C(session);
- start = 0;
+ start = false;
/*
* Stop any server that is already running. This means that each time
diff --git a/src/conn/conn_sweep.c b/src/conn/conn_sweep.c
index c220d1cf604..8854f5e0592 100644
--- a/src/conn/conn_sweep.c
+++ b/src/conn/conn_sweep.c
@@ -68,7 +68,7 @@ __sweep_expire_one(WT_SESSION_IMPL *session)
btree = S2BT(session);
dhandle = session->dhandle;
- evict_reset = 0;
+ evict_reset = false;
/*
* Acquire an exclusive lock on the handle and mark it dead.
@@ -354,7 +354,7 @@ __wt_sweep_create(WT_SESSION_IMPL *session)
F_SET(conn, WT_CONN_SERVER_SWEEP);
WT_RET(__wt_open_internal_session(
- conn, "sweep-server", 1, 1, &conn->sweep_session));
+ conn, "sweep-server", true, true, &conn->sweep_session));
session = conn->sweep_session;
/*
@@ -364,7 +364,7 @@ __wt_sweep_create(WT_SESSION_IMPL *session)
F_SET(session, WT_SESSION_CAN_WAIT);
WT_RET(__wt_cond_alloc(
- session, "handle sweep server", 0, &conn->sweep_cond));
+ session, "handle sweep server", false, &conn->sweep_cond));
WT_RET(__wt_thread_create(
session, &conn->sweep_tid, __sweep_server, session));
diff --git a/src/cursor/cur_backup.c b/src/cursor/cur_backup.c
index d34e3ea10a1..6882175362a 100644
--- a/src/cursor/cur_backup.c
+++ b/src/cursor/cur_backup.c
@@ -10,7 +10,7 @@
static int __backup_all(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *);
static int __backup_cleanup_handles(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *);
-static int __backup_file_create(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, int);
+static int __backup_file_create(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, bool);
static int __backup_list_all_append(WT_SESSION_IMPL *, const char *[]);
static int __backup_list_append(
WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *);
@@ -18,7 +18,7 @@ static int __backup_start(
WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[]);
static int __backup_stop(WT_SESSION_IMPL *);
static int __backup_uri(
- WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[], int *, int *);
+ WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[], bool *, bool *);
/*
* __curbackup_next --
@@ -158,7 +158,7 @@ err: __wt_free(session, cb);
* Append log files needed for backup.
*/
static int
-__backup_log_append(WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, int active)
+__backup_log_append(WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, bool active)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
@@ -191,8 +191,7 @@ __backup_start(
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
- bool exist;
- int log_only, target_list;
+ bool exist, log_only, target_list;
conn = S2C(session);
@@ -223,7 +222,7 @@ __backup_start(
__wt_spin_unlock(session, &conn->hot_backup_lock);
/* Create the hot backup file. */
- WT_ERR(__backup_file_create(session, cb, 0));
+ WT_ERR(__backup_file_create(session, cb, false));
/* Add log files if logging is enabled. */
@@ -235,11 +234,11 @@ __backup_start(
* copying data files to avoid rolling the metadata forward across
* a checkpoint that completes during the backup.
*/
- target_list = 0;
+ target_list = false;
WT_ERR(__backup_uri(session, cb, cfg, &target_list, &log_only));
if (!target_list) {
- WT_ERR(__backup_log_append(session, cb, 1));
+ WT_ERR(__backup_log_append(session, cb, true));
WT_ERR(__backup_all(session, cb));
}
@@ -392,17 +391,16 @@ err: if (cursor != NULL)
*/
static int
__backup_uri(WT_SESSION_IMPL *session,
- WT_CURSOR_BACKUP *cb, const char *cfg[], int *foundp, int *log_only)
+ WT_CURSOR_BACKUP *cb, const char *cfg[], bool *foundp, bool *log_only)
{
WT_CONFIG targetconf;
WT_CONFIG_ITEM cval, k, v;
WT_DECL_ITEM(tmp);
WT_DECL_RET;
- int target_list;
+ bool target_list;
const char *uri;
- *foundp = 0;
- *log_only = 0;
+ *foundp = *log_only = false;
/*
* If we find a non-empty target configuration string, we have a job,
@@ -410,11 +408,12 @@ __backup_uri(WT_SESSION_IMPL *session,
*/
WT_RET(__wt_config_gets(session, cfg, "target", &cval));
WT_RET(__wt_config_subinit(session, &targetconf, &cval));
- for (cb->list_next = 0, target_list = 0;
- (ret = __wt_config_next(&targetconf, &k, &v)) == 0; ++target_list) {
+ for (cb->list_next = 0, target_list = false;
+ (ret = __wt_config_next(&targetconf, &k, &v)) == 0;
+ target_list = true) {
/* If it is our first time through, allocate. */
- if (target_list == 0) {
- *foundp = 1;
+ if (!target_list) {
+ *foundp = true;
WT_ERR(__wt_scr_alloc(session, 512, &tmp));
}
@@ -431,12 +430,8 @@ __backup_uri(WT_SESSION_IMPL *session,
* Set log_only only if it is our only URI target.
*/
if (WT_PREFIX_MATCH(uri, "log:")) {
- if (target_list == 0)
- *log_only = 1;
- else
- *log_only = 0;
- WT_ERR(__wt_backup_list_uri_append(
- session, uri, NULL));
+ *log_only = !target_list;
+ WT_ERR(__wt_backup_list_uri_append(session, uri, NULL));
} else
WT_ERR(__wt_schema_worker(session,
uri, NULL, __wt_backup_list_uri_append, cfg, 0));
@@ -453,7 +448,7 @@ err: __wt_scr_free(session, &tmp);
*/
static int
__backup_file_create(
- WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, int incremental)
+ WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, bool incremental)
{
return (__wt_fopen(session,
incremental ? WT_INCREMENTAL_BACKUP : WT_METADATA_BACKUP,
@@ -490,7 +485,7 @@ __wt_backup_list_uri_append(
WT_UNUSED(skip);
if (WT_PREFIX_MATCH(name, "log:")) {
- WT_RET(__backup_log_append(session, cb, 0));
+ WT_RET(__backup_log_append(session, cb, false));
return (0);
}
@@ -539,8 +534,8 @@ __backup_list_append(
WT_CURSOR_BACKUP_ENTRY *p;
WT_DATA_HANDLE *old_dhandle;
WT_DECL_RET;
+ bool need_handle;
const char *name;
- int need_handle;
/* Leave a NULL at the end to mark the end of the list. */
WT_RET(__wt_realloc_def(session, &cb->list_allocated,
@@ -549,10 +544,10 @@ __backup_list_append(
p[0].name = p[1].name = NULL;
p[0].handle = p[1].handle = NULL;
- need_handle = 0;
+ need_handle = false;
name = uri;
if (WT_PREFIX_MATCH(uri, "file:")) {
- need_handle = 1;
+ need_handle = true;
name += strlen("file:");
}
diff --git a/src/cursor/cur_bulk.c b/src/cursor/cur_bulk.c
index df0616eb316..b996b934464 100644
--- a/src/cursor/cur_bulk.c
+++ b/src/cursor/cur_bulk.c
@@ -50,7 +50,7 @@ __curbulk_insert_var(WT_CURSOR *cursor)
WT_CURSOR_BULK *cbulk;
WT_DECL_RET;
WT_SESSION_IMPL *session;
- int duplicate;
+ bool duplicate;
cbulk = (WT_CURSOR_BULK *)cursor;
btree = cbulk->cbt.btree;
@@ -71,13 +71,13 @@ __curbulk_insert_var(WT_CURSOR *cursor)
* Instead of a "first time" variable, I'm using the RLE count, because
* it is only zero before the first row is inserted.
*/
- duplicate = 0;
+ duplicate = false;
if (cbulk->rle != 0) {
if (cbulk->last.size == cursor->value.size &&
memcmp(cbulk->last.data, cursor->value.data,
cursor->value.size) == 0) {
++cbulk->rle;
- duplicate = 1;
+ duplicate = true;
} else
WT_ERR(__wt_bulk_insert_var(session, cbulk));
}
@@ -225,7 +225,7 @@ err: API_END_RET(session, ret);
*/
int
__wt_curbulk_init(WT_SESSION_IMPL *session,
- WT_CURSOR_BULK *cbulk, int bitmap, bool skip_sort_check)
+ WT_CURSOR_BULK *cbulk, bool bitmap, bool skip_sort_check)
{
WT_CURSOR *c;
WT_CURSOR_BTREE *cbt;
diff --git a/src/cursor/cur_dump.c b/src/cursor/cur_dump.c
index 9323fa9483a..1600553c36b 100644
--- a/src/cursor/cur_dump.c
+++ b/src/cursor/cur_dump.c
@@ -33,7 +33,7 @@ __raw_to_dump(
*/
static int
__dump_to_raw(
- WT_SESSION_IMPL *session, const char *src_arg, WT_ITEM *item, int hexonly)
+ WT_SESSION_IMPL *session, const char *src_arg, WT_ITEM *item, bool hexonly)
{
if (hexonly)
WT_RET(__wt_hex_to_raw(session, src_arg, item));
@@ -85,8 +85,8 @@ __curdump_get_key(WT_CURSOR *cursor, ...)
else
fmt = cursor->key_format;
}
- ret = __wt_json_alloc_unpack(session, buffer, size, fmt,
- json, 1, ap);
+ ret = __wt_json_alloc_unpack(
+ session, buffer, size, fmt, json, true, ap);
} else {
if (WT_CURSOR_RECNO(cursor) &&
!F_ISSET(cursor, WT_CURSTD_RAW)) {
@@ -175,7 +175,7 @@ __curdump_set_key(WT_CURSOR *cursor, ...)
} else {
if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON))
WT_ERR(__wt_json_to_item(session, p, cursor->key_format,
- (WT_CURSOR_JSON *)cursor->json_private, 1,
+ (WT_CURSOR_JSON *)cursor->json_private, true,
&cursor->key));
else
WT_ERR(__dump_to_raw(session, p, &cursor->key,
@@ -219,8 +219,8 @@ __curdump_get_value(WT_CURSOR *cursor, ...)
WT_ERR(__wt_cursor_get_raw_value(child, &item));
fmt = F_ISSET(cursor, WT_CURSTD_RAW) ?
"u" : cursor->value_format;
- ret = __wt_json_alloc_unpack(session, item.data,
- item.size, fmt, json, 0, ap);
+ ret = __wt_json_alloc_unpack(
+ session, item.data, item.size, fmt, json, false, ap);
} else {
WT_ERR(child->get_value(child, &item));
@@ -266,7 +266,8 @@ __curdump_set_value(WT_CURSOR *cursor, ...)
if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON))
WT_ERR(__wt_json_to_item(session, p, cursor->value_format,
- (WT_CURSOR_JSON *)cursor->json_private, 0, &cursor->value));
+ (WT_CURSOR_JSON *)cursor->json_private, false,
+ &cursor->value));
else
WT_ERR(__dump_to_raw(session, p, &cursor->value,
F_ISSET(cursor, WT_CURSTD_DUMP_HEX)));
diff --git a/src/cursor/cur_file.c b/src/cursor/cur_file.c
index cf6c988464a..d78bda1a159 100644
--- a/src/cursor/cur_file.c
+++ b/src/cursor/cur_file.c
@@ -388,7 +388,7 @@ err: API_END_RET(session, ret);
*/
int
__wt_curfile_create(WT_SESSION_IMPL *session,
- WT_CURSOR *owner, const char *cfg[], int bulk, int bitmap,
+ WT_CURSOR *owner, const char *cfg[], bool bulk, bool bitmap,
WT_CURSOR **cursorp)
{
WT_CURSOR_STATIC_INIT(iface,
@@ -481,19 +481,20 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri,
{
WT_CONFIG_ITEM cval;
WT_DECL_RET;
- int bitmap, bulk;
uint32_t flags;
+ bool bitmap, bulk;
+ bitmap = bulk = false;
flags = 0;
WT_RET(__wt_config_gets_def(session, cfg, "bulk", 0, &cval));
if (cval.type == WT_CONFIG_ITEM_BOOL ||
(cval.type == WT_CONFIG_ITEM_NUM &&
(cval.val == 0 || cval.val == 1))) {
- bitmap = 0;
- bulk = (cval.val != 0);
+ bitmap = false;
+ bulk = cval.val != 0;
} else if (WT_STRING_MATCH("bitmap", cval.str, cval.len))
- bitmap = bulk = 1;
+ bitmap = bulk = true;
else
WT_RET_MSG(session, EINVAL,
"Value for 'bulk' must be a boolean or 'bitmap'");
diff --git a/src/cursor/cur_index.c b/src/cursor/cur_index.c
index 7b234eab280..83a9064c1e5 100644
--- a/src/cursor/cur_index.c
+++ b/src/cursor/cur_index.c
@@ -414,7 +414,7 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
++idxname;
if ((ret = __wt_schema_get_table(session,
- tablename, namesize, 0, &table)) != 0) {
+ tablename, namesize, false, &table)) != 0) {
if (ret == WT_NOTFOUND)
WT_RET_MSG(session, EINVAL,
"Cannot open cursor '%s' on unknown table", uri);
@@ -459,13 +459,13 @@ __wt_curindex_open(WT_SESSION_IMPL *session,
if (columns != NULL) {
WT_ERR(__wt_scr_alloc(session, 0, &tmp));
WT_ERR(__wt_struct_reformat(session, table,
- columns, strlen(columns), NULL, 0, tmp));
+ columns, strlen(columns), NULL, false, tmp));
WT_ERR(__wt_strndup(
session, tmp->data, tmp->size, &cursor->value_format));
WT_ERR(__wt_buf_init(session, tmp, 0));
WT_ERR(__wt_struct_plan(session, table,
- columns, strlen(columns), 0, tmp));
+ columns, strlen(columns), false, tmp));
WT_ERR(__wt_strndup(
session, tmp->data, tmp->size, &cindex->value_plan));
}
diff --git a/src/cursor/cur_json.c b/src/cursor/cur_json.c
index 67daf377f88..d61b9618991 100644
--- a/src/cursor/cur_json.c
+++ b/src/cursor/cur_json.c
@@ -11,16 +11,16 @@
static size_t __json_unpack_put(WT_SESSION_IMPL *, void *, u_char *, size_t,
WT_CONFIG_ITEM *);
static inline int __json_struct_size(WT_SESSION_IMPL *, const void *, size_t,
- const char *, WT_CONFIG_ITEM *, int, size_t *);
+ const char *, WT_CONFIG_ITEM *, bool, size_t *);
static inline int __json_struct_unpackv(WT_SESSION_IMPL *, const void *, size_t,
- const char *, WT_CONFIG_ITEM *, u_char *, size_t, int, va_list);
+ const char *, WT_CONFIG_ITEM *, u_char *, size_t, bool, va_list);
static int json_string_arg(WT_SESSION_IMPL *, const char **, WT_ITEM *);
static int json_int_arg(WT_SESSION_IMPL *, const char **, int64_t *);
static int json_uint_arg(WT_SESSION_IMPL *, const char **, uint64_t *);
static int __json_pack_struct(WT_SESSION_IMPL *, void *, size_t, const char *,
const char *);
static int __json_pack_size(WT_SESSION_IMPL *, const char *, WT_CONFIG_ITEM *,
- int, const char *, size_t *);
+ bool, const char *, size_t *);
#define WT_PACK_JSON_GET(session, pv, jstr) do { \
switch (pv.type) { \
@@ -90,7 +90,8 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv,
if (pv->type == 's' || pv->havesize) {
end = p + pv->size;
for (; p < end; p++) {
- n = __wt_json_unpack_char(*p, buf, bufsz, 0);
+ n = __wt_json_unpack_char(
+ *p, buf, bufsz, false);
if (n > bufsz)
bufsz = 0;
else {
@@ -101,7 +102,8 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv,
}
} else
for (; *p; p++) {
- n = __wt_json_unpack_char(*p, buf, bufsz, 0);
+ n = __wt_json_unpack_char(
+ *p, buf, bufsz, false);
if (n > bufsz)
bufsz = 0;
else {
@@ -123,7 +125,7 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv,
bufsz--;
}
for (; p < end; p++) {
- n = __wt_json_unpack_char(*p, buf, bufsz, 1);
+ n = __wt_json_unpack_char(*p, buf, bufsz, true);
if (n > bufsz)
bufsz = 0;
else {
@@ -163,7 +165,7 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv,
*/
static inline int
__json_struct_size(WT_SESSION_IMPL *session, const void *buffer,
- size_t size, const char *fmt, WT_CONFIG_ITEM *names, int iskey,
+ size_t size, const char *fmt, WT_CONFIG_ITEM *names, bool iskey,
size_t *presult)
{
WT_CONFIG_ITEM name;
@@ -171,21 +173,21 @@ __json_struct_size(WT_SESSION_IMPL *session, const void *buffer,
WT_DECL_RET;
WT_PACK pack;
WT_PACK_NAME packname;
- const uint8_t *p, *end;
size_t result;
- int needcr;
+ bool needcr;
+ const uint8_t *p, *end;
p = buffer;
end = p + size;
result = 0;
- needcr = 0;
+ needcr = false;
WT_RET(__pack_name_init(session, names, iskey, &packname));
WT_RET(__pack_init(session, &pack, fmt));
while ((ret = __pack_next(&pack, &pv)) == 0) {
if (needcr)
result += 2;
- needcr = 1;
+ needcr = true;
WT_RET(__unpack_read(session, &pv, &p, (size_t)(end - p)));
WT_RET(__pack_name_next(&packname, &name));
result += __json_unpack_put(session, &pv, NULL, 0, &name);
@@ -207,20 +209,20 @@ __json_struct_size(WT_SESSION_IMPL *session, const void *buffer,
static inline int
__json_struct_unpackv(WT_SESSION_IMPL *session,
const void *buffer, size_t size, const char *fmt, WT_CONFIG_ITEM *names,
- u_char *jbuf, size_t jbufsize, int iskey, va_list ap)
+ u_char *jbuf, size_t jbufsize, bool iskey, va_list ap)
{
WT_CONFIG_ITEM name;
WT_DECL_PACK_VALUE(pv);
WT_DECL_RET;
WT_PACK pack;
WT_PACK_NAME packname;
- int needcr;
size_t jsize;
+ bool needcr;
const uint8_t *p, *end;
p = buffer;
end = p + size;
- needcr = 0;
+ needcr = false;
/* Unpacking a cursor marked as json implies a single arg. */
*va_arg(ap, const char **) = (char *)jbuf;
@@ -234,7 +236,7 @@ __json_struct_unpackv(WT_SESSION_IMPL *session,
jbuf += 2;
jbufsize -= 2;
}
- needcr = 1;
+ needcr = true;
WT_RET(__unpack_read(session, &pv, &p, (size_t)(end - p)));
WT_RET(__pack_name_next(&packname, &name));
jsize = __json_unpack_put(session,
@@ -261,7 +263,7 @@ __json_struct_unpackv(WT_SESSION_IMPL *session,
int
__wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer,
size_t size, const char *fmt, WT_CURSOR_JSON *json,
- int iskey, va_list ap)
+ bool iskey, va_list ap)
{
WT_CONFIG_ITEM *names;
WT_DECL_RET;
@@ -308,7 +310,7 @@ __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor)
* Can be called with null buf for sizing.
*/
size_t
-__wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, int force_unicode)
+__wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, bool force_unicode)
{
char abbrev;
u_char h;
@@ -456,9 +458,10 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype,
const char **tokstart, size_t *toklen)
{
WT_SESSION_IMPL *session;
- char ch;
+ int result;
+ bool backslash, isalph, isfloat;
const char *bad;
- int backslash, isalph, isfloat, result;
+ char ch;
result = -1;
session = (WT_SESSION_IMPL *)wt_session;
@@ -475,7 +478,7 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype,
/* JSON is specified in RFC 4627. */
switch (*src) {
case '"':
- backslash = 0;
+ backslash = false;
src++;
while ((ch = *src) != '\0') {
if (!backslash) {
@@ -485,7 +488,7 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype,
break;
}
if (ch == '\\')
- backslash = 1;
+ backslash = true;
} else {
/* We validate Unicode on this pass. */
if (ch == 'u') {
@@ -501,7 +504,7 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype,
}
src += 5;
}
- backslash = 0;
+ backslash = false;
}
src++;
}
@@ -519,20 +522,20 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype,
case '7':
case '8':
case '9':
- isfloat = 0;
+ isfloat = false;
if (*src == '-')
src++;
while ((ch = *src) != '\0' && isdigit(ch))
src++;
if (*src == '.') {
- isfloat = 1;
+ isfloat = true;
src++;
while ((ch = *src) != '\0' &&
isdigit(ch))
src++;
}
if (*src == 'e' || *src == 'E') {
- isfloat = 1;
+ isfloat = true;
src++;
if (*src == '+' || *src == '-')
src++;
@@ -610,9 +613,9 @@ __wt_json_tokname(int toktype)
static int
json_string_arg(WT_SESSION_IMPL *session, const char **jstr, WT_ITEM *item)
{
- const char *tokstart;
- int tok;
WT_DECL_RET;
+ int tok;
+ const char *tokstart;
WT_RET(__wt_json_token((WT_SESSION *)session, *jstr, &tok, &tokstart,
&item->size));
@@ -640,8 +643,8 @@ json_int_arg(WT_SESSION_IMPL *session, const char **jstr, int64_t *ip)
{
char *end;
const char *tokstart;
- int tok;
size_t toksize;
+ int tok;
WT_RET(__wt_json_token((WT_SESSION *)session, *jstr, &tok, &tokstart,
&toksize));
@@ -668,10 +671,10 @@ json_int_arg(WT_SESSION_IMPL *session, const char **jstr, int64_t *ip)
static int
json_uint_arg(WT_SESSION_IMPL *session, const char **jstr, uint64_t *up)
{
- char *end;
- const char *tokstart;
- int tok;
size_t toksize;
+ int tok;
+ const char *tokstart;
+ char *end;
WT_RET(__wt_json_token((WT_SESSION *)session, *jstr, &tok, &tokstart,
&toksize));
@@ -718,14 +721,14 @@ __json_pack_struct(WT_SESSION_IMPL *session, void *buffer, size_t size,
WT_DECL_PACK_VALUE(pv);
WT_DECL_RET;
WT_PACK pack;
- const char *tokstart;
- int multi;
size_t toksize;
+ bool multi;
uint8_t *p, *end;
+ const char *tokstart;
p = buffer;
end = p + size;
- multi = 0;
+ multi = false;
if (fmt[0] != '\0' && fmt[1] == '\0') {
JSON_EXPECT_TOKEN_GET(session, jstr, 's', tokstart, toksize);
@@ -745,7 +748,7 @@ __json_pack_struct(WT_SESSION_IMPL *session, void *buffer, size_t size,
JSON_EXPECT_TOKEN(session, jstr, ':');
WT_PACK_JSON_GET(session, pv, jstr);
WT_RET(__pack_write(session, &pv, &p, (size_t)(end - p)));
- multi = 1;
+ multi = true;
}
/* Be paranoid - __pack_write should never overflow. */
@@ -767,18 +770,18 @@ __json_pack_struct(WT_SESSION_IMPL *session, void *buffer, size_t size,
static int
__json_pack_size(
WT_SESSION_IMPL *session, const char *fmt, WT_CONFIG_ITEM *names,
- int iskey, const char *jstr, size_t *sizep)
+ bool iskey, const char *jstr, size_t *sizep)
{
WT_CONFIG_ITEM name;
WT_DECL_PACK_VALUE(pv);
WT_PACK pack;
WT_PACK_NAME packname;
- const char *tokstart;
- int multi;
size_t toksize, total;
+ bool multi;
+ const char *tokstart;
WT_RET(__pack_name_init(session, names, iskey, &packname));
- multi = 0;
+ multi = false;
WT_RET(__pack_init(session, &pack, fmt));
for (total = 0; __pack_next(&pack, &pv) == 0;) {
if (multi)
@@ -794,7 +797,7 @@ __json_pack_size(
JSON_EXPECT_TOKEN(session, jstr, ':');
WT_PACK_JSON_GET(session, pv, jstr);
total += __pack_size(session, &pv);
- multi = 1;
+ multi = true;
}
/* check end of string */
JSON_EXPECT_TOKEN(session, jstr, 0);
@@ -810,7 +813,7 @@ __json_pack_size(
*/
int
__wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr,
- const char *format, WT_CURSOR_JSON *json, int iskey, WT_ITEM *item)
+ const char *format, WT_CURSOR_JSON *json, bool iskey, WT_ITEM *item)
{
size_t sz;
sz = 0; /* Initialize because GCC 4.1 is paranoid */
diff --git a/src/cursor/cur_std.c b/src/cursor/cur_std.c
index 3bb64a22b0e..dfc9fc09a26 100644
--- a/src/cursor/cur_std.c
+++ b/src/cursor/cur_std.c
@@ -63,7 +63,7 @@ __wt_cursor_set_notsup(WT_CURSOR *cursor)
* Standard error message for key/values not set.
*/
int
-__wt_cursor_kv_not_set(WT_CURSOR *cursor, int key)
+__wt_cursor_kv_not_set(WT_CURSOR *cursor, bool key)
{
WT_SESSION_IMPL *session;
@@ -195,7 +195,7 @@ __wt_cursor_get_keyv(WT_CURSOR *cursor, uint32_t flags, va_list ap)
CURSOR_API_CALL(cursor, session, get_key, NULL);
if (!F_ISSET(cursor, WT_CURSTD_KEY_EXT | WT_CURSTD_KEY_INT))
- WT_ERR(__wt_cursor_kv_not_set(cursor, 1));
+ WT_ERR(__wt_cursor_kv_not_set(cursor, true));
if (WT_CURSOR_RECNO(cursor)) {
if (LF_ISSET(WT_CURSTD_RAW)) {
@@ -344,7 +344,7 @@ __wt_cursor_get_valuev(WT_CURSOR *cursor, va_list ap)
CURSOR_API_CALL(cursor, session, get_value, NULL);
if (!F_ISSET(cursor, WT_CURSTD_VALUE_EXT | WT_CURSTD_VALUE_INT))
- WT_ERR(__wt_cursor_kv_not_set(cursor, 0));
+ WT_ERR(__wt_cursor_kv_not_set(cursor, false));
/* Fast path some common cases. */
fmt = cursor->value_format;
diff --git a/src/cursor/cur_table.c b/src/cursor/cur_table.c
index 9834b247341..80a211cffa8 100644
--- a/src/cursor/cur_table.c
+++ b/src/cursor/cur_table.c
@@ -528,7 +528,7 @@ __curtable_insert(WT_CURSOR *cursor)
WT_ERR((*cp)->insert(*cp));
}
- WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), 0));
+ WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), false));
err: CURSOR_UPDATE_API_END(session, ret);
return (ret);
@@ -567,7 +567,7 @@ __curtable_update(WT_CURSOR *cursor)
/* Remove only if the key exists. */
if (ret == 0) {
WT_ERR(__apply_idx(ctable,
- offsetof(WT_CURSOR, remove), 1));
+ offsetof(WT_CURSOR, remove), true));
WT_ERR(__wt_schema_project_slice(session,
ctable->cg_cursors, ctable->plan, 0,
cursor->value_format, value_copy));
@@ -579,7 +579,7 @@ __curtable_update(WT_CURSOR *cursor)
WT_ERR(ret);
if (ctable->table->nindices > 0)
- WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), 1));
+ WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), true));
err: CURSOR_UPDATE_API_END(session, ret);
__wt_scr_free(session, &value_copy);
@@ -605,7 +605,7 @@ __curtable_remove(WT_CURSOR *cursor)
if (ctable->table->nindices > 0) {
APPLY_CG(ctable, search);
WT_ERR(ret);
- WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, remove), 0));
+ WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, remove), false));
}
APPLY_CG(ctable, remove);
@@ -656,7 +656,7 @@ __wt_table_range_truncate(WT_CURSOR_TABLE *start, WT_CURSOR_TABLE *stop)
APPLY_CG(stop, search);
WT_ERR(ret);
WT_ERR(__apply_idx(
- stop, offsetof(WT_CURSOR, remove), 0));
+ stop, offsetof(WT_CURSOR, remove), false));
} while ((ret = wt_stop->prev(wt_stop)) == 0);
WT_ERR_NOTFOUND_OK(ret);
@@ -671,7 +671,7 @@ __wt_table_range_truncate(WT_CURSOR_TABLE *start, WT_CURSOR_TABLE *stop)
APPLY_CG(start, search);
WT_ERR(ret);
WT_ERR(__apply_idx(
- start, offsetof(WT_CURSOR, remove), 0));
+ start, offsetof(WT_CURSOR, remove), false));
if (stop != NULL)
WT_ERR(wt_start->compare(
wt_start, wt_stop,
@@ -764,7 +764,7 @@ __curtable_open_colgroups(WT_CURSOR_TABLE *ctable, const char *cfg_arg[])
cfg_arg[0], cfg_arg[1], "dump=\"\",readonly=0", NULL, NULL
};
u_int i;
- int complete;
+ bool complete;
session = (WT_SESSION_IMPL *)ctable->iface.session;
table = ctable->table;
@@ -872,7 +872,7 @@ __wt_curtable_open(WT_SESSION_IMPL *session,
size = strlen(tablename);
else
size = WT_PTRDIFF(columns, tablename);
- WT_RET(__wt_schema_get_table(session, tablename, size, 0, &table));
+ WT_RET(__wt_schema_get_table(session, tablename, size, false, &table));
if (table->is_simple) {
/* Just return a cursor on the underlying data source. */
@@ -899,13 +899,13 @@ __wt_curtable_open(WT_SESSION_IMPL *session,
WT_ERR(__wt_scr_alloc(session, 0, &tmp));
if (columns != NULL) {
WT_ERR(__wt_struct_reformat(session, table,
- columns, strlen(columns), NULL, 1, tmp));
+ columns, strlen(columns), NULL, true, tmp));
WT_ERR(__wt_strndup(
session, tmp->data, tmp->size, &cursor->value_format));
WT_ERR(__wt_buf_init(session, tmp, 0));
WT_ERR(__wt_struct_plan(session, table,
- columns, strlen(columns), 0, tmp));
+ columns, strlen(columns), false, tmp));
WT_ERR(__wt_strndup(
session, tmp->data, tmp->size, &ctable->plan));
}
diff --git a/src/evict/evict_file.c b/src/evict/evict_file.c
index 8bfa5c89ff3..5e0b5b6c7ee 100644
--- a/src/evict/evict_file.c
+++ b/src/evict/evict_file.c
@@ -27,7 +27,7 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop)
WT_RET(__wt_evict_file_exclusive_on(session, &evict_reset));
/* Make sure the oldest transaction ID is up-to-date. */
- __wt_txn_update_oldest(session, 1);
+ __wt_txn_update_oldest(session, true);
/* Walk the tree, discarding pages. */
next_ref = NULL;
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index 2fbfa796c1f..e3d5544d216 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -248,7 +248,7 @@ __evict_workers_resize(WT_SESSION_IMPL *session)
for (i = conn->evict_workers_alloc; i < conn->evict_workers_max; i++) {
WT_ERR(__wt_open_internal_session(conn,
- "eviction-worker", 0, 0, &workers[i].session));
+ "eviction-worker", true, false, &workers[i].session));
workers[i].id = i;
F_SET(workers[i].session, WT_SESSION_CAN_WAIT);
@@ -280,7 +280,7 @@ __wt_evict_create(WT_SESSION_IMPL *session)
/* We need a session handle because we're reading/writing pages. */
WT_RET(__wt_open_internal_session(
- conn, "eviction-server", 0, 0, &conn->evict_session));
+ conn, "eviction-server", true, false, &conn->evict_session));
session = conn->evict_session;
/*
@@ -505,7 +505,7 @@ __evict_pass(WT_SESSION_IMPL *session)
* of whether the cache is full, to prevent the oldest ID
* falling too far behind.
*/
- __wt_txn_update_oldest(session, 1);
+ __wt_txn_update_oldest(session, true);
WT_RET(__evict_has_work(session, &flags));
if (flags == 0)
@@ -1162,7 +1162,6 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp, uint32_t flags)
start = cache->evict + *slotp;
end = WT_MIN(start + WT_EVICT_WALK_PER_FILE,
cache->evict + cache->evict_slots);
- enough = internal_pages = restarts = 0;
internal_pages = restarts = 0;
enough = false;
@@ -1239,7 +1238,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp, uint32_t flags)
page->read_gen = __wt_cache_read_gen_new(session);
fast: /* If the page can't be evicted, give up. */
- if (!__wt_page_can_evict(session, page, 1, NULL))
+ if (!__wt_page_can_evict(session, page, true, NULL))
continue;
/*
@@ -1464,7 +1463,7 @@ __wt_evict_lru_page(WT_SESSION_IMPL *session, bool is_server)
* Wait for space in the cache.
*/
int
-__wt_cache_wait(WT_SESSION_IMPL *session, bool full)
+__wt_cache_wait(WT_SESSION_IMPL *session, int full)
{
WT_CACHE *cache;
WT_DECL_RET;
diff --git a/src/evict/evict_page.c b/src/evict/evict_page.c
index dee89b41e71..f4693511e11 100644
--- a/src/evict/evict_page.c
+++ b/src/evict/evict_page.c
@@ -322,7 +322,7 @@ __evict_review(
if (__wt_page_is_modified(page))
__wt_txn_update_oldest(session, true);
- if (!__wt_page_can_evict(session, page, 0, inmem_splitp))
+ if (!__wt_page_can_evict(session, page, false, inmem_splitp))
return (EBUSY);
/*
@@ -339,7 +339,7 @@ __evict_review(
* cleanup.
*/
if (*inmem_splitp)
- return (__wt_split_insert(session, ref, inmem_splitp));
+ return (__wt_split_insert(session, ref));
}
/*
diff --git a/src/include/btree.i b/src/include/btree.i
index 1cf0c9a8aff..dad695f8628 100644
--- a/src/include/btree.i
+++ b/src/include/btree.i
@@ -77,12 +77,12 @@ __wt_cache_decr_check_size(
(void)__wt_atomic_addsize(vp, v);
{
- static int first = 1;
+ static bool first = true;
if (!first)
return;
__wt_errx(session, "%s underflow: decrementing %" WT_SIZET_FMT, fld, v);
- first = 0;
+ first = false;
}
#else
WT_UNUSED(fld);
@@ -105,12 +105,12 @@ __wt_cache_decr_check_uint64(
(void)__wt_atomic_add64(vp, v);
{
- static int first = 1;
+ static bool first = true;
if (!first)
return;
__wt_errx(session, "%s underflow: decrementing %" WT_SIZET_FMT, fld, v);
- first = 0;
+ first = false;
}
#else
WT_UNUSED(fld);
@@ -404,7 +404,7 @@ __wt_page_modify_set(WT_SESSION_IMPL *session, WT_PAGE *page)
*/
static inline int
__wt_page_parent_modify_set(
- WT_SESSION_IMPL *session, WT_REF *ref, int page_only)
+ WT_SESSION_IMPL *session, WT_REF *ref, bool page_only)
{
WT_PAGE *parent;
@@ -1001,7 +1001,7 @@ __wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page)
*/
static inline bool
__wt_page_can_evict(WT_SESSION_IMPL *session,
- WT_PAGE *page, int check_splits, bool *inmem_splitp)
+ WT_PAGE *page, bool check_splits, bool *inmem_splitp)
{
WT_BTREE *btree;
WT_PAGE_MODIFY *mod;
@@ -1079,8 +1079,7 @@ __wt_page_release_evict(WT_SESSION_IMPL *session, WT_REF *ref)
WT_BTREE *btree;
WT_DECL_RET;
WT_PAGE *page;
- int locked;
- bool too_big;
+ bool locked, too_big;
btree = S2BT(session);
page = ref->page;
@@ -1091,7 +1090,8 @@ __wt_page_release_evict(WT_SESSION_IMPL *session, WT_REF *ref)
* reference without first locking the page, it could be evicted in
* between.
*/
- locked = __wt_atomic_casv32(&ref->state, WT_REF_MEM, WT_REF_LOCKED);
+ locked = __wt_atomic_casv32(
+ &ref->state, WT_REF_MEM, WT_REF_LOCKED) ? true : false;
if ((ret = __wt_hazard_clear(session, page)) != 0 || !locked) {
if (locked)
ref->state = WT_REF_MEM;
@@ -1153,7 +1153,7 @@ __wt_page_release(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags)
if (page->read_gen != WT_READGEN_OLDEST ||
LF_ISSET(WT_READ_NO_EVICT) ||
F_ISSET(btree, WT_BTREE_NO_EVICTION) ||
- !__wt_page_can_evict(session, page, 1, NULL))
+ !__wt_page_can_evict(session, page, true, NULL))
return (__wt_hazard_clear(session, page));
WT_RET_BUSY_OK(__wt_page_release_evict(session, ref));
@@ -1174,7 +1174,7 @@ __wt_page_swap_func(WT_SESSION_IMPL *session, WT_REF *held,
)
{
WT_DECL_RET;
- int acquired;
+ bool acquired;
/*
* In rare cases when walking the tree, we try to swap to the same
diff --git a/src/include/cursor.h b/src/include/cursor.h
index d23deee8c98..a1c94e94817 100644
--- a/src/include/cursor.h
+++ b/src/include/cursor.h
@@ -360,11 +360,11 @@ struct __wt_cursor_table {
*/
#define WT_CURSOR_CHECKKEY(cursor) do { \
if (!F_ISSET(cursor, WT_CURSTD_KEY_SET)) \
- WT_ERR(__wt_cursor_kv_not_set(cursor, 1)); \
+ WT_ERR(__wt_cursor_kv_not_set(cursor, true)); \
} while (0)
#define WT_CURSOR_CHECKVALUE(cursor) do { \
if (!F_ISSET(cursor, WT_CURSTD_VALUE_SET)) \
- WT_ERR(__wt_cursor_kv_not_set(cursor, 0)); \
+ WT_ERR(__wt_cursor_kv_not_set(cursor, false)); \
} while (0)
#define WT_CURSOR_NEEDKEY(cursor) do { \
if (F_ISSET(cursor, WT_CURSTD_KEY_INT)) { \
diff --git a/src/include/cursor.i b/src/include/cursor.i
index 9b07c3b1676..63ffa3c7e84 100644
--- a/src/include/cursor.i
+++ b/src/include/cursor.i
@@ -178,7 +178,7 @@ __wt_cursor_dhandle_decr_use(WT_SESSION_IMPL *session)
* Cursor call setup.
*/
static inline int
-__cursor_func_init(WT_CURSOR_BTREE *cbt, int reenter)
+__cursor_func_init(WT_CURSOR_BTREE *cbt, bool reenter)
{
WT_SESSION_IMPL *session;
diff --git a/src/include/extern.h b/src/include/extern.h
index adaeed31bba..58963bc8c42 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -152,7 +152,7 @@ extern int __wt_bt_salvage(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, const ch
extern void __wt_split_stash_discard(WT_SESSION_IMPL *session);
extern void __wt_split_stash_discard_all( WT_SESSION_IMPL *session_safe, WT_SESSION_IMPL *session);
extern int __wt_multi_to_ref(WT_SESSION_IMPL *session, WT_PAGE *page, WT_MULTI *multi, WT_REF **refp, size_t *incrp);
-extern int __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref, int *splitp);
+extern int __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref);
extern int __wt_split_rewrite(WT_SESSION_IMPL *session, WT_REF *ref);
extern int __wt_split_multi(WT_SESSION_IMPL *session, WT_REF *ref, bool closing);
extern int __wt_btree_stat_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst);
@@ -254,21 +254,21 @@ extern int __wt_sweep_destroy(WT_SESSION_IMPL *session);
extern int __wt_curbackup_open(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR **cursorp);
extern int __wt_backup_file_remove(WT_SESSION_IMPL *session);
extern int __wt_backup_list_uri_append( WT_SESSION_IMPL *session, const char *name, bool *skip);
-extern int __wt_curbulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk, int bitmap, bool skip_sort_check);
+extern int __wt_curbulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk, bool bitmap, bool skip_sort_check);
extern int __wt_curconfig_open(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR **cursorp);
extern int __wt_curds_open( WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_DATA_SOURCE *dsrc, WT_CURSOR **cursorp);
extern int __wt_curdump_create(WT_CURSOR *child, WT_CURSOR *owner, WT_CURSOR **cursorp);
extern int __wt_curfile_update_check(WT_CURSOR *cursor);
-extern int __wt_curfile_create(WT_SESSION_IMPL *session, WT_CURSOR *owner, const char *cfg[], int bulk, int bitmap, WT_CURSOR **cursorp);
+extern int __wt_curfile_create(WT_SESSION_IMPL *session, WT_CURSOR *owner, const char *cfg[], bool bulk, bool bitmap, WT_CURSOR **cursorp);
extern int __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp);
extern int __wt_curindex_open(WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp);
-extern int __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CURSOR_JSON *json, int iskey, va_list ap);
+extern int __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CURSOR_JSON *json, bool iskey, va_list ap);
extern void __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor);
-extern size_t __wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, int force_unicode);
+extern size_t __wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, bool force_unicode);
extern int __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, const WT_CONFIG_ITEM *idxconf, const WT_CONFIG_ITEM *colconf);
extern int __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, const char **tokstart, size_t *toklen);
extern const char *__wt_json_tokname(int toktype);
-extern int __wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr, const char *format, WT_CURSOR_JSON *json, int iskey, WT_ITEM *item);
+extern int __wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr, const char *format, WT_CURSOR_JSON *json, bool iskey, WT_ITEM *item);
extern ssize_t __wt_json_strlen(const char *src, size_t srclen);
extern int __wt_json_strncpy(char **pdst, size_t dstlen, const char *src, size_t srclen);
extern int __wt_curlog_open(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR **cursorp);
@@ -279,7 +279,7 @@ extern int __wt_curstat_open(WT_SESSION_IMPL *session, const char *uri, const ch
extern int __wt_cursor_notsup(WT_CURSOR *cursor);
extern int __wt_cursor_noop(WT_CURSOR *cursor);
extern void __wt_cursor_set_notsup(WT_CURSOR *cursor);
-extern int __wt_cursor_kv_not_set(WT_CURSOR *cursor, int key);
+extern int __wt_cursor_kv_not_set(WT_CURSOR *cursor, bool key);
extern int __wt_cursor_get_key(WT_CURSOR *cursor, ...);
extern void __wt_cursor_set_key(WT_CURSOR *cursor, ...);
extern int __wt_cursor_get_raw_key(WT_CURSOR *cursor, WT_ITEM *key);
@@ -312,7 +312,7 @@ extern int __wt_evict_page(WT_SESSION_IMPL *session, WT_REF *ref);
extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, bool *evict_resetp);
extern void __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session);
extern int __wt_evict_lru_page(WT_SESSION_IMPL *session, bool is_server);
-extern int __wt_cache_wait(WT_SESSION_IMPL *session, bool full);
+extern int __wt_cache_wait(WT_SESSION_IMPL *session, int full);
extern void __wt_cache_dump(WT_SESSION_IMPL *session);
extern int __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing);
extern void __wt_evict_page_clean_update(WT_SESSION_IMPL *session, WT_REF *ref);
@@ -320,14 +320,14 @@ extern int __wt_log_ckpt(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn);
extern int __wt_log_force_sync(WT_SESSION_IMPL *session, WT_LSN *min_lsn);
extern int __wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, bool *recp);
extern void __wt_log_written_reset(WT_SESSION_IMPL *session);
-extern int __wt_log_get_all_files(WT_SESSION_IMPL *session, char ***filesp, u_int *countp, uint32_t *maxid, int active_only);
+extern int __wt_log_get_all_files(WT_SESSION_IMPL *session, char ***filesp, u_int *countp, uint32_t *maxid, bool active_only);
extern void __wt_log_files_free(WT_SESSION_IMPL *session, char **files, u_int count);
extern int __wt_log_extract_lognum( WT_SESSION_IMPL *session, const char *name, uint32_t *id);
-extern int __wt_log_allocfile( WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, int prealloc);
+extern int __wt_log_allocfile( WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, bool prealloc);
extern int __wt_log_remove(WT_SESSION_IMPL *session, const char *file_prefix, uint32_t lognum);
extern int __wt_log_open(WT_SESSION_IMPL *session);
extern int __wt_log_close(WT_SESSION_IMPL *session);
-extern int __wt_log_newfile(WT_SESSION_IMPL *session, int conn_create, int *created);
+extern int __wt_log_newfile(WT_SESSION_IMPL *session, bool conn_create, int *created);
extern int __wt_log_read(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, uint32_t flags);
extern int __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, int (*func)(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, WT_LSN *next_lsnp, void *cookie, int firstrecord), void *cookie);
extern int __wt_log_write(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, uint32_t flags);
@@ -389,10 +389,10 @@ extern int __wt_lsm_tree_chunk_name(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_t
extern int __wt_lsm_tree_set_chunk_size( WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk);
extern int __wt_lsm_tree_setup_chunk( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk);
extern int __wt_lsm_tree_setup_bloom( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk);
-extern int __wt_lsm_tree_create(WT_SESSION_IMPL *session, const char *uri, int exclusive, const char *config);
-extern int __wt_lsm_tree_get(WT_SESSION_IMPL *session, const char *uri, int exclusive, WT_LSM_TREE **treep);
+extern int __wt_lsm_tree_create(WT_SESSION_IMPL *session, const char *uri, bool exclusive, const char *config);
+extern int __wt_lsm_tree_get(WT_SESSION_IMPL *session, const char *uri, bool exclusive, WT_LSM_TREE **treep);
extern void __wt_lsm_tree_release(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree);
-extern void __wt_lsm_tree_throttle( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int decrease_only);
+extern void __wt_lsm_tree_throttle( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool decrease_only);
extern int __wt_lsm_tree_switch(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree);
extern int __wt_lsm_tree_retire_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int start_chunk, u_int nchunks);
extern int __wt_lsm_tree_drop( WT_SESSION_IMPL *session, const char *name, const char *cfg[]);
@@ -404,8 +404,8 @@ extern int __wt_lsm_tree_writelock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tr
extern int __wt_lsm_tree_writeunlock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree);
extern int __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp);
extern int __wt_lsm_tree_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), int (*name_func)(WT_SESSION_IMPL *, const char *, bool *), const char *cfg[], uint32_t open_flags);
-extern int __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int force, WT_LSM_CHUNK **chunkp);
-extern int __wt_lsm_work_switch( WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, int *ran);
+extern int __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool force, WT_LSM_CHUNK **chunkp);
+extern int __wt_lsm_work_switch( WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, bool *ran);
extern int __wt_lsm_work_bloom(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree);
extern int __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk);
extern int __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree);
@@ -433,7 +433,7 @@ extern int __wt_metadata_search( WT_SESSION_IMPL *session, const char *key, char
extern void __wt_meta_track_discard(WT_SESSION_IMPL *session);
extern int __wt_meta_track_on(WT_SESSION_IMPL *session);
extern int __wt_meta_track_find_handle( WT_SESSION_IMPL *session, const char *name, const char *checkpoint);
-extern int __wt_meta_track_off(WT_SESSION_IMPL *session, int need_sync, int unroll);
+extern int __wt_meta_track_off(WT_SESSION_IMPL *session, bool need_sync, bool unroll);
extern int __wt_meta_track_sub_on(WT_SESSION_IMPL *session);
extern int __wt_meta_track_sub_off(WT_SESSION_IMPL *session);
extern int __wt_meta_track_checkpoint(WT_SESSION_IMPL *session);
@@ -441,7 +441,7 @@ extern int __wt_meta_track_insert(WT_SESSION_IMPL *session, const char *key);
extern int __wt_meta_track_update(WT_SESSION_IMPL *session, const char *key);
extern int __wt_meta_track_fileop( WT_SESSION_IMPL *session, const char *olduri, const char *newuri);
extern int __wt_meta_track_drop( WT_SESSION_IMPL *session, const char *filename);
-extern int __wt_meta_track_handle_lock(WT_SESSION_IMPL *session, int created);
+extern int __wt_meta_track_handle_lock(WT_SESSION_IMPL *session, bool created);
extern int __wt_turtle_init(WT_SESSION_IMPL *session);
extern int __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep);
extern int __wt_turtle_update( WT_SESSION_IMPL *session, const char *key, const char *value);
@@ -454,7 +454,7 @@ extern int __wt_strdup(WT_SESSION_IMPL *session, const char *str, void *retp);
extern void __wt_free_int(WT_SESSION_IMPL *session, const void *p_arg);
extern int __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix, uint32_t flags, char ***dirlist, u_int *countp);
extern int __wt_dlopen(WT_SESSION_IMPL *session, const char *path, WT_DLH **dlhp);
-extern int __wt_dlsym(WT_SESSION_IMPL *session, WT_DLH *dlh, const char *name, int fail, void *sym_ret);
+extern int __wt_dlsym(WT_SESSION_IMPL *session, WT_DLH *dlh, const char *name, bool fail, void *sym_ret);
extern int __wt_dlclose(WT_SESSION_IMPL *session, WT_DLH *dlh);
extern int __wt_errno(void);
extern const char *__wt_strerror(WT_SESSION_IMPL *session, int error, char *errbuf, size_t errlen);
@@ -463,7 +463,7 @@ extern void __wt_fallocate_config(WT_SESSION_IMPL *session, WT_FH *fh);
extern int __wt_fallocate( WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, wt_off_t len);
extern int __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep);
extern int __wt_filesize_name( WT_SESSION_IMPL *session, const char *filename, wt_off_t *sizep);
-extern int __wt_bytelock(WT_FH *fhp, wt_off_t byte, int lock);
+extern int __wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock);
extern int __wt_directory_sync_fh(WT_SESSION_IMPL *session, WT_FH *fh);
extern int __wt_directory_sync(WT_SESSION_IMPL *session, char *path);
extern int __wt_fsync(WT_SESSION_IMPL *session, WT_FH *fh);
@@ -476,7 +476,7 @@ extern int __wt_mmap(WT_SESSION_IMPL *session, WT_FH *fh, void *mapp, size_t *le
extern int __wt_mmap_preload(WT_SESSION_IMPL *session, const void *p, size_t size);
extern int __wt_mmap_discard(WT_SESSION_IMPL *session, void *p, size_t size);
extern int __wt_munmap(WT_SESSION_IMPL *session, WT_FH *fh, void *map, size_t len, void **mappingcookie);
-extern int __wt_cond_alloc(WT_SESSION_IMPL *session, const char *name, int is_signalled, WT_CONDVAR **condp);
+extern int __wt_cond_alloc(WT_SESSION_IMPL *session, const char *name, bool is_signalled, WT_CONDVAR **condp);
extern int __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs);
extern int __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond);
extern int __wt_cond_destroy(WT_SESSION_IMPL *session, WT_CONDVAR **condp);
@@ -493,7 +493,7 @@ extern int __wt_open(WT_SESSION_IMPL *session, const char *name, bool ok_create,
extern int __wt_close(WT_SESSION_IMPL *session, WT_FH **fhp);
extern bool __wt_absolute_path(const char *path);
extern const char *__wt_path_separator(void);
-extern int __wt_has_priv(void);
+extern bool __wt_has_priv(void);
extern int __wt_remove(WT_SESSION_IMPL *session, const char *name);
extern int __wt_rename(WT_SESSION_IMPL *session, const char *from, const char *to);
extern int __wt_read( WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, size_t len, void *buf);
@@ -541,7 +541,7 @@ extern int __wt_schema_colgroup_source(WT_SESSION_IMPL *session, WT_TABLE *table
extern int __wt_schema_index_source(WT_SESSION_IMPL *session, WT_TABLE *table, const char *idxname, const char *config, WT_ITEM *buf);
extern int __wt_schema_create( WT_SESSION_IMPL *session, const char *uri, const char *config);
extern int __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]);
-extern int __wt_schema_get_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep);
+extern int __wt_schema_get_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep);
extern void __wt_schema_release_table(WT_SESSION_IMPL *session, WT_TABLE *table);
extern void __wt_schema_destroy_colgroup(WT_SESSION_IMPL *session, WT_COLGROUP *colgroup);
extern int __wt_schema_destroy_index(WT_SESSION_IMPL *session, WT_INDEX *idx);
@@ -552,13 +552,13 @@ extern int __wt_schema_colgroup_name(WT_SESSION_IMPL *session, WT_TABLE *table,
extern int __wt_schema_open_colgroups(WT_SESSION_IMPL *session, WT_TABLE *table);
extern int __wt_schema_open_index(WT_SESSION_IMPL *session, WT_TABLE *table, const char *idxname, size_t len, WT_INDEX **indexp);
extern int __wt_schema_open_indices(WT_SESSION_IMPL *session, WT_TABLE *table);
-extern int __wt_schema_open_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep);
-extern int __wt_schema_get_colgroup(WT_SESSION_IMPL *session, const char *uri, int quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp);
-extern int __wt_schema_get_index(WT_SESSION_IMPL *session, const char *uri, int quiet, WT_TABLE **tablep, WT_INDEX **indexp);
+extern int __wt_schema_open_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep);
+extern int __wt_schema_get_colgroup(WT_SESSION_IMPL *session, const char *uri, bool quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp);
+extern int __wt_schema_get_index(WT_SESSION_IMPL *session, const char *uri, bool quiet, WT_TABLE **tablep, WT_INDEX **indexp);
extern int __wt_schema_colcheck(WT_SESSION_IMPL *session, const char *key_format, const char *value_format, WT_CONFIG_ITEM *colconf, u_int *kcolsp, u_int *vcolsp);
extern int __wt_table_check(WT_SESSION_IMPL *session, WT_TABLE *table);
-extern int __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, int value_only, WT_ITEM *plan);
-extern int __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, const char *extra_cols, int value_only, WT_ITEM *format);
+extern int __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, bool value_only, WT_ITEM *plan);
+extern int __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, const char *extra_cols, bool value_only, WT_ITEM *format);
extern int __wt_struct_truncate(WT_SESSION_IMPL *session, const char *input_fmt, u_int ncols, WT_ITEM *format);
extern int __wt_schema_project_in(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, va_list ap);
extern int __wt_schema_project_out(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, va_list ap);
@@ -579,7 +579,7 @@ extern int __wt_session_reset_cursors(WT_SESSION_IMPL *session);
extern int __wt_session_copy_values(WT_SESSION_IMPL *session);
extern int __wt_open_cursor(WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp);
extern int __wt_session_create_strip(WT_SESSION *wt_session, const char *v1, const char *v2, char **value_ret);
-extern int __wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name, int uses_dhandles, int open_metadata, WT_SESSION_IMPL **sessionp);
+extern int __wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name, bool uses_dhandles, bool open_metadata, WT_SESSION_IMPL **sessionp);
extern int __wt_open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const char *config, WT_SESSION_IMPL **sessionp);
extern int __wt_compact_uri_analyze(WT_SESSION_IMPL *session, const char *uri, bool *skipp);
extern int __wt_session_compact( WT_SESSION *wt_session, const char *uri, const char *config);
@@ -593,7 +593,7 @@ extern int __wt_salvage(WT_SESSION_IMPL *session, const char *cfg[]);
extern uint32_t __wt_cksum(const void *chunk, size_t len);
extern void __wt_cksum_init(void);
extern void __wt_event_handler_set(WT_SESSION_IMPL *session, WT_EVENT_HANDLER *handler);
-extern int __wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap);
+extern int __wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap);
extern void __wt_err(WT_SESSION_IMPL *session, int error, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4)));
extern void __wt_errx(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 2, 3)));
extern int __wt_ext_err_printf( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4)));
@@ -666,7 +666,7 @@ extern void __wt_stat_refresh_connection_stats(void *stats_arg);
extern int WT_CDECL __wt_txnid_cmp(const void *v1, const void *v2);
extern void __wt_txn_release_snapshot(WT_SESSION_IMPL *session);
extern void __wt_txn_get_snapshot(WT_SESSION_IMPL *session);
-extern void __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force);
+extern void __wt_txn_update_oldest(WT_SESSION_IMPL *session, bool force);
extern int __wt_txn_config(WT_SESSION_IMPL *session, const char *cfg[]);
extern void __wt_txn_release(WT_SESSION_IMPL *session);
extern int __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]);
@@ -681,7 +681,7 @@ extern int __wt_checkpoint_list(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_checkpoint_sync(WT_SESSION_IMPL *session, const char *cfg[]);
-extern int __wt_checkpoint_close(WT_SESSION_IMPL *session, int final);
+extern int __wt_checkpoint_close(WT_SESSION_IMPL *session, bool final);
extern uint64_t __wt_ext_transaction_id(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session);
extern int __wt_ext_transaction_isolation_level( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session);
extern int __wt_ext_transaction_notify( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, WT_TXN_NOTIFY *notify);
@@ -691,7 +691,7 @@ extern void __wt_txn_op_free(WT_SESSION_IMPL *session, WT_TXN_OP *op);
extern int __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt);
extern int __wt_txn_log_commit(WT_SESSION_IMPL *session, const char *cfg[]);
extern int __wt_txn_checkpoint_logread( WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, WT_LSN *ckpt_lsn);
-extern int __wt_txn_checkpoint_log( WT_SESSION_IMPL *session, int full, uint32_t flags, WT_LSN *lsnp);
+extern int __wt_txn_checkpoint_log( WT_SESSION_IMPL *session, bool full, uint32_t flags, WT_LSN *lsnp);
extern int __wt_txn_truncate_log( WT_SESSION_IMPL *session, WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop);
extern int __wt_txn_truncate_end(WT_SESSION_IMPL *session);
extern int __wt_txn_printlog(WT_SESSION *wt_session, FILE *out);
diff --git a/src/include/misc.i b/src/include/misc.i
index 53f08b3cbeb..8ffabcfc7eb 100644
--- a/src/include/misc.i
+++ b/src/include/misc.i
@@ -20,7 +20,7 @@ __wt_verbose(WT_SESSION_IMPL *session, int flag, const char *fmt, ...)
if (WT_VERBOSE_ISSET(session, flag)) {
va_start(ap, fmt);
- ret = __wt_eventv(session, 1, 0, NULL, 0, fmt, ap);
+ ret = __wt_eventv(session, true, 0, NULL, 0, fmt, ap);
va_end(ap);
}
return (ret);
diff --git a/src/include/os.h b/src/include/os.h
index 518b124f547..a8bf59f25d3 100644
--- a/src/include/os.h
+++ b/src/include/os.h
@@ -93,7 +93,7 @@ struct __wt_fh {
wt_off_t extend_size; /* File extended size */
wt_off_t extend_len; /* File extend chunk size */
- int direct_io; /* O_DIRECT configured */
+ bool direct_io; /* O_DIRECT configured */
enum { /* file extend configuration */
WT_FALLOCATE_AVAILABLE,
diff --git a/src/include/packing.i b/src/include/packing.i
index b97b3a322ce..3b60a1269f8 100644
--- a/src/include/packing.i
+++ b/src/include/packing.i
@@ -42,7 +42,7 @@ typedef struct {
WT_CONFIG config;
char buf[20];
int count;
- int iskey;
+ bool iskey;
int genname;
} WT_PACK_NAME;
@@ -82,7 +82,7 @@ __pack_init(WT_SESSION_IMPL *session, WT_PACK *pack, const char *fmt)
*/
static inline int
__pack_name_init(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *names,
- int iskey, WT_PACK_NAME *pn)
+ bool iskey, WT_PACK_NAME *pn)
{
WT_CLEAR(*pn);
pn->iskey = iskey;
diff --git a/src/include/schema.h b/src/include/schema.h
index e590089e607..0f562e9ba18 100644
--- a/src/include/schema.h
+++ b/src/include/schema.h
@@ -65,7 +65,7 @@ struct __wt_table {
TAILQ_ENTRY(__wt_table) q;
TAILQ_ENTRY(__wt_table) hashq;
- int cg_complete, idx_complete, is_simple;
+ bool cg_complete, idx_complete, is_simple;
u_int ncolgroups, nindices, nkey_columns;
uint32_t refcnt; /* Number of open cursors */
diff --git a/src/include/serial.i b/src/include/serial.i
index 7b62e66eccb..f38e50cee6b 100644
--- a/src/include/serial.i
+++ b/src/include/serial.i
@@ -202,8 +202,8 @@ __wt_insert_serial(WT_SESSION_IMPL *session, WT_PAGE *page,
{
WT_INSERT *new_ins = *new_insp;
WT_DECL_RET;
- int simple;
u_int i;
+ bool simple;
/* Check for page write generation wrap. */
WT_RET(__page_write_gen_wrapped_check(page));
@@ -211,10 +211,10 @@ __wt_insert_serial(WT_SESSION_IMPL *session, WT_PAGE *page,
/* Clear references to memory we now own and must free on error. */
*new_insp = NULL;
- simple = 1;
+ simple = true;
for (i = 0; i < skipdepth; i++)
if (new_ins->next[i] == NULL)
- simple = 0;
+ simple = false;
if (simple)
ret = __insert_simple_func(
diff --git a/src/log/log.c b/src/log/log.c
index 1ad82b61673..6eb0d4323ab 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -208,7 +208,7 @@ __log_get_files(WT_SESSION_IMPL *session,
*/
int
__wt_log_get_all_files(WT_SESSION_IMPL *session,
- char ***filesp, u_int *countp, uint32_t *maxid, int active_only)
+ char ***filesp, u_int *countp, uint32_t *maxid, bool active_only)
{
WT_DECL_RET;
WT_LOG *log;
@@ -361,7 +361,7 @@ __log_acquire(WT_SESSION_IMPL *session, uint64_t recsize, WT_LOGSLOT *slot)
*/
slot->slot_release_lsn = log->alloc_lsn;
if (!__log_size_fit(session, &log->alloc_lsn, recsize)) {
- WT_RET(__wt_log_newfile(session, 0, &created_log));
+ WT_RET(__wt_log_newfile(session, false, &created_log));
if (log->log_close_fh != NULL)
F_SET(slot, WT_SLOT_CLOSEFH);
}
@@ -448,7 +448,7 @@ __log_decompress(WT_SESSION_IMPL *session, WT_ITEM *in, WT_ITEM **out)
*/
static int
__log_fill(WT_SESSION_IMPL *session,
- WT_MYSLOT *myslot, int direct, WT_ITEM *record, WT_LSN *lsnp)
+ WT_MYSLOT *myslot, bool direct, WT_ITEM *record, WT_LSN *lsnp)
{
WT_DECL_RET;
WT_LOG_RECORD *logrec;
@@ -487,7 +487,7 @@ err:
*/
static int
__log_file_header(
- WT_SESSION_IMPL *session, WT_FH *fh, WT_LSN *end_lsn, int prealloc)
+ WT_SESSION_IMPL *session, WT_FH *fh, WT_LSN *end_lsn, bool prealloc)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_ITEM(buf);
@@ -539,7 +539,7 @@ __log_file_header(
log->prep_missed++;
WT_ERR(__log_acquire(session, logrec->len, &tmp));
}
- WT_ERR(__log_fill(session, &myslot, 1, buf, NULL));
+ WT_ERR(__log_fill(session, &myslot, true, buf, NULL));
/*
* Make sure the header gets to disk.
*/
@@ -557,7 +557,7 @@ err: __wt_scr_free(session, &buf);
*/
static int
__log_openfile(WT_SESSION_IMPL *session,
- int ok_create, WT_FH **fh, const char *file_prefix, uint32_t id)
+ bool ok_create, WT_FH **fh, const char *file_prefix, uint32_t id)
{
WT_DECL_ITEM(buf);
WT_DECL_RET;
@@ -687,7 +687,7 @@ __log_truncate(WT_SESSION_IMPL *session,
/*
* Truncate the log file to the given LSN.
*/
- WT_ERR(__log_openfile(session, 0, &log_fh, file_prefix, lsn->file));
+ WT_ERR(__log_openfile(session, false, &log_fh, file_prefix, lsn->file));
WT_ERR(__wt_ftruncate(session, log_fh, lsn->offset));
WT_ERR(__wt_fsync(session, log_fh));
WT_ERR(__wt_close(session, &log_fh));
@@ -704,7 +704,7 @@ __log_truncate(WT_SESSION_IMPL *session,
WT_ERR(__wt_log_extract_lognum(session, logfiles[i], &lognum));
if (lognum > lsn->file && lognum < log->trunc_lsn.file) {
WT_ERR(__log_openfile(session,
- 0, &log_fh, file_prefix, lognum));
+ false, &log_fh, file_prefix, lognum));
/*
* If there are intervening files pre-allocated,
* truncate them to the end of the log file header.
@@ -728,7 +728,7 @@ err: WT_TRET(__wt_close(session, &log_fh));
*/
int
__wt_log_allocfile(
- WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, int prealloc)
+ WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, bool prealloc)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_ITEM(from_path);
@@ -754,8 +754,8 @@ __wt_log_allocfile(
/*
* Set up the temporary file.
*/
- WT_ERR(__log_openfile(session, 1, &log_fh, WT_LOG_TMPNAME, lognum));
- WT_ERR(__log_file_header(session, log_fh, NULL, 1));
+ WT_ERR(__log_openfile(session, true, &log_fh, WT_LOG_TMPNAME, lognum));
+ WT_ERR(__log_file_header(session, log_fh, NULL, true));
WT_ERR(__wt_ftruncate(session, log_fh, LOG_FIRST_RECORD));
if (prealloc)
WT_ERR(__log_prealloc(session, log_fh));
@@ -874,7 +874,7 @@ __wt_log_open(WT_SESSION_IMPL *session)
* Start logging at the beginning of the next log file, no matter
* where the previous log file ends.
*/
- WT_ERR(__wt_log_newfile(session, 1, NULL));
+ WT_ERR(__wt_log_newfile(session, true, NULL));
/* If we found log files, save the new state. */
if (logcount > 0) {
@@ -1016,20 +1016,23 @@ err:
* Release a log slot.
*/
static int
-__log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep)
+__log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_LOG *log;
WT_LSN sync_lsn;
size_t write_size;
- int locked, yield_count;
+ int yield_count;
+ bool locked;
WT_DECL_SPINLOCK_ID(id); /* Must appear last */
conn = S2C(session);
log = conn->log;
- locked = yield_count = 0;
- *freep = 1;
+ yield_count = 0;
+ locked = false;
+ if (freep != NULL)
+ *freep = true;
/* Write the buffered records */
if (F_ISSET(slot, WT_SLOT_BUFFERED)) {
@@ -1048,7 +1051,8 @@ __log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep)
*/
if (F_ISSET(slot, WT_SLOT_BUFFERED) &&
!F_ISSET(slot, WT_SLOT_SYNC | WT_SLOT_SYNC_DIR)) {
- *freep = 0;
+ if (freep != NULL)
+ *freep = 0;
slot->slot_state = WT_LOG_SLOT_WRITTEN;
/*
* After this point the worker thread owns the slot. There
@@ -1097,7 +1101,7 @@ __log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep)
session, log->log_sync_cond, 10000));
continue;
}
- locked = 1;
+ locked = true;
/*
* Record the current end of our update after the lock.
@@ -1138,7 +1142,7 @@ __log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep)
* Clear the flags before leaving the loop.
*/
F_CLR(slot, WT_SLOT_SYNC | WT_SLOT_SYNC_DIR);
- locked = 0;
+ locked = false;
__wt_spin_unlock(session, &log->log_sync_lock);
break;
}
@@ -1155,7 +1159,7 @@ done:
* Create the next log file and write the file header record into it.
*/
int
-__wt_log_newfile(WT_SESSION_IMPL *session, int conn_create, int *created)
+__wt_log_newfile(WT_SESSION_IMPL *session, bool conn_create, int *created)
{
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
@@ -1356,8 +1360,8 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags,
wt_off_t log_size;
uint32_t allocsize, cksum, firstlog, lastlog, lognum, rdup_len, reclen;
u_int i, logcount;
- int eol;
int firstrecord;
+ bool eol;
char **logfiles;
conn = S2C(session);
@@ -1365,8 +1369,8 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags,
log_fh = NULL;
logcount = 0;
logfiles = NULL;
+ eol = false;
firstrecord = 1;
- eol = 0;
WT_CLEAR(buf);
/*
@@ -1445,7 +1449,7 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags,
logfiles = NULL;
}
WT_ERR(__log_openfile(
- session, 0, &log_fh, WT_LOG_FILENAME, start_lsn.file));
+ session, false, &log_fh, WT_LOG_FILENAME, start_lsn.file));
WT_ERR(__log_filesize(session, log_fh, &log_size));
rd_lsn = start_lsn;
WT_ERR(__wt_buf_initsize(session, &buf, WT_LOG_ALIGN));
@@ -1457,7 +1461,7 @@ advance:
*/
WT_ERR(__wt_close(session, &log_fh));
log_fh = NULL;
- eol = 1;
+ eol = true;
/*
* Truncate this log file before we move to the next.
*/
@@ -1472,10 +1476,10 @@ advance:
*/
if (rd_lsn.file > end_lsn.file)
break;
- WT_ERR(__log_openfile(
- session, 0, &log_fh, WT_LOG_FILENAME, rd_lsn.file));
+ WT_ERR(__log_openfile(session,
+ false, &log_fh, WT_LOG_FILENAME, rd_lsn.file));
WT_ERR(__log_filesize(session, log_fh, &log_size));
- eol = 0;
+ eol = false;
continue;
}
/*
@@ -1500,7 +1504,7 @@ advance:
*/
if (reclen == 0) {
/* This LSN is the end. */
- eol = 1;
+ eol = true;
break;
}
rdup_len = __wt_rduppo2(reclen, allocsize);
@@ -1606,19 +1610,18 @@ __log_direct_write(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp,
WT_LOG *log;
WT_LOGSLOT tmp;
WT_MYSLOT myslot;
- int dummy, locked;
+ bool locked;
WT_DECL_SPINLOCK_ID(id); /* Must appear last */
log = S2C(session)->log;
myslot.slot = &tmp;
myslot.offset = 0;
- dummy = 0;
WT_CLEAR(tmp);
/* Fast path the contended case. */
if (__wt_spin_trylock(session, &log->log_slot_lock, &id) != 0)
return (EAGAIN);
- locked = 1;
+ locked = true;
if (LF_ISSET(WT_LOG_DSYNC | WT_LOG_FSYNC))
F_SET(&tmp, WT_SLOT_SYNC_DIR);
@@ -1626,9 +1629,9 @@ __log_direct_write(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp,
F_SET(&tmp, WT_SLOT_SYNC);
WT_ERR(__log_acquire(session, record->size, &tmp));
__wt_spin_unlock(session, &log->log_slot_lock);
- locked = 0;
- WT_ERR(__log_fill(session, &myslot, 1, record, lsnp));
- WT_ERR(__log_release(session, &tmp, &dummy));
+ locked = false;
+ WT_ERR(__log_fill(session, &myslot, true, record, lsnp));
+ WT_ERR(__log_release(session, &tmp, NULL));
err: if (locked)
__wt_spin_unlock(session, &log->log_slot_lock);
@@ -1756,7 +1759,7 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp,
WT_LSN lsn;
WT_MYSLOT myslot;
uint32_t rdup_len;
- int free_slot, locked;
+ bool free_slot, locked;
conn = S2C(session);
log = conn->log;
@@ -1767,7 +1770,7 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp,
return (EFBIG);
}
WT_INIT_LSN(&lsn);
- free_slot = locked = 0;
+ free_slot = locked = false;
myslot.slot = NULL;
/*
@@ -1833,16 +1836,16 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp,
WT_ERR(ret);
if (myslot.offset == 0) {
__wt_spin_lock(session, &log->log_slot_lock);
- locked = 1;
+ locked = true;
WT_ERR(__wt_log_slot_close(session, myslot.slot));
WT_ERR(__log_acquire(
session, myslot.slot->slot_group_size, myslot.slot));
__wt_spin_unlock(session, &log->log_slot_lock);
- locked = 0;
+ locked = false;
WT_ERR(__wt_log_slot_notify(session, myslot.slot));
} else
WT_ERR(__wt_log_slot_wait(session, myslot.slot));
- WT_ERR(__log_fill(session, &myslot, 0, record, &lsn));
+ WT_ERR(__log_fill(session, &myslot, false, record, &lsn));
if (__wt_log_slot_release(myslot.slot, rdup_len) == WT_LOG_SLOT_DONE) {
WT_ERR(__log_release(session, myslot.slot, &free_slot));
if (free_slot)
diff --git a/src/log/log_auto.c b/src/log/log_auto.c
index bd830687df2..9977ab01849 100644
--- a/src/log/log_auto.c
+++ b/src/log/log_auto.c
@@ -52,7 +52,8 @@ __logrec_json_unpack_str(char *dest, size_t destlen, const char *src,
total = 0;
while (srclen > 0) {
- n = __wt_json_unpack_char(*src++, (u_char *)dest, destlen, 0);
+ n = __wt_json_unpack_char(
+ *src++, (u_char *)dest, destlen, false);
srclen--;
if (n > destlen)
destlen = 0;
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index 0f3f6c6105d..9ed5eef6ecc 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -16,7 +16,7 @@
__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 *, int, u_int, uint32_t);
+static int __clsm_open_cursors(WT_CURSOR_LSM *, bool, u_int, uint32_t);
static int __clsm_reset_cursors(WT_CURSOR_LSM *, WT_CURSOR *);
/*
@@ -160,7 +160,7 @@ __clsm_enter_update(WT_CURSOR_LSM *clsm)
* Start an operation on an LSM cursor, update if the tree has changed.
*/
static inline int
-__clsm_enter(WT_CURSOR_LSM *clsm, int reset, int update)
+__clsm_enter(WT_CURSOR_LSM *clsm, bool reset, bool update)
{
WT_DECL_RET;
WT_LSM_TREE *lsm_tree;
@@ -295,7 +295,7 @@ static const WT_ITEM __tombstone = { "\x14\x14", 2, 0, NULL, 0 };
* __clsm_deleted --
* Check whether the current value is a tombstone.
*/
-static inline int
+static inline bool
__clsm_deleted(WT_CURSOR_LSM *clsm, const WT_ITEM *item)
{
return (!F_ISSET(clsm, WT_CLSM_MINOR_MERGE) &&
@@ -392,7 +392,7 @@ __clsm_close_cursors(WT_CURSOR_LSM *clsm, u_int start, u_int end)
*/
static int
__clsm_open_cursors(
- WT_CURSOR_LSM *clsm, int update, u_int start_chunk, uint32_t start_id)
+ WT_CURSOR_LSM *clsm, bool update, u_int start_chunk, uint32_t start_id)
{
WT_BTREE *btree;
WT_CURSOR *c, **cp, *primary;
@@ -405,13 +405,13 @@ __clsm_open_cursors(
uint64_t saved_gen;
u_int i, nchunks, ngood, nupdates;
u_int close_range_end, close_range_start;
- int locked;
+ bool locked;
c = &clsm->iface;
session = (WT_SESSION_IMPL *)c->session;
txn = &session->txn;
chunk = NULL;
- locked = 0;
+ locked = false;
lsm_tree = clsm->lsm_tree;
/*
@@ -445,7 +445,7 @@ __clsm_open_cursors(
F_CLR(clsm, WT_CLSM_ITERATE_NEXT | WT_CLSM_ITERATE_PREV);
WT_RET(__wt_lsm_tree_readlock(session, lsm_tree));
- locked = 1;
+ locked = true;
/* Merge cursors have already figured out how many chunks they need. */
retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) {
@@ -562,12 +562,12 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) {
}
if (close_range_end > close_range_start) {
saved_gen = lsm_tree->dsk_gen;
- locked = 0;
+ locked = false;
WT_ERR(__wt_lsm_tree_readunlock(session, lsm_tree));
WT_ERR(__clsm_close_cursors(
clsm, close_range_start, close_range_end));
WT_ERR(__wt_lsm_tree_readlock(session, lsm_tree));
- locked = 1;
+ locked = true;
if (lsm_tree->dsk_gen != saved_gen)
goto retry;
}
@@ -709,7 +709,7 @@ __wt_clsm_init_merge(
clsm->nchunks = nchunks;
WT_WITH_SCHEMA_LOCK(session,
- ret = __clsm_open_cursors(clsm, 0, start_chunk, start_id));
+ ret = __clsm_open_cursors(clsm, false, start_chunk, start_id));
return (ret);
}
@@ -718,15 +718,16 @@ __wt_clsm_init_merge(
* Find the smallest / largest of the cursors and copy its key/value.
*/
static int
-__clsm_get_current(
- WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm, int smallest, int *deletedp)
+__clsm_get_current(WT_SESSION_IMPL *session,
+ WT_CURSOR_LSM *clsm, bool smallest, bool *deletedp)
{
WT_CURSOR *c, *current;
- int cmp, multiple;
+ int cmp;
u_int i;
+ bool multiple;
current = NULL;
- multiple = 0;
+ multiple = false;
WT_FORALL_CURSORS(clsm, c, i) {
if (!F_ISSET(c, WT_CURSTD_KEY_INT))
@@ -738,9 +739,9 @@ __clsm_get_current(
WT_RET(WT_LSM_CURCMP(session, clsm->lsm_tree, c, current, cmp));
if (smallest ? cmp < 0 : cmp > 0) {
current = c;
- multiple = 0;
+ multiple = false;
} else if (cmp == 0)
- multiple = 1;
+ multiple = true;
}
c = &clsm->iface;
@@ -758,7 +759,7 @@ __clsm_get_current(
WT_RET(current->get_value(current, &c->value));
F_CLR(c, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET);
- if ((*deletedp = __clsm_deleted(clsm, &c->value)) == 0)
+ if ((*deletedp = __clsm_deleted(clsm, &c->value)) == false)
F_SET(c, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT);
return (0);
@@ -808,13 +809,14 @@ __clsm_next(WT_CURSOR *cursor)
WT_DECL_RET;
WT_SESSION_IMPL *session;
u_int i;
- int check, cmp, deleted;
+ int cmp;
+ bool check, deleted;
clsm = (WT_CURSOR_LSM *)cursor;
CURSOR_API_CALL(cursor, session, next, NULL);
WT_CURSOR_NOVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 0, 0));
+ WT_ERR(__clsm_enter(clsm, false, false));
/* If we aren't positioned for a forward scan, get started. */
if (clsm->current == NULL || !F_ISSET(clsm, WT_CLSM_ITERATE_NEXT)) {
@@ -852,7 +854,7 @@ retry: /*
* forward.
*/
if (F_ISSET(clsm, WT_CLSM_MULTIPLE)) {
- check = 0;
+ check = false;
WT_FORALL_CURSORS(clsm, c, i) {
if (!F_ISSET(c, WT_CURSTD_KEY_INT))
continue;
@@ -864,7 +866,7 @@ retry: /*
WT_ERR_NOTFOUND_OK(c->next(c));
}
if (c == clsm->current)
- check = 1;
+ check = true;
}
}
@@ -874,7 +876,7 @@ retry: /*
}
/* Find the cursor(s) with the smallest key. */
- if ((ret = __clsm_get_current(session, clsm, 1, &deleted)) == 0 &&
+ if ((ret = __clsm_get_current(session, clsm, true, &deleted)) == 0 &&
deleted)
goto retry;
@@ -897,13 +899,14 @@ __clsm_prev(WT_CURSOR *cursor)
WT_DECL_RET;
WT_SESSION_IMPL *session;
u_int i;
- int check, cmp, deleted;
+ int cmp;
+ bool check, deleted;
clsm = (WT_CURSOR_LSM *)cursor;
CURSOR_API_CALL(cursor, session, prev, NULL);
WT_CURSOR_NOVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 0, 0));
+ WT_ERR(__clsm_enter(clsm, false, false));
/* If we aren't positioned for a reverse scan, get started. */
if (clsm->current == NULL || !F_ISSET(clsm, WT_CLSM_ITERATE_PREV)) {
@@ -940,7 +943,7 @@ retry: /*
* backwards.
*/
if (F_ISSET(clsm, WT_CLSM_MULTIPLE)) {
- check = 0;
+ check = false;
WT_FORALL_CURSORS(clsm, c, i) {
if (!F_ISSET(c, WT_CURSTD_KEY_INT))
continue;
@@ -952,7 +955,7 @@ retry: /*
WT_ERR_NOTFOUND_OK(c->prev(c));
}
if (c == clsm->current)
- check = 1;
+ check = true;
}
}
@@ -962,7 +965,7 @@ retry: /*
}
/* Find the cursor(s) with the largest key. */
- if ((ret = __clsm_get_current(session, clsm, 0, &deleted)) == 0 &&
+ if ((ret = __clsm_get_current(session, clsm, false, &deleted)) == 0 &&
deleted)
goto retry;
@@ -1045,11 +1048,11 @@ __clsm_lookup(WT_CURSOR_LSM *clsm, WT_ITEM *value)
WT_DECL_RET;
WT_SESSION_IMPL *session;
u_int i;
- int have_hash;
+ bool have_hash;
c = NULL;
cursor = &clsm->iface;
- have_hash = 0;
+ have_hash = false;
session = (WT_SESSION_IMPL *)cursor->session;
WT_FORALL_CURSORS(clsm, c, i) {
@@ -1059,7 +1062,7 @@ __clsm_lookup(WT_CURSOR_LSM *clsm, WT_ITEM *value)
if (!have_hash) {
WT_ERR(__wt_bloom_hash(
bloom, &cursor->key, &bhash));
- have_hash = 1;
+ have_hash = true;
}
ret = __wt_bloom_hash_get(bloom, &bhash);
@@ -1121,7 +1124,7 @@ __clsm_search(WT_CURSOR *cursor)
CURSOR_API_CALL(cursor, session, search, NULL);
WT_CURSOR_NEEDKEY(cursor);
WT_CURSOR_NOVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 1, 0));
+ WT_ERR(__clsm_enter(clsm, true, false));
ret = __clsm_lookup(clsm, &cursor->value);
@@ -1144,16 +1147,18 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp)
WT_DECL_RET;
WT_SESSION_IMPL *session;
u_int i;
- int cmp, deleted, exact;
+ int cmp, exact;
+ bool deleted;
closest = NULL;
clsm = (WT_CURSOR_LSM *)cursor;
- deleted = exact = 0;
+ exact = 0;
+ deleted = false;
CURSOR_API_CALL(cursor, session, search_near, NULL);
WT_CURSOR_NEEDKEY(cursor);
WT_CURSOR_NOVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 1, 0));
+ WT_ERR(__clsm_enter(clsm, true, false));
F_CLR(clsm, WT_CLSM_ITERATE_NEXT | WT_CLSM_ITERATE_PREV);
/*
@@ -1222,7 +1227,7 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp)
* end up with WT_NOTFOUND, as expected.
*/
if (closest == NULL)
- deleted = 1;
+ deleted = true;
else {
WT_ERR(closest->get_key(closest, &cursor->key));
WT_ERR(closest->get_value(closest, &cursor->value));
@@ -1244,7 +1249,7 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp)
F_SET(cursor, WT_CURSTD_KEY_INT);
if ((ret = cursor->next(cursor)) == 0) {
cmp = 1;
- deleted = 0;
+ deleted = false;
}
}
WT_ERR_NOTFOUND_OK(ret);
@@ -1276,8 +1281,8 @@ err: __clsm_leave(clsm);
* necessary.
*/
static inline int
-__clsm_put(WT_SESSION_IMPL *session,
- WT_CURSOR_LSM *clsm, const WT_ITEM *key, const WT_ITEM *value, int position)
+__clsm_put(WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm,
+ const WT_ITEM *key, const WT_ITEM *value, bool position)
{
WT_CURSOR *c, *primary;
WT_LSM_TREE *lsm_tree;
@@ -1362,7 +1367,7 @@ __clsm_insert(WT_CURSOR *cursor)
CURSOR_UPDATE_API_CALL(cursor, session, insert, NULL);
WT_CURSOR_NEEDKEY(cursor);
WT_CURSOR_NEEDVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 0, 1));
+ WT_ERR(__clsm_enter(clsm, false, true));
if (!F_ISSET(cursor, WT_CURSTD_OVERWRITE) &&
(ret = __clsm_lookup(clsm, &value)) != WT_NOTFOUND) {
@@ -1372,7 +1377,7 @@ __clsm_insert(WT_CURSOR *cursor)
}
WT_ERR(__clsm_deleted_encode(session, &cursor->value, &value, &buf));
- ret = __clsm_put(session, clsm, &cursor->key, &value, 0);
+ ret = __clsm_put(session, clsm, &cursor->key, &value, false);
err: __wt_scr_free(session, &buf);
__clsm_leave(clsm);
@@ -1398,13 +1403,13 @@ __clsm_update(WT_CURSOR *cursor)
CURSOR_UPDATE_API_CALL(cursor, session, update, NULL);
WT_CURSOR_NEEDKEY(cursor);
WT_CURSOR_NEEDVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 0, 1));
+ WT_ERR(__clsm_enter(clsm, false, true));
if (F_ISSET(cursor, WT_CURSTD_OVERWRITE) ||
(ret = __clsm_lookup(clsm, &value)) == 0) {
WT_ERR(__clsm_deleted_encode(
session, &cursor->value, &value, &buf));
- ret = __clsm_put(session, clsm, &cursor->key, &value, 1);
+ ret = __clsm_put(session, clsm, &cursor->key, &value, true);
}
err: __wt_scr_free(session, &buf);
@@ -1430,11 +1435,12 @@ __clsm_remove(WT_CURSOR *cursor)
CURSOR_UPDATE_API_CALL(cursor, session, remove, NULL);
WT_CURSOR_NEEDKEY(cursor);
WT_CURSOR_NOVALUE(cursor);
- WT_ERR(__clsm_enter(clsm, 0, 1));
+ WT_ERR(__clsm_enter(clsm, false, true));
if (F_ISSET(cursor, WT_CURSTD_OVERWRITE) ||
(ret = __clsm_lookup(clsm, &value)) == 0)
- ret = __clsm_put(session, clsm, &cursor->key, &__tombstone, 1);
+ ret = __clsm_put(
+ session, clsm, &cursor->key, &__tombstone, true);
err: __clsm_leave(clsm);
CURSOR_UPDATE_API_END(session, ret);
@@ -1505,9 +1511,8 @@ __wt_clsm_open(WT_SESSION_IMPL *session,
WT_CURSOR_LSM *clsm;
WT_DECL_RET;
WT_LSM_TREE *lsm_tree;
- int bulk;
+ bool bulk;
- bulk = 0;
clsm = NULL;
cursor = NULL;
lsm_tree = NULL;
@@ -1521,8 +1526,7 @@ __wt_clsm_open(WT_SESSION_IMPL *session,
"LSM does not support opening by checkpoint");
WT_RET(__wt_config_gets_def(session, cfg, "bulk", 0, &cval));
- if (cval.val != 0)
- bulk = 1;
+ bulk = cval.val != 0;
/* Get the LSM tree. */
WT_WITH_HANDLE_LIST_LOCK(session,
diff --git a/src/lsm/lsm_manager.c b/src/lsm/lsm_manager.c
index 2309b55670f..14377f10125 100644
--- a/src/lsm/lsm_manager.c
+++ b/src/lsm/lsm_manager.c
@@ -226,7 +226,7 @@ __wt_lsm_manager_start(WT_SESSION_IMPL *session)
*/
for (i = 0; i < WT_LSM_MAX_WORKERS; i++) {
WT_ERR(__wt_open_internal_session(
- S2C(session), "lsm-worker", 1, 0, &worker_session));
+ S2C(session), "lsm-worker", true, false, &worker_session));
worker_session->isolation = WT_ISO_READ_UNCOMMITTED;
manager->lsm_worker_cookies[i].session = worker_session;
}
@@ -408,10 +408,10 @@ __lsm_manager_run_server(WT_SESSION_IMPL *session)
WT_LSM_TREE *lsm_tree;
struct timespec now;
uint64_t fillms, pushms;
- int dhandle_locked;
+ bool dhandle_locked;
conn = S2C(session);
- dhandle_locked = 0;
+ dhandle_locked = false;
while (F_ISSET(conn, WT_CONN_SERVER_RUN)) {
__wt_sleep(0, 10000);
@@ -419,7 +419,7 @@ __lsm_manager_run_server(WT_SESSION_IMPL *session)
continue;
__wt_spin_lock(session, &conn->dhandle_lock);
F_SET(session, WT_SESSION_LOCKED_HANDLE_LIST);
- dhandle_locked = 1;
+ dhandle_locked = true;
TAILQ_FOREACH(lsm_tree, &S2C(session)->lsmqh, q) {
if (!F_ISSET(lsm_tree, WT_LSM_TREE_ACTIVE))
continue;
@@ -479,7 +479,7 @@ __lsm_manager_run_server(WT_SESSION_IMPL *session)
}
__wt_spin_unlock(session, &conn->dhandle_lock);
F_CLR(session, WT_SESSION_LOCKED_HANDLE_LIST);
- dhandle_locked = 0;
+ dhandle_locked = false;
}
err: if (dhandle_locked) {
diff --git a/src/lsm/lsm_merge.c b/src/lsm/lsm_merge.c
index de7ea37e498..76caf4318fa 100644
--- a/src/lsm/lsm_merge.c
+++ b/src/lsm/lsm_merge.c
@@ -239,21 +239,18 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
WT_LSM_CHUNK *chunk;
uint32_t generation;
uint64_t insert_count, record_count;
- u_int dest_id, end_chunk, i, nchunks, start_chunk, start_id;
- u_int created_chunk, verb;
- int create_bloom, locked, in_sync, tret;
+ u_int dest_id, end_chunk, i, nchunks, start_chunk, start_id, verb;
+ int tret;
+ bool created_chunk, create_bloom, locked, in_sync;
const char *cfg[3];
const char *drop_cfg[] =
{ WT_CONFIG_BASE(session, session_drop), "force", NULL };
bloom = NULL;
chunk = NULL;
- create_bloom = 0;
- created_chunk = 0;
dest = src = NULL;
- locked = 0;
start_id = 0;
- in_sync = 0;
+ created_chunk = create_bloom = locked = in_sync = false;
/* Fast path if it's obvious no merges could be done. */
if (lsm_tree->nchunks < lsm_tree->merge_min &&
@@ -266,7 +263,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
* long time.
*/
WT_RET(__wt_lsm_tree_writelock(session, lsm_tree));
- locked = 1;
+ locked = true;
WT_ERR(__lsm_merge_span(session,
lsm_tree, id, &start_chunk, &end_chunk, &record_count));
@@ -281,7 +278,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
lsm_tree->chunk[start_chunk + i]->generation + 1);
WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree));
- locked = 0;
+ locked = false;
/* Allocate an ID for the merge. */
dest_id = __wt_atomic_add32(&lsm_tree->last, 1);
@@ -304,13 +301,13 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
}
WT_ERR(__wt_calloc_one(session, &chunk));
- created_chunk = 1;
+ created_chunk = true;
chunk->id = dest_id;
if (FLD_ISSET(lsm_tree->bloom, WT_LSM_BLOOM_MERGED) &&
(FLD_ISSET(lsm_tree->bloom, WT_LSM_BLOOM_OLDEST) ||
start_chunk > 0) && record_count > 0)
- create_bloom = 1;
+ create_bloom = true;
/*
* Special setup for the merge cursor:
@@ -376,7 +373,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
* progress.
*/
(void)__wt_atomic_add32(&lsm_tree->merge_syncing, 1);
- in_sync = 1;
+ in_sync = true;
/*
* We've successfully created the new chunk. Now install it. We need
* to ensure that the NO_CACHE flag is cleared and the bloom filter
@@ -427,12 +424,12 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
dest = NULL;
++lsm_tree->merge_progressing;
(void)__wt_atomic_sub32(&lsm_tree->merge_syncing, 1);
- in_sync = 0;
+ in_sync = false;
WT_ERR_NOTFOUND_OK(ret);
WT_ERR(__wt_lsm_tree_set_chunk_size(session, chunk));
WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree));
- locked = 1;
+ locked = true;
/*
* Check whether we raced with another merge, and adjust the chunk
@@ -473,7 +470,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id)
lsm_tree->dsk_gen++;
/* Update the throttling while holding the tree lock. */
- __wt_lsm_tree_throttle(session, lsm_tree, 1);
+ __wt_lsm_tree_throttle(session, lsm_tree, true);
/* Schedule a pass to discard old chunks */
WT_ERR(__wt_lsm_manager_push_entry(
diff --git a/src/lsm/lsm_meta.c b/src/lsm/lsm_meta.c
index e4c95125428..64ca283e2c8 100644
--- a/src/lsm/lsm_meta.c
+++ b/src/lsm/lsm_meta.c
@@ -184,7 +184,7 @@ __wt_lsm_meta_write(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
WT_DECL_RET;
WT_LSM_CHUNK *chunk;
u_int i;
- int first;
+ bool first;
WT_RET(__wt_scr_alloc(session, 0, &buf));
WT_ERR(__wt_buf_fmt(session, buf,
@@ -229,12 +229,12 @@ __wt_lsm_meta_write(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
}
WT_ERR(__wt_buf_catfmt(session, buf, "]"));
WT_ERR(__wt_buf_catfmt(session, buf, ",old_chunks=["));
- first = 1;
+ first = true;
for (i = 0; i < lsm_tree->nold_chunks; i++) {
chunk = lsm_tree->old_chunks[i];
WT_ASSERT(session, chunk != NULL);
if (first)
- first = 0;
+ first = false;
else
WT_ERR(__wt_buf_catfmt(session, buf, ","));
WT_ERR(__wt_buf_catfmt(session, buf, "\"%s\"", chunk->uri));
diff --git a/src/lsm/lsm_stat.c b/src/lsm/lsm_stat.c
index b704226b345..086860fc73a 100644
--- a/src/lsm/lsm_stat.c
+++ b/src/lsm/lsm_stat.c
@@ -23,7 +23,7 @@ __curstat_lsm_init(
WT_LSM_CHUNK *chunk;
WT_LSM_TREE *lsm_tree;
u_int i;
- int locked;
+ bool locked;
char config[64];
const char *cfg[] = {
WT_CONFIG_BASE(session, session_open_cursor), NULL, NULL };
@@ -31,9 +31,9 @@ __curstat_lsm_init(
WT_CONFIG_BASE(session, session_open_cursor),
"checkpoint=" WT_CHECKPOINT, NULL, NULL };
- locked = 0;
+ locked = false;
WT_WITH_HANDLE_LIST_LOCK(session,
- ret = __wt_lsm_tree_get(session, uri, 0, &lsm_tree));
+ ret = __wt_lsm_tree_get(session, uri, false, &lsm_tree));
WT_RET(ret);
WT_ERR(__wt_scr_alloc(session, 0, &uribuf));
@@ -58,7 +58,7 @@ __curstat_lsm_init(
/* Hold the LSM lock so that we can safely walk through the chunks. */
WT_ERR(__wt_lsm_tree_readlock(session, lsm_tree));
- locked = 1;
+ locked = true;
/* Initialize the statistics. */
__wt_stat_init_dsrc_stats(stats);
diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c
index a5709ac97ad..0680d98bdde 100644
--- a/src/lsm/lsm_tree.c
+++ b/src/lsm/lsm_tree.c
@@ -19,7 +19,7 @@ static int __lsm_tree_set_name(WT_SESSION_IMPL *, WT_LSM_TREE *, const char *);
* Free an LSM tree structure.
*/
static int
-__lsm_tree_discard(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int final)
+__lsm_tree_discard(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool final)
{
WT_DECL_RET;
WT_LSM_CHUNK *chunk;
@@ -136,7 +136,7 @@ __wt_lsm_tree_close_all(WT_SESSION_IMPL *session)
*/
(void)__wt_atomic_add32(&lsm_tree->refcnt, 1);
WT_TRET(__lsm_tree_close(session, lsm_tree));
- WT_TRET(__lsm_tree_discard(session, lsm_tree, 1));
+ WT_TRET(__lsm_tree_discard(session, lsm_tree, true));
}
return (ret);
@@ -297,7 +297,7 @@ __wt_lsm_tree_setup_bloom(
*/
int
__wt_lsm_tree_create(WT_SESSION_IMPL *session,
- const char *uri, int exclusive, const char *config)
+ const char *uri, bool exclusive, const char *config)
{
WT_CONFIG_ITEM cval;
WT_DECL_ITEM(buf);
@@ -309,7 +309,7 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session,
/* If the tree is open, it already exists. */
WT_WITH_HANDLE_LIST_LOCK(session,
- ret = __wt_lsm_tree_get(session, uri, 0, &lsm_tree));
+ ret = __wt_lsm_tree_get(session, uri, false, &lsm_tree));
if (ret == 0) {
__wt_lsm_tree_release(session, lsm_tree);
return (exclusive ? EEXIST : 0);
@@ -421,7 +421,7 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session,
WT_ERR(__wt_lsm_meta_write(session, lsm_tree));
/* Discard our partially populated handle. */
- ret = __lsm_tree_discard(session, lsm_tree, 0);
+ ret = __lsm_tree_discard(session, lsm_tree, false);
lsm_tree = NULL;
/*
@@ -436,7 +436,7 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session,
__wt_lsm_tree_release(session, lsm_tree);
if (0) {
-err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0));
+err: WT_TRET(__lsm_tree_discard(session, lsm_tree, false));
}
__wt_scr_free(session, &buf);
return (ret);
@@ -451,7 +451,7 @@ err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0));
*/
static int
__lsm_tree_find(WT_SESSION_IMPL *session,
- const char *uri, int exclusive, WT_LSM_TREE **treep)
+ const char *uri, bool exclusive, WT_LSM_TREE **treep)
{
WT_LSM_TREE *lsm_tree;
@@ -586,7 +586,7 @@ __lsm_tree_open(WT_SESSION_IMPL *session,
* with getting handles exclusive.
*/
lsm_tree->refcnt = 1;
- lsm_tree->exclusive = exclusive;
+ lsm_tree->exclusive = exclusive ? 1 : 0;
lsm_tree->queue_ref = 0;
/* Set a flush timestamp as a baseline. */
@@ -599,7 +599,7 @@ __lsm_tree_open(WT_SESSION_IMPL *session,
*treep = lsm_tree;
if (0) {
-err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0));
+err: WT_TRET(__lsm_tree_discard(session, lsm_tree, false));
}
return (ret);
}
@@ -610,7 +610,7 @@ err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0));
*/
int
__wt_lsm_tree_get(WT_SESSION_IMPL *session,
- const char *uri, int exclusive, WT_LSM_TREE **treep)
+ const char *uri, bool exclusive, WT_LSM_TREE **treep)
{
WT_DECL_RET;
@@ -620,7 +620,8 @@ __wt_lsm_tree_get(WT_SESSION_IMPL *session,
if (ret == WT_NOTFOUND)
ret = __lsm_tree_open(session, uri, exclusive, treep);
- WT_ASSERT(session, ret != 0 || exclusive == (*treep)->exclusive);
+ WT_ASSERT(session, ret != 0 ||
+ (exclusive ? 1 : 0) == (*treep)->exclusive);
return (ret);
}
@@ -664,7 +665,7 @@ __wt_lsm_tree_release(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
*/
void
__wt_lsm_tree_throttle(
- WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int decrease_only)
+ WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool decrease_only)
{
WT_LSM_CHUNK *last_chunk, **cp, *ondisk, *prev_chunk;
uint64_t cache_sz, cache_used, oldtime, record_count, timediff;
@@ -827,7 +828,7 @@ __wt_lsm_tree_switch(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
goto err;
/* Update the throttle time. */
- __wt_lsm_tree_throttle(session, lsm_tree, 0);
+ __wt_lsm_tree_throttle(session, lsm_tree, false);
new_id = __wt_atomic_add32(&lsm_tree->last, 1);
@@ -936,13 +937,13 @@ __wt_lsm_tree_drop(
WT_LSM_CHUNK *chunk;
WT_LSM_TREE *lsm_tree;
u_int i;
- int locked;
+ bool locked;
- locked = 0;
+ locked = false;
/* Get the LSM tree. */
WT_WITH_HANDLE_LIST_LOCK(session,
- ret = __wt_lsm_tree_get(session, name, 1, &lsm_tree));
+ ret = __wt_lsm_tree_get(session, name, true, &lsm_tree));
WT_RET(ret);
/* Shut down the LSM worker. */
@@ -950,7 +951,7 @@ __wt_lsm_tree_drop(
/* Prevent any new opens. */
WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree));
- locked = 1;
+ locked = true;
/* Drop the chunks. */
for (i = 0; i < lsm_tree->nchunks; i++) {
@@ -971,14 +972,14 @@ __wt_lsm_tree_drop(
__wt_schema_drop(session, chunk->bloom_uri, cfg));
}
- locked = 0;
+ locked = false;
WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree));
ret = __wt_metadata_remove(session, name);
err: if (locked)
WT_TRET(__wt_lsm_tree_writeunlock(session, lsm_tree));
WT_WITH_HANDLE_LIST_LOCK(session,
- WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)));
+ WT_TRET(__lsm_tree_discard(session, lsm_tree, false)));
return (ret);
}
@@ -995,14 +996,14 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session,
WT_LSM_TREE *lsm_tree;
const char *old;
u_int i;
- int locked;
+ bool locked;
old = NULL;
- locked = 0;
+ locked = false;
/* Get the LSM tree. */
WT_WITH_HANDLE_LIST_LOCK(session,
- ret = __wt_lsm_tree_get(session, olduri, 1, &lsm_tree));
+ ret = __wt_lsm_tree_get(session, olduri, true, &lsm_tree));
WT_RET(ret);
/* Shut down the LSM worker. */
@@ -1010,7 +1011,7 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session,
/* Prevent any new opens. */
WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree));
- locked = 1;
+ locked = true;
/* Set the new name. */
WT_ERR(__lsm_tree_set_name(session, lsm_tree, newuri));
@@ -1039,7 +1040,7 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session,
}
WT_ERR(__wt_lsm_meta_write(session, lsm_tree));
- locked = 0;
+ locked = false;
WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree));
WT_ERR(__wt_metadata_remove(session, olduri));
@@ -1052,7 +1053,7 @@ err: if (locked)
* tree will create a new one.
*/
WT_WITH_HANDLE_LIST_LOCK(session,
- WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)));
+ WT_TRET(__lsm_tree_discard(session, lsm_tree, false)));
return (ret);
}
@@ -1067,15 +1068,15 @@ __wt_lsm_tree_truncate(
WT_DECL_RET;
WT_LSM_CHUNK *chunk;
WT_LSM_TREE *lsm_tree;
- int locked;
+ bool locked;
WT_UNUSED(cfg);
chunk = NULL;
- locked = 0;
+ locked = false;
/* Get the LSM tree. */
WT_WITH_HANDLE_LIST_LOCK(session,
- ret = __wt_lsm_tree_get(session, name, 1, &lsm_tree));
+ ret = __wt_lsm_tree_get(session, name, true, &lsm_tree));
WT_RET(ret);
/* Shut down the LSM worker. */
@@ -1083,7 +1084,7 @@ __wt_lsm_tree_truncate(
/* Prevent any new opens. */
WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree));
- locked = 1;
+ locked = true;
/* Create the new chunk. */
WT_ERR(__wt_calloc_one(session, &chunk));
@@ -1096,7 +1097,7 @@ __wt_lsm_tree_truncate(
WT_ERR(__wt_lsm_meta_write(session, lsm_tree));
- locked = 0;
+ locked = false;
WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree));
__wt_lsm_tree_release(session, lsm_tree);
@@ -1114,7 +1115,7 @@ err: if (locked)
* in a valid (not truncated) tree.
*/
WT_WITH_HANDLE_LIST_LOCK(session,
- WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)));
+ WT_TRET(__lsm_tree_discard(session, lsm_tree, false)));
}
return (ret);
}
@@ -1198,9 +1199,9 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
time_t begin, end;
uint64_t progress;
uint32_t i;
- int compacting, flushing, locked, ref;
+ bool compacting, flushing, locked, ref;
- compacting = flushing = locked = ref = 0;
+ compacting = flushing = locked = ref = false;
chunk = NULL;
/*
* This function is applied to all matching sources: ignore anything
@@ -1213,7 +1214,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
*skipp = true;
WT_WITH_HANDLE_LIST_LOCK(session,
- ret = __wt_lsm_tree_get(session, name, 0, &lsm_tree));
+ ret = __wt_lsm_tree_get(session, name, false, &lsm_tree));
WT_RET(ret);
if (!F_ISSET(S2C(session), WT_CONN_LSM_MERGE))
@@ -1237,7 +1238,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
/* Lock the tree: single-thread compaction. */
WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree));
- locked = 1;
+ locked = true;
/* Clear any merge throttle: compact throws out that calculation. */
lsm_tree->merge_throttle = 0;
@@ -1262,10 +1263,10 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
* So we need to add a reference to keep it available.
*/
(void)__wt_atomic_add32(&chunk->refcnt, 1);
- ref = 1;
+ ref = true;
}
- locked = 0;
+ locked = false;
WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree));
if (chunk != NULL) {
@@ -1273,7 +1274,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
"Compact force flush %s flags 0x%" PRIx32
" chunk %u flags 0x%"
PRIx32, name, lsm_tree->flags, chunk->id, chunk->flags));
- flushing = 1;
+ flushing = true;
/*
* Make sure the in-memory chunk gets flushed do not push a
* switch, because we don't want to create a new in-memory
@@ -1286,7 +1287,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
* If there is no chunk to flush, go straight to the
* compacting state.
*/
- compacting = 1;
+ compacting = true;
progress = lsm_tree->merge_progressing;
F_SET(lsm_tree, WT_LSM_TREE_COMPACTING);
WT_ERR(__wt_verbose(session, WT_VERB_LSM,
@@ -1310,8 +1311,8 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp)
name, chunk->id,
lsm_tree->merge_progressing));
(void)__wt_atomic_sub32(&chunk->refcnt, 1);
- flushing = ref = 0;
- compacting = 1;
+ flushing = ref = false;
+ compacting = true;
F_SET(lsm_tree, WT_LSM_TREE_COMPACTING);
progress = lsm_tree->merge_progressing;
} else {
@@ -1394,9 +1395,9 @@ __wt_lsm_tree_worker(WT_SESSION_IMPL *session,
WT_LSM_CHUNK *chunk;
WT_LSM_TREE *lsm_tree;
u_int i;
- int exclusive, locked;
+ bool exclusive, locked;
- locked = 0;
+ locked = false;
exclusive = FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE);
WT_WITH_HANDLE_LIST_LOCK(session,
ret = __wt_lsm_tree_get(session, uri, exclusive, &lsm_tree));
@@ -1410,7 +1411,7 @@ __wt_lsm_tree_worker(WT_SESSION_IMPL *session,
WT_ERR(exclusive ?
__wt_lsm_tree_writelock(session, lsm_tree) :
__wt_lsm_tree_readlock(session, lsm_tree));
- locked = 1;
+ locked = true;
for (i = 0; i < lsm_tree->nchunks; i++) {
chunk = lsm_tree->chunk[i];
if (file_func == __wt_checkpoint &&
diff --git a/src/lsm/lsm_work_unit.c b/src/lsm/lsm_work_unit.c
index 08c02467517..72c6cfb9d79 100644
--- a/src/lsm/lsm_work_unit.c
+++ b/src/lsm/lsm_work_unit.c
@@ -19,7 +19,7 @@ static int __lsm_discard_handle(WT_SESSION_IMPL *, const char *, const char *);
*/
static int
__lsm_copy_chunks(WT_SESSION_IMPL *session,
- WT_LSM_TREE *lsm_tree, WT_LSM_WORKER_COOKIE *cookie, int old_chunks)
+ WT_LSM_TREE *lsm_tree, WT_LSM_WORKER_COOKIE *cookie, bool old_chunks)
{
WT_DECL_RET;
u_int i, nchunks;
@@ -68,7 +68,7 @@ err: WT_TRET(__wt_lsm_tree_readunlock(session, lsm_tree));
*/
int
__wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session,
- WT_LSM_TREE *lsm_tree, int force, WT_LSM_CHUNK **chunkp)
+ WT_LSM_TREE *lsm_tree, bool force, WT_LSM_CHUNK **chunkp)
{
WT_DECL_RET;
WT_LSM_CHUNK *chunk, *evict_chunk, *flush_chunk;
@@ -157,14 +157,14 @@ __lsm_unpin_chunks(WT_SESSION_IMPL *session, WT_LSM_WORKER_COOKIE *cookie)
*/
int
__wt_lsm_work_switch(
- WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, int *ran)
+ WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, bool *ran)
{
WT_DECL_RET;
WT_LSM_WORK_UNIT *entry;
/* We've become responsible for freeing the work unit. */
entry = *entryp;
- *ran = 0;
+ *ran = false;
*entryp = NULL;
if (F_ISSET(entry->lsm_tree, WT_LSM_TREE_NEED_SWITCH)) {
@@ -177,7 +177,7 @@ __wt_lsm_work_switch(
WT_LSM_WORK_SWITCH, 0, entry->lsm_tree));
ret = 0;
} else
- *ran = 1;
+ *ran = true;
}
err: __wt_lsm_manager_free_work_unit(session, entry);
return (ret);
@@ -198,7 +198,7 @@ __wt_lsm_work_bloom(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
WT_CLEAR(cookie);
- WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, 0));
+ WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, false));
/* Create bloom filters in all checkpointed chunks. */
merge = 0;
@@ -281,7 +281,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session,
}
/* Stop if a running transaction needs the chunk. */
- __wt_txn_update_oldest(session, 1);
+ __wt_txn_update_oldest(session, true);
if (chunk->switch_txn == WT_TXN_NONE ||
!__wt_txn_visible_all(session, chunk->switch_txn)) {
WT_RET(__wt_verbose(session, WT_VERB_LSM,
@@ -337,7 +337,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session,
++lsm_tree->dsk_gen;
/* Update the throttle time. */
- __wt_lsm_tree_throttle(session, lsm_tree, 1);
+ __wt_lsm_tree_throttle(session, lsm_tree, true);
WT_TRET(__wt_lsm_tree_writeunlock(session, lsm_tree));
if (ret != 0)
@@ -530,9 +530,10 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
WT_LSM_CHUNK *chunk;
WT_LSM_WORKER_COOKIE cookie;
u_int i, skipped;
- int flush_metadata, drop_ret;
+ int drop_ret;
+ bool flush_metadata;
- flush_metadata = 0;
+ flush_metadata = false;
if (lsm_tree->nold_chunks == 0)
return (0);
@@ -554,7 +555,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
* one to keep the non-NULL slots at the beginning of the array.
*/
WT_CLEAR(cookie);
- WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, 1));
+ WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, true));
for (i = skipped = 0; i < cookie.nchunks; i++) {
chunk = cookie.chunk_array[i];
WT_ASSERT(session, chunk != NULL);
@@ -591,7 +592,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
} else if (drop_ret != ENOENT)
WT_ERR(drop_ret);
- flush_metadata = 1;
+ flush_metadata = true;
F_CLR(chunk, WT_LSM_CHUNK_BLOOM);
}
if (chunk->uri != NULL) {
@@ -601,7 +602,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree)
continue;
} else if (drop_ret != ENOENT)
WT_ERR(drop_ret);
- flush_metadata = 1;
+ flush_metadata = true;
}
/* Lock the tree to clear out the old chunk information. */
diff --git a/src/lsm/lsm_worker.c b/src/lsm/lsm_worker.c
index 6346791f905..fcf35261604 100644
--- a/src/lsm/lsm_worker.c
+++ b/src/lsm/lsm_worker.c
@@ -9,7 +9,7 @@
#include "wt_internal.h"
static int __lsm_worker_general_op(
- WT_SESSION_IMPL *, WT_LSM_WORKER_ARGS *, int *);
+ WT_SESSION_IMPL *, WT_LSM_WORKER_ARGS *, bool *);
static WT_THREAD_RET __lsm_worker(void *);
/*
@@ -30,14 +30,14 @@ __wt_lsm_worker_start(WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *args)
*/
static int
__lsm_worker_general_op(
- WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *cookie, int *completed)
+ WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *cookie, bool *completed)
{
WT_DECL_RET;
WT_LSM_CHUNK *chunk;
WT_LSM_WORK_UNIT *entry;
bool force;
- *completed = 0;
+ *completed = false;
/*
* Return if this thread cannot process a bloom, drop or flush.
*/
@@ -72,7 +72,7 @@ __lsm_worker_general_op(
WT_ERR(__wt_lsm_free_chunks(session, entry->lsm_tree));
else if (entry->type == WT_LSM_WORK_BLOOM)
WT_ERR(__wt_lsm_work_bloom(session, entry->lsm_tree));
- *completed = 1;
+ *completed = true;
err: __wt_lsm_manager_free_work_unit(session, entry);
return (ret);
@@ -90,7 +90,7 @@ __lsm_worker(void *arg)
WT_LSM_WORK_UNIT *entry;
WT_LSM_WORKER_ARGS *cookie;
WT_SESSION_IMPL *session;
- int progress, ran;
+ bool progress, ran;
cookie = (WT_LSM_WORKER_ARGS *)arg;
session = cookie->session;
@@ -99,7 +99,7 @@ __lsm_worker(void *arg)
entry = NULL;
while (F_ISSET(conn, WT_CONN_SERVER_RUN) &&
F_ISSET(cookie, WT_LSM_WORKER_RUN)) {
- progress = 0;
+ progress = false;
/*
* Workers process the different LSM work queues. Some workers
@@ -148,7 +148,7 @@ __lsm_worker(void *arg)
__wt_lsm_manager_free_work_unit(session, entry);
entry = NULL;
- progress = 1;
+ progress = true;
}
/* Flag an error if the pop failed. */
WT_ERR(ret);
diff --git a/src/meta/meta_apply.c b/src/meta/meta_apply.c
index 6d08ce3aa6a..053870ba623 100644
--- a/src/meta/meta_apply.c
+++ b/src/meta/meta_apply.c
@@ -46,8 +46,8 @@ __wt_meta_btree_apply(WT_SESSION_IMPL *session,
WT_SAVE_DHANDLE(session,
ret = func(session, cfg));
if (WT_META_TRACKING(session))
- WT_TRET(
- __wt_meta_track_handle_lock(session, 0));
+ WT_TRET(__wt_meta_track_handle_lock(
+ session, false));
else
WT_TRET(__wt_session_release_btree(session));
} else if (ret == EBUSY)
diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c
index 189a095ae74..ff1173585b4 100644
--- a/src/meta/meta_track.c
+++ b/src/meta/meta_track.c
@@ -25,7 +25,7 @@ typedef struct __wt_meta_track {
} op;
char *a, *b; /* Strings */
WT_DATA_HANDLE *dhandle; /* Locked handle */
- int created; /* Handle on newly created file */
+ bool created; /* Handle on newly created file */
} WT_META_TRACK;
/*
@@ -257,7 +257,7 @@ __wt_meta_track_find_handle(
* Turn off metadata operation tracking, unrolling on error.
*/
int
-__wt_meta_track_off(WT_SESSION_IMPL *session, int need_sync, int unroll)
+__wt_meta_track_off(WT_SESSION_IMPL *session, bool need_sync, bool unroll)
{
WT_DECL_RET;
WT_META_TRACK *trk, *trk_orig;
@@ -300,8 +300,8 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int need_sync, int unroll)
/* If we're logging, make sure the metadata update was flushed. */
if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED)) {
WT_WITH_DHANDLE(session, session->meta_dhandle,
- ret = __wt_txn_checkpoint_log(session,
- 0, WT_TXN_LOG_CKPT_SYNC, NULL));
+ ret = __wt_txn_checkpoint_log(
+ session, false, WT_TXN_LOG_CKPT_SYNC, NULL));
WT_RET(ret);
} else {
WT_WITH_DHANDLE(session, session->meta_dhandle,
@@ -460,7 +460,7 @@ __wt_meta_track_drop(
* Track a locked handle.
*/
int
-__wt_meta_track_handle_lock(WT_SESSION_IMPL *session, int created)
+__wt_meta_track_handle_lock(WT_SESSION_IMPL *session, bool created)
{
WT_META_TRACK *trk;
diff --git a/src/os_posix/os_dir.c b/src/os_posix/os_dir.c
index 5bf6e7349fe..9eba641ca51 100644
--- a/src/os_posix/os_dir.c
+++ b/src/os_posix/os_dir.c
@@ -24,7 +24,7 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix,
WT_DECL_RET;
size_t dirallocsz;
u_int count, dirsz;
- int match;
+ bool match;
char **entries, *path;
*dirlist = NULL;
@@ -54,13 +54,13 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix,
if (strcmp(dp->d_name, ".") == 0 ||
strcmp(dp->d_name, "..") == 0)
continue;
- match = 0;
+ match = false;
if (prefix != NULL &&
((LF_ISSET(WT_DIRLIST_INCLUDE) &&
WT_PREFIX_MATCH(dp->d_name, prefix)) ||
(LF_ISSET(WT_DIRLIST_EXCLUDE) &&
!WT_PREFIX_MATCH(dp->d_name, prefix))))
- match = 1;
+ match = true;
if (prefix == NULL || match) {
/*
* We have a file name we want to return.
diff --git a/src/os_posix/os_dlopen.c b/src/os_posix/os_dlopen.c
index a468e7ab49d..2b5fa249163 100644
--- a/src/os_posix/os_dlopen.c
+++ b/src/os_posix/os_dlopen.c
@@ -39,7 +39,7 @@ err: __wt_free(session, dlh->name);
*/
int
__wt_dlsym(WT_SESSION_IMPL *session,
- WT_DLH *dlh, const char *name, int fail, void *sym_ret)
+ WT_DLH *dlh, const char *name, bool fail, void *sym_ret)
{
void *sym;
diff --git a/src/os_posix/os_flock.c b/src/os_posix/os_flock.c
index 69cd367dde3..07393481e7d 100644
--- a/src/os_posix/os_flock.c
+++ b/src/os_posix/os_flock.c
@@ -13,7 +13,7 @@
* Lock/unlock a byte in a file.
*/
int
-__wt_bytelock(WT_FH *fhp, wt_off_t byte, int lock)
+__wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock)
{
struct flock fl;
WT_DECL_RET;
diff --git a/src/os_posix/os_mtx_cond.c b/src/os_posix/os_mtx_cond.c
index baf9b475777..79f9e4959f7 100644
--- a/src/os_posix/os_mtx_cond.c
+++ b/src/os_posix/os_mtx_cond.c
@@ -14,7 +14,7 @@
*/
int
__wt_cond_alloc(WT_SESSION_IMPL *session,
- const char *name, int is_signalled, WT_CONDVAR **condp)
+ const char *name, bool is_signalled, WT_CONDVAR **condp)
{
WT_CONDVAR *cond;
WT_DECL_RET;
@@ -49,9 +49,9 @@ __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs)
{
struct timespec ts;
WT_DECL_RET;
- int locked;
+ bool locked;
- locked = 0;
+ locked = false;
/* Fast path if already signalled. */
if (__wt_atomic_addi32(&cond->waiters, 1) == 0)
@@ -68,7 +68,7 @@ __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs)
}
WT_ERR(pthread_mutex_lock(&cond->mtx));
- locked = 1;
+ locked = true;
if (usecs > 0) {
WT_ERR(__wt_epoch(session, &ts));
@@ -108,9 +108,9 @@ int
__wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond)
{
WT_DECL_RET;
- int locked;
+ bool locked;
- locked = 0;
+ locked = false;
/*
* !!!
@@ -126,7 +126,7 @@ __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond)
if (cond->waiters > 0 || !__wt_atomic_casi32(&cond->waiters, 0, -1)) {
WT_ERR(pthread_mutex_lock(&cond->mtx));
- locked = 1;
+ locked = true;
WT_ERR(pthread_cond_broadcast(&cond->cond));
}
diff --git a/src/os_posix/os_open.c b/src/os_posix/os_open.c
index 5d6ac6942de..dc0e9293fb8 100644
--- a/src/os_posix/os_open.c
+++ b/src/os_posix/os_open.c
@@ -37,11 +37,12 @@ __wt_open(WT_SESSION_IMPL *session,
WT_FH *fh, *tfh;
mode_t mode;
uint64_t bucket, hash;
- int direct_io, f, fd, matched;
+ int f, fd;
+ bool direct_io, matched;
char *path;
conn = S2C(session);
- direct_io = 0;
+ direct_io = false;
fh = NULL;
fd = -1;
path = NULL;
@@ -49,7 +50,7 @@ __wt_open(WT_SESSION_IMPL *session,
WT_RET(__wt_verbose(session, WT_VERB_FILEOPS, "%s: open", name));
/* Increment the reference count if we already have the file open. */
- matched = 0;
+ matched = false;
hash = __wt_hash_city64(name, strlen(name));
bucket = hash % WT_HASH_ARRAY_SIZE;
__wt_spin_lock(session, &conn->fh_lock);
@@ -57,7 +58,7 @@ __wt_open(WT_SESSION_IMPL *session,
if (strcmp(name, tfh->name) == 0) {
++tfh->ref;
*fhp = tfh;
- matched = 1;
+ matched = true;
break;
}
}
@@ -103,7 +104,7 @@ __wt_open(WT_SESSION_IMPL *session,
#ifdef O_DIRECT
if (dio_type && FLD_ISSET(conn->direct_io, dio_type)) {
f |= O_DIRECT;
- direct_io = 1;
+ direct_io = true;
}
#endif
if (dio_type == WT_FILE_TYPE_LOG &&
@@ -165,13 +166,13 @@ setupfh:
* Repeat the check for a match, but then link onto the database's list
* of files.
*/
- matched = 0;
+ matched = false;
__wt_spin_lock(session, &conn->fh_lock);
TAILQ_FOREACH(tfh, &conn->fhhash[bucket], hashq) {
if (strcmp(name, tfh->name) == 0) {
++tfh->ref;
*fhp = tfh;
- matched = 1;
+ matched = true;
break;
}
}
diff --git a/src/os_posix/os_priv.c b/src/os_posix/os_priv.c
index 21549cad957..a8479668d67 100644
--- a/src/os_posix/os_priv.c
+++ b/src/os_posix/os_priv.c
@@ -13,7 +13,7 @@
* Return if the process has special privileges, defined as having
* different effective and read UIDs or GIDs.
*/
-int
+bool
__wt_has_priv(void)
{
return (getuid() != geteuid() || getgid() != getegid());
diff --git a/src/os_win/os_dir.c b/src/os_win/os_dir.c
index 33489bc2497..aff916c25f5 100644
--- a/src/os_win/os_dir.c
+++ b/src/os_win/os_dir.c
@@ -23,7 +23,7 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix,
WT_DECL_RET;
size_t dirallocsz, pathlen;
u_int count, dirsz;
- int match;
+ bool match;
char **entries, *path;
*dirlist = NULL;
@@ -66,13 +66,13 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix,
if (strcmp(finddata.cFileName, ".") == 0 ||
strcmp(finddata.cFileName, "..") == 0)
continue;
- match = 0;
+ match = false;
if (prefix != NULL &&
((LF_ISSET(WT_DIRLIST_INCLUDE) &&
WT_PREFIX_MATCH(finddata.cFileName, prefix)) ||
(LF_ISSET(WT_DIRLIST_EXCLUDE) &&
!WT_PREFIX_MATCH(finddata.cFileName, prefix))))
- match = 1;
+ match = true;
if (prefix == NULL || match) {
/*
* We have a file name we want to return.
diff --git a/src/os_win/os_dlopen.c b/src/os_win/os_dlopen.c
index 0337c7cc368..3b200811aca 100644
--- a/src/os_win/os_dlopen.c
+++ b/src/os_win/os_dlopen.c
@@ -49,7 +49,7 @@ err: __wt_free(session, dlh->name);
*/
int
__wt_dlsym(WT_SESSION_IMPL *session,
- WT_DLH *dlh, const char *name, int fail, void *sym_ret)
+ WT_DLH *dlh, const char *name, bool fail, void *sym_ret)
{
void *sym;
diff --git a/src/os_win/os_flock.c b/src/os_win/os_flock.c
index d551480ba4d..947d7bdcde7 100644
--- a/src/os_win/os_flock.c
+++ b/src/os_win/os_flock.c
@@ -13,7 +13,7 @@
* Lock/unlock a byte in a file.
*/
int
-__wt_bytelock(WT_FH *fhp, wt_off_t byte, int lock)
+__wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock)
{
WT_DECL_RET;
diff --git a/src/os_win/os_mtx_cond.c b/src/os_win/os_mtx_cond.c
index 565928cb863..90aba6b6fad 100644
--- a/src/os_win/os_mtx_cond.c
+++ b/src/os_win/os_mtx_cond.c
@@ -14,7 +14,7 @@
*/
int
__wt_cond_alloc(WT_SESSION_IMPL *session,
- const char *name, int is_signalled, WT_CONDVAR **condp)
+ const char *name, bool is_signalled, WT_CONDVAR **condp)
{
WT_CONDVAR *cond;
@@ -46,9 +46,9 @@ __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs)
DWORD milliseconds;
WT_DECL_RET;
uint64_t milliseconds64;
- int locked;
+ bool locked;
- locked = 0;
+ locked = false;
/* Fast path if already signalled. */
if (__wt_atomic_addi32(&cond->waiters, 1) == 0)
@@ -65,7 +65,7 @@ __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs)
}
EnterCriticalSection(&cond->mtx);
- locked = 1;
+ locked = true;
if (usecs > 0) {
milliseconds64 = usecs / 1000;
@@ -114,9 +114,9 @@ int
__wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond)
{
WT_DECL_RET;
- int locked;
+ bool locked;
- locked = 0;
+ locked = false;
/*
* !!!
@@ -132,7 +132,7 @@ __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond)
if (cond->waiters > 0 || !__wt_atomic_casi32(&cond->waiters, 0, -1)) {
EnterCriticalSection(&cond->mtx);
- locked = 1;
+ locked = true;
WakeAllConditionVariable(&cond->cond);
}
diff --git a/src/os_win/os_open.c b/src/os_win/os_open.c
index 9bdae92774b..c7b30408e63 100644
--- a/src/os_win/os_open.c
+++ b/src/os_win/os_open.c
@@ -22,7 +22,8 @@ __wt_open(WT_SESSION_IMPL *session,
WT_DECL_RET;
WT_FH *fh, *tfh;
uint64_t bucket, hash;
- int direct_io, f, matched, share_mode;
+ int f, share_mode;
+ bool direct_io, matched;
char *path;
conn = S2C(session);
@@ -30,20 +31,20 @@ __wt_open(WT_SESSION_IMPL *session,
path = NULL;
filehandle = INVALID_HANDLE_VALUE;
filehandle_secondary = INVALID_HANDLE_VALUE;
- direct_io = 0;
+ direct_io = false;
hash = __wt_hash_city64(name, strlen(name));
bucket = hash % WT_HASH_ARRAY_SIZE;
WT_RET(__wt_verbose(session, WT_VERB_FILEOPS, "%s: open", name));
/* Increment the reference count if we already have the file open. */
- matched = 0;
+ matched = false;
__wt_spin_lock(session, &conn->fh_lock);
TAILQ_FOREACH(tfh, &conn->fhhash[bucket], hashq)
if (strcmp(name, tfh->name) == 0) {
++tfh->ref;
*fhp = tfh;
- matched = 1;
+ matched = true;
break;
}
__wt_spin_unlock(session, &conn->fh_lock);
@@ -79,7 +80,7 @@ __wt_open(WT_SESSION_IMPL *session,
if (dio_type && FLD_ISSET(conn->direct_io, dio_type)) {
f |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
- direct_io = 1;
+ direct_io = true;
}
if (dio_type == WT_FILE_TYPE_LOG &&
@@ -158,13 +159,13 @@ setupfh:
* Repeat the check for a match, but then link onto the database's list
* of files.
*/
- matched = 0;
+ matched = false;
__wt_spin_lock(session, &conn->fh_lock);
TAILQ_FOREACH(tfh, &conn->fhhash[bucket], hashq)
if (strcmp(name, tfh->name) == 0) {
++tfh->ref;
*fhp = tfh;
- matched = 1;
+ matched = true;
break;
}
if (!matched) {
diff --git a/src/os_win/os_priv.c b/src/os_win/os_priv.c
index b5dc1eb55fe..5c32d6b5999 100644
--- a/src/os_win/os_priv.c
+++ b/src/os_win/os_priv.c
@@ -13,7 +13,7 @@
* Return if the process has special privileges, defined as having
* different effective and read UIDs or GIDs.
*/
-int
+bool
__wt_has_priv(void)
{
return (0);
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 06955c80e4a..1addf1855eb 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -280,13 +280,13 @@ typedef struct {
uint32_t tested_ref_state; /* Debugging information */
} WT_RECONCILE;
-static void __rec_bnd_cleanup(WT_SESSION_IMPL *, WT_RECONCILE *, int);
+static void __rec_bnd_cleanup(WT_SESSION_IMPL *, WT_RECONCILE *, bool);
static void __rec_cell_build_addr(
WT_RECONCILE *, const void *, size_t, u_int, uint64_t);
static int __rec_cell_build_int_key(WT_SESSION_IMPL *,
- WT_RECONCILE *, const void *, size_t, int *);
+ WT_RECONCILE *, const void *, size_t, bool *);
static int __rec_cell_build_leaf_key(WT_SESSION_IMPL *,
- WT_RECONCILE *, const void *, size_t, int *);
+ WT_RECONCILE *, const void *, size_t, bool *);
static int __rec_cell_build_ovfl(WT_SESSION_IMPL *,
WT_RECONCILE *, WT_KV *, uint8_t, uint64_t);
static int __rec_cell_build_val(WT_SESSION_IMPL *,
@@ -299,7 +299,7 @@ static int __rec_col_merge(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *);
static int __rec_col_var(WT_SESSION_IMPL *,
WT_RECONCILE *, WT_PAGE *, WT_SALVAGE_COOKIE *);
static int __rec_col_var_helper(WT_SESSION_IMPL *, WT_RECONCILE *,
- WT_SALVAGE_COOKIE *, WT_ITEM *, int, uint8_t, uint64_t);
+ WT_SALVAGE_COOKIE *, WT_ITEM *, bool, uint8_t, uint64_t);
static int __rec_destroy_session(WT_SESSION_IMPL *);
static int __rec_root_write(WT_SESSION_IMPL *, WT_PAGE *, uint32_t);
static int __rec_row_int(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *);
@@ -315,7 +315,7 @@ static int __rec_split_row(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *);
static int __rec_split_row_promote(
WT_SESSION_IMPL *, WT_RECONCILE *, WT_ITEM *, uint8_t);
static int __rec_split_write(WT_SESSION_IMPL *,
- WT_RECONCILE *, WT_BOUNDARY *, WT_ITEM *, int);
+ WT_RECONCILE *, WT_BOUNDARY *, WT_ITEM *, bool);
static int __rec_write_init(WT_SESSION_IMPL *,
WT_REF *, uint32_t, WT_SALVAGE_COOKIE *, void *);
static int __rec_write_wrapup(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *);
@@ -463,7 +463,7 @@ __wt_reconcile(WT_SESSION_IMPL *session,
* got roped into doing forced eviction, they won't be discarded for the
* life of the session.
*/
- __rec_bnd_cleanup(session, r, 0);
+ __rec_bnd_cleanup(session, r, false);
WT_RET(ret);
@@ -483,7 +483,7 @@ __wt_reconcile(WT_SESSION_IMPL *session,
* checkpoint, it's cleared the tree's dirty flag, and we don't want to
* set it again as part of that walk.
*/
- return (__wt_page_parent_modify_set(session, ref, 1));
+ return (__wt_page_parent_modify_set(session, ref, true));
}
/*
@@ -747,7 +747,7 @@ __rec_destroy(WT_SESSION_IMPL *session, void *reconcilep)
__wt_free(session, r->raw_recnos);
__wt_buf_free(session, &r->raw_destination);
- __rec_bnd_cleanup(session, r, 1);
+ __rec_bnd_cleanup(session, r, true);
__wt_free(session, r->skip);
@@ -777,7 +777,7 @@ __rec_destroy_session(WT_SESSION_IMPL *session)
* Cleanup the boundary structure information.
*/
static void
-__rec_bnd_cleanup(WT_SESSION_IMPL *session, WT_RECONCILE *r, int destroy)
+__rec_bnd_cleanup(WT_SESSION_IMPL *session, WT_RECONCILE *r, bool destroy)
{
WT_BOUNDARY *bnd;
uint32_t i, last_used;
@@ -877,7 +877,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r,
WT_UPDATE *upd, *upd_list, *upd_ovfl;
size_t notused;
uint64_t max_txn, min_txn, txnid;
- int skipped;
+ bool skipped;
*updp = NULL;
@@ -888,7 +888,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r,
* list, else is an on-page row-store WT_UPDATE list.
*/
upd_list = ins == NULL ? WT_ROW_UPDATE(page, rip) : ins->upd;
- skipped = 0;
+ skipped = false;
for (max_txn = WT_TXN_NONE, min_txn = UINT64_MAX, upd = upd_list;
upd != NULL; upd = upd->next) {
@@ -1040,7 +1040,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r,
*/
#define WT_CHILD_RELEASE(session, hazard, ref) do { \
if (hazard) { \
- hazard = 0; \
+ hazard = false; \
WT_TRET( \
__wt_page_release(session, ref, WT_READ_NO_EVICT)); \
} \
@@ -1187,13 +1187,13 @@ __rec_child_deleted(WT_SESSION_IMPL *session,
*/
static int
__rec_child_modify(WT_SESSION_IMPL *session,
- WT_RECONCILE *r, WT_REF *ref, int *hazardp, WT_CHILD_STATE *statep)
+ WT_RECONCILE *r, WT_REF *ref, bool *hazardp, WT_CHILD_STATE *statep)
{
WT_DECL_RET;
WT_PAGE_MODIFY *mod;
/* We may acquire a hazard pointer our caller must release. */
- *hazardp = 0;
+ *hazardp = false;
/* Default to using the original child address. */
*statep = WT_CHILD_ORIGINAL;
@@ -1291,7 +1291,7 @@ __rec_child_modify(WT_SESSION_IMPL *session,
break;
}
WT_RET(ret);
- *hazardp = 1;
+ *hazardp = true;
goto in_memory;
case WT_REF_READING:
@@ -1454,7 +1454,7 @@ __rec_dict_replace(
* Update prefix and suffix compression based on the last key.
*/
static inline void
-__rec_key_state_update(WT_RECONCILE *r, int ovfl_key)
+__rec_key_state_update(WT_RECONCILE *r, bool ovfl_key)
{
WT_ITEM *a;
@@ -2135,7 +2135,7 @@ __rec_split(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len)
dsk->recno = last->recno;
dsk->u.entries = r->entries;
dsk->mem_size = r->dsk.size = WT_PTRDIFF32(r->first_free, dsk);
- WT_RET(__rec_split_write(session, r, last, &r->dsk, 0));
+ WT_RET(__rec_split_write(session, r, last, &r->dsk, false));
/*
* Set the caller's entry count and buffer information for the
@@ -2174,7 +2174,7 @@ __rec_split(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len)
*/
static int
__rec_split_raw_worker(WT_SESSION_IMPL *session,
- WT_RECONCILE *r, size_t next_len, int no_more_rows)
+ WT_RECONCILE *r, size_t next_len, bool no_more_rows)
{
WT_BM *bm;
WT_BOUNDARY *last, *next;
@@ -2189,7 +2189,7 @@ __rec_split_raw_worker(WT_SESSION_IMPL *session,
size_t corrected_page_size, len, result_len;
uint64_t recno;
uint32_t entry, i, result_slots, slots;
- int last_block;
+ bool last_block;
uint8_t *dsk_start;
wt_session = (WT_SESSION *)session;
@@ -2614,7 +2614,7 @@ err: __wt_scr_free(session, &tmp);
static inline int
__rec_split_raw(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len)
{
- return (__rec_split_raw_worker(session, r, next_len, 0));
+ return (__rec_split_raw_worker(session, r, next_len, false));
}
/*
@@ -2677,7 +2677,7 @@ __rec_split_finish_std(WT_SESSION_IMPL *session, WT_RECONCILE *r)
/* If this is a checkpoint, we're done, otherwise write the page. */
return (
__rec_is_checkpoint(r, bnd) ? 0 :
- __rec_split_write(session, r, bnd, &r->dsk, 1));
+ __rec_split_write(session, r, bnd, &r->dsk, true));
}
/*
@@ -2690,7 +2690,7 @@ __rec_split_finish(WT_SESSION_IMPL *session, WT_RECONCILE *r)
/* We're done reconciling - write the final page */
if (r->raw_compression && r->entries != 0) {
while (r->entries != 0)
- WT_RET(__rec_split_raw_worker(session, r, 0, 1));
+ WT_RET(__rec_split_raw_worker(session, r, 0, true));
} else
WT_RET(__rec_split_finish_std(session, r));
@@ -2746,7 +2746,7 @@ __rec_split_fixup(WT_SESSION_IMPL *session, WT_RECONCILE *r)
dsk->u.entries = bnd->entries;
dsk->mem_size =
tmp->size = WT_PAGE_HEADER_BYTE_SIZE(btree) + len;
- WT_ERR(__rec_split_write(session, r, bnd, tmp, 0));
+ WT_ERR(__rec_split_write(session, r, bnd, tmp, false));
}
/*
@@ -2794,7 +2794,7 @@ err: __wt_scr_free(session, &tmp);
*/
static int
__rec_split_write(WT_SESSION_IMPL *session,
- WT_RECONCILE *r, WT_BOUNDARY *bnd, WT_ITEM *buf, int last_block)
+ WT_RECONCILE *r, WT_BOUNDARY *bnd, WT_ITEM *buf, bool last_block)
{
WT_BTREE *btree;
WT_DECL_ITEM(key);
@@ -3078,7 +3078,7 @@ __wt_bulk_insert_row(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk)
WT_CURSOR *cursor;
WT_KV *key, *val;
WT_RECONCILE *r;
- int ovfl_key;
+ bool ovfl_key;
r = cbulk->reconcile;
btree = S2BT(session);
@@ -3281,11 +3281,11 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
WT_KV *val;
WT_PAGE *child;
WT_REF *ref;
- int hazard;
+ bool hazard;
btree = S2BT(session);
child = NULL;
- hazard = 0;
+ hazard = false;
val = &r->v;
vpack = &_vpack;
@@ -3588,7 +3588,7 @@ __rec_col_fix_slvg(WT_SESSION_IMPL *session,
static int
__rec_col_var_helper(WT_SESSION_IMPL *session, WT_RECONCILE *r,
WT_SALVAGE_COOKIE *salvage,
- WT_ITEM *value, int deleted, uint8_t overflow_type, uint64_t rle)
+ WT_ITEM *value, bool deleted, uint8_t overflow_type, uint64_t rle)
{
WT_BTREE *btree;
WT_KV *val;
@@ -3680,7 +3680,7 @@ __rec_col_var(WT_SESSION_IMPL *session,
WT_UPDATE *upd;
uint64_t n, nrepeat, repeat_count, rle, src_recno;
uint32_t i, size;
- int deleted, last_deleted, orig_deleted, update_no_copy;
+ bool deleted, last_deleted, orig_deleted, update_no_copy;
const void *data;
btree = S2BT(session);
@@ -3707,11 +3707,11 @@ __rec_col_var(WT_SESSION_IMPL *session,
* helper function's assistance.)
*/
rle = 0;
- last_deleted = 0;
+ last_deleted = false;
if (salvage != NULL && salvage->missing != 0) {
if (salvage->skip == 0) {
rle = salvage->missing;
- last_deleted = 1;
+ last_deleted = true;
/*
* Correct the number of records we're going to "take",
@@ -3719,8 +3719,8 @@ __rec_col_var(WT_SESSION_IMPL *session,
*/
salvage->take += salvage->missing;
} else
- WT_ERR(__rec_col_var_helper(
- session, r, NULL, NULL, 1, 0, salvage->missing));
+ WT_ERR(__rec_col_var_helper(session,
+ r, NULL, NULL, true, false, salvage->missing));
}
/*
@@ -3742,7 +3742,7 @@ __rec_col_var(WT_SESSION_IMPL *session,
if ((cell = WT_COL_PTR(page, cip)) == NULL) {
nrepeat = 1;
ins = NULL;
- orig_deleted = 1;
+ orig_deleted = true;
} else {
__wt_cell_unpack(cell, vpack);
nrepeat = __wt_cell_rle(vpack);
@@ -3752,7 +3752,7 @@ __rec_col_var(WT_SESSION_IMPL *session,
* If the original value is "deleted", there's no value
* to compare, we're done.
*/
- orig_deleted = vpack->type == WT_CELL_DEL ? 1 : 0;
+ orig_deleted = vpack->type == WT_CELL_DEL;
if (orig_deleted)
goto record_loop;
@@ -3805,7 +3805,7 @@ record_loop: /*
ins = WT_SKIP_NEXT(ins);
}
if (upd != NULL) {
- update_no_copy = 1; /* No data copy */
+ update_no_copy = true; /* No data copy */
repeat_count = 1; /* Single record */
deleted = WT_UPDATE_DELETED_ISSET(upd);
@@ -3814,10 +3814,10 @@ record_loop: /*
size = upd->size;
}
} else if (vpack->raw == WT_CELL_VALUE_OVFL_RM) {
- update_no_copy = 1; /* No data copy */
+ update_no_copy = true; /* No data copy */
repeat_count = 1; /* Single record */
- deleted = 0;
+ deleted = false;
/*
* If doing update save and restore, there's an
@@ -3846,7 +3846,7 @@ record_loop: /*
data = "@";
size = 1;
} else {
- update_no_copy = 0; /* Maybe data copy */
+ update_no_copy = false; /* Maybe data copy */
/*
* The repeat count is the number of records up
@@ -3890,7 +3890,7 @@ record_loop: /*
last->data = vpack->data;
last->size = vpack->size;
WT_ERR(__rec_col_var_helper(
- session, r, salvage, last, 0,
+ session, r, salvage, last, false,
WT_CELL_VALUE_OVFL, repeat_count));
/* Track if page has overflow items. */
@@ -3996,7 +3996,7 @@ compare: /*
* gaps in the name space.
*/
if (src_recno < n)
- deleted = 1;
+ deleted = true;
else {
deleted = WT_UPDATE_DELETED_ISSET(upd);
if (!deleted) {
@@ -4068,12 +4068,12 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
WT_REF *ref;
size_t size;
u_int vtype;
- int hazard, key_onpage_ovfl, ovfl_key;
+ bool hazard, key_onpage_ovfl, ovfl_key;
const void *p;
btree = S2BT(session);
child = NULL;
- hazard = 0;
+ hazard = false;
key = &r->k;
kpack = &_kpack;
@@ -4116,7 +4116,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
ikey = __wt_ref_key_instantiated(ref);
if (ikey == NULL || ikey->cell_offset == 0) {
cell = NULL;
- key_onpage_ovfl = 0;
+ key_onpage_ovfl = false;
} else {
cell = WT_PAGE_REF_OFFSET(page, ikey->cell_offset);
__wt_cell_unpack(cell, kpack);
@@ -4231,7 +4231,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
key->buf.size = __wt_cell_total_len(kpack);
key->cell_len = 0;
key->len = key->buf.size;
- ovfl_key = 1;
+ ovfl_key = true;
} else {
__wt_ref_key(page, ref, &p, &size);
WT_ERR(__rec_cell_build_int_key(
@@ -4254,7 +4254,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
if (key_onpage_ovfl) {
WT_ERR(__wt_buf_set(session, r->cur,
WT_IKEY_DATA(ikey), ikey->size));
- key_onpage_ovfl = 0;
+ key_onpage_ovfl = false;
}
WT_ERR(__rec_split(
session, r, key->len + val->len));
@@ -4288,7 +4288,7 @@ __rec_row_merge(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
WT_MULTI *multi;
WT_PAGE_MODIFY *mod;
uint32_t i;
- int ovfl_key;
+ bool ovfl_key;
mod = page->modify;
@@ -4346,7 +4346,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session,
size_t size;
uint64_t slvg_skip;
uint32_t i;
- int dictionary, key_onpage_ovfl, ovfl_key;
+ bool dictionary, key_onpage_ovfl, ovfl_key;
const void *p;
void *copy;
@@ -4414,7 +4414,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session,
WT_ERR(__rec_txn_read(session, r, NULL, rip, vpack, &upd));
/* Build value cell. */
- dictionary = 0;
+ dictionary = false;
if (upd == NULL) {
/*
* When the page was read into memory, there may not
@@ -4443,7 +4443,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session,
}
WT_ERR(__rec_cell_build_val(
session, r, p, size, (uint64_t)0));
- dictionary = 1;
+ dictionary = true;
} else if (vpack->raw == WT_CELL_VALUE_OVFL_RM) {
/*
* If doing update save and restore in service
@@ -4565,7 +4565,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session,
WT_ERR(__rec_cell_build_val(session, r,
WT_UPDATE_DATA(upd), upd->size,
(uint64_t)0));
- dictionary = 1;
+ dictionary = true;
}
}
@@ -4582,7 +4582,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session,
key->buf.size = __wt_cell_total_len(kpack);
key->cell_len = 0;
key->len = key->buf.size;
- ovfl_key = 1;
+ ovfl_key = true;
/*
* We aren't creating a key so we can't use this key as
@@ -4655,7 +4655,7 @@ build:
if (key_onpage_ovfl) {
WT_ERR(__wt_dsk_cell_data_ref(session,
WT_PAGE_ROW_LEAF, kpack, r->cur));
- key_onpage_ovfl = 0;
+ key_onpage_ovfl = false;
}
/*
@@ -4715,7 +4715,7 @@ __rec_row_leaf_insert(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins)
WT_BTREE *btree;
WT_KV *key, *val;
WT_UPDATE *upd;
- int ovfl_key;
+ bool ovfl_key;
btree = S2BT(session);
@@ -5272,12 +5272,12 @@ __rec_split_col(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page)
*/
static int
__rec_cell_build_int_key(WT_SESSION_IMPL *session,
- WT_RECONCILE *r, const void *data, size_t size, int *is_ovflp)
+ WT_RECONCILE *r, const void *data, size_t size, bool *is_ovflp)
{
WT_BTREE *btree;
WT_KV *key;
- *is_ovflp = 0;
+ *is_ovflp = false;
btree = S2BT(session);
@@ -5291,7 +5291,7 @@ __rec_cell_build_int_key(WT_SESSION_IMPL *session,
if (size > btree->maxintlkey) {
WT_STAT_FAST_DATA_INCR(session, rec_overflow_key_internal);
- *is_ovflp = 1;
+ *is_ovflp = true;
return (__rec_cell_build_ovfl(
session, r, key, WT_CELL_KEY_OVFL, (uint64_t)0));
}
@@ -5309,7 +5309,7 @@ __rec_cell_build_int_key(WT_SESSION_IMPL *session,
*/
static int
__rec_cell_build_leaf_key(WT_SESSION_IMPL *session,
- WT_RECONCILE *r, const void *data, size_t size, int *is_ovflp)
+ WT_RECONCILE *r, const void *data, size_t size, bool *is_ovflp)
{
WT_BTREE *btree;
WT_KV *key;
@@ -5317,7 +5317,7 @@ __rec_cell_build_leaf_key(WT_SESSION_IMPL *session,
uint8_t pfx;
const uint8_t *a, *b;
- *is_ovflp = 0;
+ *is_ovflp = false;
btree = S2BT(session);
@@ -5391,7 +5391,7 @@ __rec_cell_build_leaf_key(WT_SESSION_IMPL *session,
if (pfx == 0) {
WT_STAT_FAST_DATA_INCR(session, rec_overflow_key_leaf);
- *is_ovflp = 1;
+ *is_ovflp = true;
return (__rec_cell_build_ovfl(
session, r, key, WT_CELL_KEY_OVFL, (uint64_t)0));
}
diff --git a/src/schema/schema_create.c b/src/schema/schema_create.c
index 80e443d8a21..28b1e2473ed 100644
--- a/src/schema/schema_create.c
+++ b/src/schema/schema_create.c
@@ -54,12 +54,12 @@ __wt_direct_io_size_check(WT_SESSION_IMPL *session,
*/
static int
__create_file(WT_SESSION_IMPL *session,
- const char *uri, int exclusive, const char *config)
+ const char *uri, bool exclusive, const char *config)
{
WT_DECL_ITEM(val);
WT_DECL_RET;
uint32_t allocsize;
- int is_metadata;
+ bool is_metadata;
const char *filename, **p, *filecfg[] =
{ WT_CONFIG_BASE(session, file_meta), config, NULL, NULL };
char *fileconf;
@@ -119,7 +119,7 @@ __create_file(WT_SESSION_IMPL *session,
WT_ERR(__wt_session_get_btree(
session, uri, NULL, NULL, WT_DHANDLE_EXCLUSIVE));
if (WT_META_TRACKING(session))
- WT_ERR(__wt_meta_track_handle_lock(session, 1));
+ WT_ERR(__wt_meta_track_handle_lock(session, true));
else
WT_ERR(__wt_session_release_btree(session));
@@ -170,7 +170,7 @@ __wt_schema_colgroup_source(WT_SESSION_IMPL *session,
*/
static int
__create_colgroup(WT_SESSION_IMPL *session,
- const char *name, int exclusive, const char *config)
+ const char *name, bool exclusive, const char *config)
{
WT_CONFIG_ITEM cval;
WT_DECL_RET;
@@ -199,7 +199,7 @@ __create_colgroup(WT_SESSION_IMPL *session,
tlen = strlen(tablename);
if ((ret =
- __wt_schema_get_table(session, tablename, tlen, 1, &table)) != 0)
+ __wt_schema_get_table(session, tablename, tlen, true, &table)) != 0)
WT_RET_MSG(session, (ret == WT_NOTFOUND) ? ENOENT : ret,
"Can't create '%s' for non-existent table '%.*s'",
name, (int)tlen, tablename);
@@ -241,7 +241,7 @@ __create_colgroup(WT_SESSION_IMPL *session,
"No 'columns' configuration for '%s'", name);
WT_ERR(__wt_buf_catfmt(session, &fmt, ",value_format="));
WT_ERR(__wt_struct_reformat(session,
- table, cval.str, cval.len, NULL, 1, &fmt));
+ table, cval.str, cval.len, NULL, true, &fmt));
}
sourcecfg[1] = fmt.data;
WT_ERR(__wt_config_concat(session, sourcecfg, &sourceconf));
@@ -310,7 +310,7 @@ __wt_schema_index_source(WT_SESSION_IMPL *session,
*/
static int
__create_index(WT_SESSION_IMPL *session,
- const char *name, int exclusive, const char *config)
+ const char *name, bool exclusive, const char *config)
{
WT_CONFIG kcols, pkcols;
WT_CONFIG_ITEM ckey, cval, icols, kval;
@@ -325,7 +325,7 @@ __create_index(WT_SESSION_IMPL *session,
const char *source, *idxname, *tablename;
char *sourceconf, *idxconf;
size_t tlen;
- int have_extractor;
+ bool have_extractor;
u_int i, npublic_cols;
idxconf = sourceconf = NULL;
@@ -333,7 +333,7 @@ __create_index(WT_SESSION_IMPL *session,
WT_CLEAR(fmt);
WT_CLEAR(extra_cols);
WT_CLEAR(namebuf);
- have_extractor = 0;
+ have_extractor = false;
tablename = name;
if (!WT_PREFIX_SKIP(tablename, "index:"))
@@ -345,7 +345,7 @@ __create_index(WT_SESSION_IMPL *session,
tlen = (size_t)(idxname++ - tablename);
if ((ret =
- __wt_schema_get_table(session, tablename, tlen, 1, &table)) != 0)
+ __wt_schema_get_table(session, tablename, tlen, true, &table)) != 0)
WT_RET_MSG(session, ret,
"Can't create an index for a non-existent table: %.*s",
(int)tlen, tablename);
@@ -370,7 +370,7 @@ __create_index(WT_SESSION_IMPL *session,
if (__wt_config_getones_none(
session, config, "extractor", &cval) == 0 && cval.len != 0) {
- have_extractor = 1;
+ have_extractor = true;
/* Custom extractors must supply a key format. */
if ((ret = __wt_config_getones(
session, config, "key_format", &kval)) != 0)
@@ -445,7 +445,7 @@ __create_index(WT_SESSION_IMPL *session,
* for custom extractors.
*/
WT_ERR(__wt_struct_reformat(session, table,
- icols.str, icols.len, (const char *)extra_cols.data, 0, &fmt));
+ icols.str, icols.len, (const char *)extra_cols.data, false, &fmt));
/* Check for a record number index key, which makes no sense. */
WT_ERR(__wt_config_getones(session, fmt.data, "key_format", &cval));
@@ -492,7 +492,7 @@ err: __wt_free(session, idxconf);
*/
static int
__create_table(WT_SESSION_IMPL *session,
- const char *name, int exclusive, const char *config)
+ const char *name, bool exclusive, const char *config)
{
WT_CONFIG conf;
WT_CONFIG_ITEM cgkey, cgval, cval;
@@ -514,7 +514,7 @@ __create_table(WT_SESSION_IMPL *session,
return (EINVAL);
if ((ret = __wt_schema_get_table(session,
- tablename, strlen(tablename), 0, &table)) == 0) {
+ tablename, strlen(tablename), false, &table)) == 0) {
__wt_schema_release_table(session, table);
return (exclusive ? EEXIST : 0);
}
@@ -541,7 +541,7 @@ __create_table(WT_SESSION_IMPL *session,
/* Attempt to open the table now to catch any errors. */
WT_ERR(__wt_schema_get_table(
- session, tablename, strlen(tablename), 1, &table));
+ session, tablename, strlen(tablename), true, &table));
if (ncolgroups == 0) {
cgsize = strlen("colgroup:") + strlen(tablename) + 1;
@@ -607,11 +607,11 @@ __wt_schema_create(
WT_CONFIG_ITEM cval;
WT_DATA_SOURCE *dsrc;
WT_DECL_RET;
- int exclusive;
+ bool exclusive;
- exclusive = (
+ exclusive =
__wt_config_getones(session, config, "exclusive", &cval) == 0 &&
- cval.val != 0);
+ cval.val != 0;
/*
* We track create operations: if we fail in the middle of creating a
@@ -637,7 +637,7 @@ __wt_schema_create(
ret = __wt_bad_object_type(session, uri);
session->dhandle = NULL;
- WT_TRET(__wt_meta_track_off(session, 1, ret != 0));
+ WT_TRET(__wt_meta_track_off(session, true, ret != 0));
return (ret);
}
diff --git a/src/schema/schema_drop.c b/src/schema/schema_drop.c
index 27d0a2bb614..9b9f3a23961 100644
--- a/src/schema/schema_drop.c
+++ b/src/schema/schema_drop.c
@@ -18,11 +18,11 @@ __drop_file(
{
WT_CONFIG_ITEM cval;
WT_DECL_RET;
- int remove_files;
+ bool remove_files;
const char *filename;
WT_RET(__wt_config_gets(session, cfg, "remove_files", &cval));
- remove_files = (cval.val != 0);
+ remove_files = cval.val != 0;
filename = uri;
if (!WT_PREFIX_SKIP(filename, "file:"))
@@ -64,7 +64,7 @@ __drop_colgroup(
/* If we can get the colgroup, detach it from the table. */
if ((ret = __wt_schema_get_colgroup(
session, uri, force, &table, &colgroup)) == 0) {
- table->cg_complete = 0;
+ table->cg_complete = false;
WT_TRET(__wt_schema_drop(session, colgroup->source, cfg));
}
@@ -87,7 +87,7 @@ __drop_index(
/* If we can get the colgroup, detach it from the table. */
if ((ret = __wt_schema_get_index(
session, uri, force, &table, &idx)) == 0) {
- table->idx_complete = 0;
+ table->idx_complete = false;
WT_TRET(__wt_schema_drop(session, idx->source, cfg));
}
@@ -113,7 +113,8 @@ __drop_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
(void)WT_PREFIX_SKIP(name, "table:");
table = NULL;
- WT_ERR(__wt_schema_get_table(session, name, strlen(name), 1, &table));
+ WT_ERR(__wt_schema_get_table(
+ session, name, strlen(name), true, &table));
/* Drop the column groups. */
for (i = 0; i < WT_COLGROUPS(table); i++) {
@@ -201,7 +202,7 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[])
/* Bump the schema generation so that stale data is ignored. */
++S2C(session)->schema_gen;
- WT_TRET(__wt_meta_track_off(session, 1, ret != 0));
+ WT_TRET(__wt_meta_track_off(session, true, ret != 0));
return (ret);
}
diff --git a/src/schema/schema_list.c b/src/schema/schema_list.c
index 5ab9f1c160e..3390c950e18 100644
--- a/src/schema/schema_list.c
+++ b/src/schema/schema_list.c
@@ -14,7 +14,7 @@
*/
static int
__schema_add_table(WT_SESSION_IMPL *session,
- const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep)
+ const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep)
{
WT_DECL_RET;
WT_TABLE *table;
@@ -86,7 +86,7 @@ restart:
*/
int
__wt_schema_get_table(WT_SESSION_IMPL *session,
- const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep)
+ const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep)
{
WT_DECL_RET;
WT_TABLE *table;
diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c
index 2b645d5c666..b50ab566d08 100644
--- a/src/schema/schema_open.c
+++ b/src/schema/schema_open.c
@@ -107,12 +107,12 @@ __wt_schema_open_colgroups(WT_SESSION_IMPL *session, WT_TABLE *table)
WT_ERR(__wt_buf_init(session, buf, 0));
WT_ERR(__wt_struct_plan(session,
- table, table->colconf.str, table->colconf.len, 1, buf));
+ table, table->colconf.str, table->colconf.len, true, buf));
WT_ERR(__wt_strndup(
session, buf->data, buf->size, &table->plan));
}
- table->cg_complete = 1;
+ table->cg_complete = true;
err: __wt_scr_free(session, &buf);
if (colgroup != NULL)
@@ -231,7 +231,8 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx)
goto err;
WT_ERR(__wt_scr_alloc(session, 0, &plan));
- WT_ERR(__wt_struct_plan(session, table, buf->data, buf->size, 0, plan));
+ WT_ERR(__wt_struct_plan(
+ session, table, buf->data, buf->size, false, plan));
WT_ERR(__wt_strndup(session, plan->data, plan->size, &idx->key_plan));
/* Set up the cursor key format (the visible columns). */
@@ -254,7 +255,7 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx)
/* TODO Optimize to use index columns in preference to table lookups. */
WT_ERR(__wt_buf_init(session, plan, 0));
WT_ERR(__wt_struct_plan(session,
- table, table->colconf.str, table->colconf.len, 1, plan));
+ table, table->colconf.str, table->colconf.len, true, plan));
WT_ERR(__wt_strndup(session, plan->data, plan->size, &idx->value_plan));
err: __wt_scr_free(session, &buf);
@@ -275,7 +276,8 @@ __wt_schema_open_index(WT_SESSION_IMPL *session,
WT_DECL_RET;
WT_INDEX *idx;
u_int i;
- int cmp, match;
+ int cmp;
+ bool match;
const char *idxconf, *name, *tablename, *uri;
/* Check if we've already done the work. */
@@ -284,7 +286,7 @@ __wt_schema_open_index(WT_SESSION_IMPL *session,
cursor = NULL;
idx = NULL;
- match = 0;
+ match = false;
/* Build a search key. */
tablename = table->name;
@@ -365,7 +367,7 @@ __wt_schema_open_index(WT_SESSION_IMPL *session,
/* If we did a full pass, we won't need to do it again. */
if (idxname == NULL) {
table->nindices = i;
- table->idx_complete = 1;
+ table->idx_complete = true;
}
err: __wt_scr_free(session, &tmp);
@@ -392,7 +394,7 @@ __wt_schema_open_indices(WT_SESSION_IMPL *session, WT_TABLE *table)
*/
int
__wt_schema_open_table(WT_SESSION_IMPL *session,
- const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep)
+ const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep)
{
WT_CONFIG cparser;
WT_CONFIG_ITEM ckey, cval;
@@ -440,9 +442,9 @@ __wt_schema_open_table(WT_SESSION_IMPL *session,
* are not named.
*/
WT_ERR(__wt_config_subinit(session, &cparser, &table->colconf));
- table->is_simple = 1;
+ table->is_simple = true;
while ((ret = __wt_config_next(&cparser, &ckey, &cval)) == 0)
- table->is_simple = 0;
+ table->is_simple = false;
if (ret != WT_NOTFOUND)
goto err;
@@ -498,7 +500,7 @@ err: if (table != NULL)
*/
int
__wt_schema_get_colgroup(WT_SESSION_IMPL *session,
- const char *uri, int quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp)
+ const char *uri, bool quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp)
{
WT_COLGROUP *colgroup;
WT_TABLE *table;
@@ -515,7 +517,7 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session,
tend = tablename + strlen(tablename);
WT_RET(__wt_schema_get_table(session,
- tablename, WT_PTRDIFF(tend, tablename), 0, &table));
+ tablename, WT_PTRDIFF(tend, tablename), false, &table));
for (i = 0; i < WT_COLGROUPS(table); i++) {
colgroup = table->cgroups[i];
@@ -541,7 +543,7 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session,
*/
int
__wt_schema_get_index(WT_SESSION_IMPL *session,
- const char *uri, int quiet, WT_TABLE **tablep, WT_INDEX **indexp)
+ const char *uri, bool quiet, WT_TABLE **tablep, WT_INDEX **indexp)
{
WT_DECL_RET;
WT_INDEX *idx;
@@ -557,7 +559,7 @@ __wt_schema_get_index(WT_SESSION_IMPL *session,
return (__wt_bad_object_type(session, uri));
WT_RET(__wt_schema_get_table(session,
- tablename, WT_PTRDIFF(tend, tablename), 0, &table));
+ tablename, WT_PTRDIFF(tend, tablename), false, &table));
/* Try to find the index in the table. */
for (i = 0; i < table->nindices; i++) {
diff --git a/src/schema/schema_plan.c b/src/schema/schema_plan.c
index 918cbe68fcc..066e666190b 100644
--- a/src/schema/schema_plan.c
+++ b/src/schema/schema_plan.c
@@ -21,14 +21,14 @@ __find_next_col(WT_SESSION_IMPL *session, WT_TABLE *table,
WT_CONFIG_ITEM cval, k, v;
WT_DECL_RET;
u_int cg, col, foundcg, foundcol, matchcg, matchcol;
- int getnext;
+ bool getnext;
foundcg = foundcol = UINT_MAX;
matchcg = *cgnump;
matchcol = (*coltype == WT_PROJ_KEY) ?
*colnump : *colnump + table->nkey_columns;
- getnext = 1;
+ getnext = true;
for (colgroup = NULL, cg = 0; cg < WT_COLGROUPS(table); cg++) {
colgroup = table->cgroups[cg];
@@ -53,7 +53,7 @@ cgcols: cval = colgroup->colconf;
foundcg = cg;
foundcol = col;
}
- getnext = (cg == matchcg && col == matchcol);
+ getnext = cg == matchcg && col == matchcol;
}
if (cg == 0 && table->ncolgroups > 0 &&
col == table->nkey_columns - 1)
@@ -174,13 +174,13 @@ __wt_table_check(WT_SESSION_IMPL *session, WT_TABLE *table)
*/
int
__wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table,
- const char *columns, size_t len, int value_only, WT_ITEM *plan)
+ const char *columns, size_t len, bool value_only, WT_ITEM *plan)
{
WT_CONFIG conf;
WT_CONFIG_ITEM k, v;
WT_DECL_RET;
u_int cg, col, current_cg, current_col, i, start_cg, start_col;
- int have_it;
+ bool have_it;
char coltype, current_coltype;
start_cg = start_col = UINT_MAX; /* -Wuninitialized */
@@ -195,7 +195,7 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table,
current_col = col = INT_MAX;
current_coltype = coltype = WT_PROJ_KEY; /* Keep lint quiet. */
for (i = 0; (ret = __wt_config_next(&conf, &k, &v)) == 0; i++) {
- have_it = 0;
+ have_it = false;
while ((ret = __find_next_col(session, table,
&k, &cg, &col, &coltype)) == 0 &&
@@ -242,7 +242,7 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table,
start_cg = cg;
start_col = col;
- have_it = 1;
+ have_it = true;
} else
WT_RET(__wt_buf_catfmt(session,
plan, "%c", WT_PROJ_REUSE));
@@ -272,25 +272,25 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table,
* Find the format of the named column.
*/
static int
-__find_column_format(WT_SESSION_IMPL *session,
- WT_TABLE *table, WT_CONFIG_ITEM *colname, int value_only, WT_PACK_VALUE *pv)
+__find_column_format(WT_SESSION_IMPL *session, WT_TABLE *table,
+ WT_CONFIG_ITEM *colname, bool value_only, WT_PACK_VALUE *pv)
{
WT_CONFIG conf;
WT_CONFIG_ITEM k, v;
WT_DECL_RET;
WT_PACK pack;
- int inkey;
+ bool inkey;
WT_RET(__wt_config_subinit(session, &conf, &table->colconf));
WT_RET(__pack_init(session, &pack, table->key_format));
- inkey = 1;
+ inkey = true;
while ((ret = __wt_config_next(&conf, &k, &v)) == 0) {
if ((ret = __pack_next(&pack, pv)) == WT_NOTFOUND && inkey) {
ret = __pack_init(session, &pack, table->value_format);
if (ret == 0)
ret = __pack_next(&pack, pv);
- inkey = 0;
+ inkey = false;
}
if (ret != 0)
return (ret);
@@ -314,14 +314,14 @@ __find_column_format(WT_SESSION_IMPL *session,
*/
int
__wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table,
- const char *columns, size_t len, const char *extra_cols, int value_only,
+ const char *columns, size_t len, const char *extra_cols, bool value_only,
WT_ITEM *format)
{
WT_CONFIG config;
WT_CONFIG_ITEM k, next_k, next_v;
WT_DECL_PACK_VALUE(pv);
WT_DECL_RET;
- int have_next;
+ bool have_next;
WT_RET(__wt_config_initn(session, &config, columns, len));
/*
@@ -344,12 +344,12 @@ __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table,
ret = __wt_config_next(&config, &next_k, &next_v);
if (ret != 0 && ret != WT_NOTFOUND)
return (ret);
- have_next = (ret == 0);
+ have_next = ret == 0;
if (!have_next && extra_cols != NULL) {
WT_RET(__wt_config_init(session, &config, extra_cols));
WT_RET(__wt_config_next(&config, &next_k, &next_v));
- have_next = 1;
+ have_next = true;
extra_cols = NULL;
}
diff --git a/src/schema/schema_rename.c b/src/schema/schema_rename.c
index f75b68037af..8a347f2c39f 100644
--- a/src/schema/schema_rename.c
+++ b/src/schema/schema_rename.c
@@ -87,9 +87,9 @@ __rename_tree(WT_SESSION_IMPL *session,
WT_DECL_ITEM(nv);
WT_DECL_ITEM(os);
WT_DECL_RET;
+ bool is_colgroup;
const char *newname, *olduri, *suffix;
char *value;
- int is_colgroup;
olduri = table->name;
value = NULL;
@@ -211,7 +211,7 @@ __rename_table(WT_SESSION_IMPL *session,
(void)WT_PREFIX_SKIP(oldname, "table:");
WT_RET(__wt_schema_get_table(
- session, oldname, strlen(oldname), 0, &table));
+ session, oldname, strlen(oldname), false, &table));
/* Rename the column groups. */
for (i = 0; i < WT_COLGROUPS(table); i++)
@@ -277,7 +277,7 @@ __wt_schema_rename(WT_SESSION_IMPL *session,
/* Bump the schema generation so that stale data is ignored. */
++S2C(session)->schema_gen;
- WT_TRET(__wt_meta_track_off(session, 1, ret != 0));
+ WT_TRET(__wt_meta_track_off(session, true, ret != 0));
/* If we didn't find a metadata entry, map that error to ENOENT. */
return (ret == WT_NOTFOUND ? ENOENT : ret);
diff --git a/src/schema/schema_stat.c b/src/schema/schema_stat.c
index dea797f823d..df8e23eb604 100644
--- a/src/schema/schema_stat.c
+++ b/src/schema/schema_stat.c
@@ -20,7 +20,7 @@ __wt_curstat_colgroup_init(WT_SESSION_IMPL *session,
WT_DECL_ITEM(buf);
WT_DECL_RET;
- WT_RET(__wt_schema_get_colgroup(session, uri, 0, NULL, &colgroup));
+ WT_RET(__wt_schema_get_colgroup(session, uri, false, NULL, &colgroup));
WT_RET(__wt_scr_alloc(session, 0, &buf));
WT_ERR(__wt_buf_fmt(session, buf, "statistics:%s", colgroup->source));
@@ -42,7 +42,7 @@ __wt_curstat_index_init(WT_SESSION_IMPL *session,
WT_DECL_RET;
WT_INDEX *idx;
- WT_RET(__wt_schema_get_index(session, uri, 0, NULL, &idx));
+ WT_RET(__wt_schema_get_index(session, uri, false, NULL, &idx));
WT_RET(__wt_scr_alloc(session, 0, &buf));
WT_ERR(__wt_buf_fmt(session, buf, "statistics:%s", idx->source));
@@ -69,7 +69,8 @@ __wt_curstat_table_init(WT_SESSION_IMPL *session,
const char *name;
name = uri + strlen("table:");
- WT_RET(__wt_schema_get_table(session, name, strlen(name), 0, &table));
+ WT_RET(__wt_schema_get_table(
+ session, name, strlen(name), false, &table));
WT_ERR(__wt_scr_alloc(session, 0, &buf));
diff --git a/src/schema/schema_truncate.c b/src/schema/schema_truncate.c
index 3f2d080284c..4e9180cfe8f 100644
--- a/src/schema/schema_truncate.c
+++ b/src/schema/schema_truncate.c
@@ -55,7 +55,8 @@ __truncate_table(WT_SESSION_IMPL *session, const char *name, const char *cfg[])
WT_TABLE *table;
u_int i;
- WT_RET(__wt_schema_get_table(session, name, strlen(name), 0, &table));
+ WT_RET(
+ __wt_schema_get_table(session, name, strlen(name), false, &table));
/* Truncate the column groups. */
for (i = 0; i < WT_COLGROUPS(table); i++)
diff --git a/src/schema/schema_worker.c b/src/schema/schema_worker.c
index 5bc67d1ae76..e429327973e 100644
--- a/src/schema/schema_worker.c
+++ b/src/schema/schema_worker.c
@@ -69,12 +69,12 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
}
} else if (WT_PREFIX_MATCH(uri, "colgroup:")) {
WT_ERR(__wt_schema_get_colgroup(
- session, uri, 0, NULL, &colgroup));
+ session, uri, false, NULL, &colgroup));
WT_ERR(__wt_schema_worker(session,
colgroup->source, file_func, name_func, cfg, open_flags));
} else if (WT_PREFIX_SKIP(tablename, "index:")) {
idx = NULL;
- WT_ERR(__wt_schema_get_index(session, uri, 0, NULL, &idx));
+ WT_ERR(__wt_schema_get_index(session, uri, false, NULL, &idx));
WT_ERR(__wt_schema_worker(session, idx->source,
file_func, name_func, cfg, open_flags));
} else if (WT_PREFIX_MATCH(uri, "lsm:")) {
@@ -87,7 +87,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
uri, file_func, name_func, cfg, open_flags));
} else if (WT_PREFIX_SKIP(tablename, "table:")) {
WT_ERR(__wt_schema_get_table(session,
- tablename, strlen(tablename), 0, &table));
+ tablename, strlen(tablename), false, &table));
WT_ASSERT(session, session->dhandle == NULL);
/*
@@ -98,7 +98,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
*/
for (i = 0; i < WT_COLGROUPS(table); i++) {
colgroup = table->cgroups[i];
- skip = 0;
+ skip = false;
if (name_func != NULL)
WT_ERR(name_func(
session, colgroup->name, &skip));
@@ -111,7 +111,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session,
WT_ERR(__wt_schema_open_indices(session, table));
for (i = 0; i < table->nindices; i++) {
idx = table->indices[i];
- skip = 0;
+ skip = false;
if (name_func != NULL)
WT_ERR(name_func(session, idx->name, &skip));
if (!skip)
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 2773b31ce1e..f71ff8ea71c 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -246,7 +246,7 @@ __wt_open_cursor(WT_SESSION_IMPL *session,
* the underlying data source.
*/
WT_RET(__wt_schema_get_colgroup(
- session, uri, 0, NULL, &colgroup));
+ session, uri, false, NULL, &colgroup));
WT_RET(__wt_open_cursor(
session, colgroup->source, owner, cfg, cursorp));
} else if (WT_PREFIX_MATCH(uri, "config:"))
@@ -602,9 +602,10 @@ __session_truncate(WT_SESSION *wt_session,
WT_DECL_RET;
WT_SESSION_IMPL *session;
WT_CURSOR *cursor;
- int cmp, local_start;
+ int cmp;
+ bool local_start;
- local_start = 0;
+ local_start = false;
session = (WT_SESSION_IMPL *)wt_session;
SESSION_TXN_API_CALL(session, truncate, config, cfg);
@@ -708,7 +709,7 @@ __session_truncate(WT_SESSION *wt_session,
if (start == NULL) {
WT_ERR(__session_open_cursor(
wt_session, stop->uri, NULL, NULL, &start));
- local_start = 1;
+ local_start = true;
WT_ERR(start->next(start));
}
@@ -982,7 +983,7 @@ __session_strerror(WT_SESSION *wt_session, int error)
*/
int
__wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name,
- int uses_dhandles, int open_metadata, WT_SESSION_IMPL **sessionp)
+ bool uses_dhandles, bool open_metadata, WT_SESSION_IMPL **sessionp)
{
WT_SESSION_IMPL *session;
@@ -1097,7 +1098,7 @@ __wt_open_session(WT_CONNECTION_IMPL *conn,
session_ret->iface = stds;
session_ret->iface.connection = &conn->iface;
- WT_ERR(__wt_cond_alloc(session, "session", 0, &session_ret->cond));
+ WT_ERR(__wt_cond_alloc(session, "session", false, &session_ret->cond));
if (WT_SESSION_FIRST_USE(session_ret))
__wt_random_init(&session_ret->rnd);
diff --git a/src/session/session_dhandle.c b/src/session/session_dhandle.c
index 76b2ac06ebc..63635b54032 100644
--- a/src/session/session_dhandle.c
+++ b/src/session/session_dhandle.c
@@ -248,10 +248,10 @@ __wt_session_get_btree_ckpt(WT_SESSION_IMPL *session,
{
WT_CONFIG_ITEM cval;
WT_DECL_RET;
- int last_ckpt;
+ bool last_ckpt;
const char *checkpoint;
- last_ckpt = 0;
+ last_ckpt = false;
checkpoint = NULL;
/*
@@ -266,7 +266,7 @@ __wt_session_get_btree_ckpt(WT_SESSION_IMPL *session,
* unnamed checkpoint of the object.
*/
if (WT_STRING_MATCH(WT_CHECKPOINT, cval.str, cval.len)) {
- last_ckpt = 1;
+ last_ckpt = true;
retry: WT_RET(__wt_meta_checkpoint_last_name(
session, uri, &checkpoint));
} else
@@ -514,7 +514,7 @@ __wt_session_lock_checkpoint(WT_SESSION_IMPL *session, const char *checkpoint)
dhandle = session->dhandle;
F_SET(dhandle, WT_DHANDLE_DISCARD);
- WT_ERR(__wt_meta_track_handle_lock(session, 0));
+ WT_ERR(__wt_meta_track_handle_lock(session, false));
/* Restore the original btree in the session. */
err: session->dhandle = saved_dhandle;
diff --git a/src/support/err.c b/src/support/err.c
index fc6569cb81e..59a0a0ebd6b 100644
--- a/src/support/err.c
+++ b/src/support/err.c
@@ -91,7 +91,7 @@ static WT_EVENT_HANDLER __event_handler_default = {
*/
static void
__handler_failure(WT_SESSION_IMPL *session,
- int error, const char *which, int error_handler_failed)
+ int error, const char *which, bool error_handler_failed)
{
WT_EVENT_HANDLER *handler;
WT_SESSION *wt_session;
@@ -148,7 +148,7 @@ __wt_event_handler_set(WT_SESSION_IMPL *session, WT_EVENT_HANDLER *handler)
* Report a message to an event handler.
*/
int
-__wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error,
+__wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error,
const char *file_name, int line_number, const char *fmt, va_list ap)
{
WT_EVENT_HANDLER *handler;
@@ -286,11 +286,11 @@ __wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error,
if (msg_event) {
ret = handler->handle_message(handler, wt_session, s);
if (ret != 0)
- __handler_failure(session, ret, "message", 0);
+ __handler_failure(session, ret, "message", false);
} else {
ret = handler->handle_error(handler, wt_session, error, s);
if (ret != 0 && handler->handle_error != __handle_error_default)
- __handler_failure(session, ret, "error", 1);
+ __handler_failure(session, ret, "error", true);
}
return (ret);
@@ -311,7 +311,7 @@ __wt_err(WT_SESSION_IMPL *session, int error, const char *fmt, ...)
* an error value to return.
*/
va_start(ap, fmt);
- (void)__wt_eventv(session, 0, error, NULL, 0, fmt, ap);
+ (void)__wt_eventv(session, false, error, NULL, 0, fmt, ap);
va_end(ap);
}
@@ -330,7 +330,7 @@ __wt_errx(WT_SESSION_IMPL *session, const char *fmt, ...)
* an error value to return.
*/
va_start(ap, fmt);
- (void)__wt_eventv(session, 0, 0, NULL, 0, fmt, ap);
+ (void)__wt_eventv(session, false, 0, NULL, 0, fmt, ap);
va_end(ap);
}
@@ -351,7 +351,7 @@ __wt_ext_err_printf(
session = ((WT_CONNECTION_IMPL *)wt_api->conn)->default_session;
va_start(ap, fmt);
- ret = __wt_eventv(session, 0, 0, NULL, 0, fmt, ap);
+ ret = __wt_eventv(session, false, 0, NULL, 0, fmt, ap);
va_end(ap);
return (ret);
}
@@ -450,7 +450,7 @@ __wt_progress(WT_SESSION_IMPL *session, const char *s, uint64_t v)
if (handler != NULL && handler->handle_progress != NULL)
if ((ret = handler->handle_progress(handler,
wt_session, s == NULL ? session->name : s, v)) != 0)
- __handler_failure(session, ret, "progress", 0);
+ __handler_failure(session, ret, "progress", false);
return (0);
}
@@ -467,7 +467,8 @@ __wt_assert(WT_SESSION_IMPL *session,
va_list ap;
va_start(ap, fmt);
- (void)__wt_eventv(session, 0, error, file_name, line_number, fmt, ap);
+ (void)__wt_eventv(
+ session, false, error, file_name, line_number, fmt, ap);
va_end(ap);
#ifdef HAVE_DIAGNOSTIC
diff --git a/src/support/global.c b/src/support/global.c
index 5ddd291c6d4..1e32f5b4453 100644
--- a/src/support/global.c
+++ b/src/support/global.c
@@ -19,10 +19,10 @@ static int
__system_is_little_endian(void)
{
uint64_t v;
- int little;
+ bool little;
v = 1;
- little = *((uint8_t *)&v) == 0 ? 0 : 1;
+ little = *((uint8_t *)&v) != 0;
if (little)
return (0);
@@ -74,7 +74,7 @@ __wt_global_once(void)
int
__wt_library_init(void)
{
- static int first = 1;
+ static bool first = true;
WT_DECL_RET;
/*
@@ -86,7 +86,7 @@ __wt_library_init(void)
if (first) {
if ((ret = __wt_once(__wt_global_once)) != 0)
__wt_pthread_once_failed = ret;
- first = 0;
+ first = false;
}
return (__wt_pthread_once_failed);
}
diff --git a/src/support/hazard.c b/src/support/hazard.c
index 8333661db2d..c004e4063f8 100644
--- a/src/support/hazard.c
+++ b/src/support/hazard.c
@@ -187,17 +187,17 @@ void
__wt_hazard_close(WT_SESSION_IMPL *session)
{
WT_HAZARD *hp;
- int found;
+ bool found;
/*
* Check for a set hazard pointer and complain if we find one. We could
* just check the session's hazard pointer count, but this is a useful
* diagnostic.
*/
- for (found = 0, hp = session->hazard;
+ for (found = false, hp = session->hazard;
hp < session->hazard + session->hazard_size; ++hp)
if (hp->page != NULL) {
- found = 1;
+ found = true;
break;
}
if (session->nhazard == 0 && !found)
diff --git a/src/txn/txn.c b/src/txn/txn.c
index 52e840f89d8..eb2b621f315 100644
--- a/src/txn/txn.c
+++ b/src/txn/txn.c
@@ -168,7 +168,7 @@ __wt_txn_get_snapshot(WT_SESSION_IMPL *session)
* past the last committed transaction.
*/
void
-__wt_txn_update_oldest(WT_SESSION_IMPL *session, int force)
+__wt_txn_update_oldest(WT_SESSION_IMPL *session, bool force)
{
WT_CONNECTION_IMPL *conn;
WT_SESSION_IMPL *oldest_session;
@@ -177,7 +177,7 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force)
uint64_t current_id, id, oldest_id, prev_oldest_id, snap_min;
uint32_t i, session_cnt;
int32_t count;
- int last_running_moved;
+ bool last_running_moved;
conn = S2C(session);
txn_global = &conn->txn_global;
diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
index ea1fbfef853..13597924c0c 100644
--- a/src/txn/txn_ckpt.c
+++ b/src/txn/txn_ckpt.c
@@ -90,15 +90,15 @@ err: if (cursor != NULL)
*/
static int
__checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[],
- int (*op)(WT_SESSION_IMPL *, const char *[]), int *fullp)
+ int (*op)(WT_SESSION_IMPL *, const char *[]), bool *fullp)
{
WT_CONFIG targetconf;
WT_CONFIG_ITEM cval, k, v;
WT_DECL_ITEM(tmp);
WT_DECL_RET;
- int ckpt_closed, named, target_list;
+ bool ckpt_closed, named, target_list;
- target_list = 0;
+ target_list = false;
/* Flag if this is a named checkpoint, and check if the name is OK. */
WT_RET(__wt_config_gets(session, cfg, "name", &cval));
@@ -112,7 +112,7 @@ __checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[],
while ((ret = __wt_config_next(&targetconf, &k, &v)) == 0) {
if (!target_list) {
WT_ERR(__wt_scr_alloc(session, 512, &tmp));
- target_list = 1;
+ target_list = true;
}
if (v.len != 0)
@@ -354,15 +354,15 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
{ WT_CONFIG_BASE(session, session_begin_transaction),
"isolation=snapshot", NULL };
void *saved_meta_next;
- int full, idle, logging, tracking;
u_int i;
+ bool full, idle, logging, tracking;
conn = S2C(session);
txn = &session->txn;
txn_global = &conn->txn_global;
txn_state = WT_SESSION_TXN_STATE(session);
saved_isolation = session->isolation;
- full = idle = logging = tracking = 0;
+ full = idle = logging = tracking = false;
/* Ensure the metadata table is open before taking any locks. */
WT_RET(__wt_metadata_open(session));
@@ -393,7 +393,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
* This is particularly important for compact, so that all dirty pages
* can be fully written.
*/
- __wt_txn_update_oldest(session, 1);
+ __wt_txn_update_oldest(session, true);
/* Flush data-sources before we start the checkpoint. */
WT_ERR(__checkpoint_data_source(session, cfg));
@@ -421,7 +421,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
__wt_spin_lock(session, &conn->schema_lock);
WT_ERR(__wt_meta_track_on(session));
- tracking = 1;
+ tracking = true;
/* Tell logging that we are about to start a database checkpoint. */
if (full && logging)
@@ -553,8 +553,8 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
"metadata sync completed", &verb_timer));
} else
WT_WITH_DHANDLE(session, session->meta_dhandle,
- ret = __wt_txn_checkpoint_log(session,
- 0, WT_TXN_LOG_CKPT_SYNC, NULL));
+ ret = __wt_txn_checkpoint_log(
+ session, false, WT_TXN_LOG_CKPT_SYNC, NULL));
if (full) {
WT_ERR(__wt_epoch(session, &stop));
@@ -576,7 +576,7 @@ err: /*
*/
session->isolation = txn->isolation = WT_ISO_READ_UNCOMMITTED;
if (tracking)
- WT_TRET(__wt_meta_track_off(session, 0, ret != 0));
+ WT_TRET(__wt_meta_track_off(session, false, ret != 0));
if (F_ISSET(txn, WT_TXN_RUNNING)) {
/*
@@ -597,7 +597,7 @@ err: /*
if (ret == 0 &&
F_ISSET((WT_BTREE *)session->meta_dhandle->handle,
WT_BTREE_SKIP_CKPT))
- idle = 1;
+ idle = true;
WT_TRET(__wt_txn_checkpoint_log(session, full,
(ret == 0 && !idle) ?
WT_TXN_LOG_CKPT_STOP : WT_TXN_LOG_CKPT_CLEANUP, NULL));
@@ -659,7 +659,7 @@ static void
__drop_from(WT_CKPT *ckptbase, const char *name, size_t len)
{
WT_CKPT *ckpt;
- int matched;
+ bool matched;
/*
* There's a special case -- if the name is "all", then we delete all
@@ -676,12 +676,12 @@ __drop_from(WT_CKPT *ckptbase, const char *name, size_t len)
* checkpoints with the same name in the list, we'll delete from the
* first match to the end.
*/
- matched = 0;
+ matched = false;
WT_CKPT_FOREACH(ckptbase, ckpt) {
if (!matched && !WT_STRING_MATCH(ckpt->name, name, len))
continue;
- matched = 1;
+ matched = true;
F_SET(ckpt, WT_CKPT_DELETE);
}
}
@@ -722,7 +722,7 @@ __drop_to(WT_CKPT *ckptbase, const char *name, size_t len)
*/
static int
__checkpoint_worker(
- WT_SESSION_IMPL *session, const char *cfg[], int is_checkpoint)
+ WT_SESSION_IMPL *session, const char *cfg[], bool is_checkpoint)
{
WT_BM *bm;
WT_BTREE *btree;
@@ -733,8 +733,9 @@ __checkpoint_worker(
WT_DATA_HANDLE *dhandle;
WT_DECL_RET;
WT_LSN ckptlsn;
+ int deleted, was_modified;
+ bool fake_ckpt, force, hot_backup_locked;
const char *name;
- int deleted, fake_ckpt, force, hot_backup_locked, was_modified;
char *name_alloc;
btree = S2BT(session);
@@ -742,11 +743,9 @@ __checkpoint_worker(
conn = S2C(session);
ckpt = ckptbase = NULL;
dhandle = session->dhandle;
- name_alloc = NULL;
- hot_backup_locked = 0;
- name_alloc = NULL;
- fake_ckpt = 0;
was_modified = btree->modified;
+ fake_ckpt = hot_backup_locked = false;
+ name_alloc = NULL;
/*
* Set the checkpoint LSN to the maximum LSN so that if logging is
@@ -831,14 +830,14 @@ __checkpoint_worker(
* to open the checkpoint in a cursor after taking any checkpoint, which
* means it must exist.
*/
- force = 0;
+ force = false;
F_CLR(btree, WT_BTREE_SKIP_CKPT);
if (!btree->modified && cfg != NULL) {
ret = __wt_config_gets(session, cfg, "force", &cval);
if (ret != 0 && ret != WT_NOTFOUND)
WT_ERR(ret);
if (ret == 0 && cval.val != 0)
- force = 1;
+ force = true;
}
if (!btree->modified && !force) {
if (!is_checkpoint)
@@ -885,7 +884,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT);
* we don't want to race with a future hot backup.
*/
__wt_spin_lock(session, &conn->hot_backup_lock);
- hot_backup_locked = 1;
+ hot_backup_locked = true;
if (conn->hot_backup)
WT_CKPT_FOREACH(ckptbase, ckpt) {
if (!F_ISSET(ckpt, WT_CKPT_DELETE))
@@ -971,7 +970,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT);
WT_ERR_MSG(session, ret,
"block-manager checkpoint found "
"for a bulk-loaded file");
- fake_ckpt = 1;
+ fake_ckpt = true;
goto fake;
case WT_BTREE_SALVAGE:
case WT_BTREE_UPGRADE:
@@ -996,7 +995,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT);
*/
if (is_checkpoint)
if (btree->bulk_load_ok) {
- fake_ckpt = 1;
+ fake_ckpt = true;
goto fake;
}
@@ -1029,7 +1028,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT);
/* Tell logging that a file checkpoint is starting. */
if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
WT_ERR(__wt_txn_checkpoint_log(
- session, 0, WT_TXN_LOG_CKPT_START, &ckptlsn));
+ session, false, WT_TXN_LOG_CKPT_START, &ckptlsn));
/* Flush the file from the cache, creating the checkpoint. */
if (is_checkpoint)
@@ -1092,7 +1091,7 @@ fake: /*
/* Tell logging that the checkpoint is complete. */
if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))
WT_ERR(__wt_txn_checkpoint_log(
- session, 0, WT_TXN_LOG_CKPT_STOP, NULL));
+ session, false, WT_TXN_LOG_CKPT_STOP, NULL));
done:
err: /*
@@ -1124,7 +1123,7 @@ __wt_checkpoint(WT_SESSION_IMPL *session, const char *cfg[])
/* Should be holding the schema lock. */
WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SCHEMA));
- return (__checkpoint_worker(session, cfg, 1));
+ return (__checkpoint_worker(session, cfg, true));
}
/*
@@ -1154,7 +1153,7 @@ __wt_checkpoint_sync(WT_SESSION_IMPL *session, const char *cfg[])
* Checkpoint a single file as part of closing the handle.
*/
int
-__wt_checkpoint_close(WT_SESSION_IMPL *session, int final)
+__wt_checkpoint_close(WT_SESSION_IMPL *session, bool final)
{
WT_BTREE *btree;
WT_DECL_RET;
@@ -1172,7 +1171,7 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, int final)
* for active readers.
*/
if (!btree->modified && !bulk) {
- __wt_txn_update_oldest(session, 1);
+ __wt_txn_update_oldest(session, true);
return (__wt_txn_visible_all(session, btree->rec_max_txn) ?
__wt_cache_op(session, NULL, WT_SYNC_DISCARD) : EBUSY);
}
@@ -1196,10 +1195,10 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, int final)
if (need_tracking)
WT_RET(__wt_meta_track_on(session));
- WT_TRET(__checkpoint_worker(session, NULL, 0));
+ WT_TRET(__checkpoint_worker(session, NULL, false));
if (need_tracking)
- WT_RET(__wt_meta_track_off(session, 1, ret != 0));
+ WT_RET(__wt_meta_track_off(session, true, ret != 0));
return (ret);
}
diff --git a/src/txn/txn_log.c b/src/txn/txn_log.c
index cb3c17a098b..d34448efc4d 100644
--- a/src/txn/txn_log.c
+++ b/src/txn/txn_log.c
@@ -67,9 +67,9 @@ static int
__txn_commit_printlog(
WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, FILE *out)
{
- int firstrecord;
+ bool firstrecord;
- firstrecord = 1;
+ firstrecord = true;
fprintf(out, " \"ops\": [\n");
/* The logging subsystem zero-pads records. */
@@ -78,7 +78,7 @@ __txn_commit_printlog(
fprintf(out, ",\n");
fprintf(out, " {");
- firstrecord = 0;
+ firstrecord = false;
WT_RET(__wt_txn_op_printlog(session, pp, end, out));
fprintf(out, "\n }");
@@ -221,7 +221,8 @@ __txn_log_file_sync(WT_SESSION_IMPL *session, uint32_t flags, WT_LSN *lsnp)
WT_DECL_RET;
size_t header_size;
uint32_t rectype = WT_LOGREC_FILE_SYNC;
- int start, need_sync;
+ int start;
+ bool need_sync;
const char *fmt = WT_UNCHECKED_STRING(III);
btree = S2BT(session);
@@ -271,7 +272,7 @@ __wt_txn_checkpoint_logread(
*/
int
__wt_txn_checkpoint_log(
- WT_SESSION_IMPL *session, int full, uint32_t flags, WT_LSN *lsnp)
+ WT_SESSION_IMPL *session, bool full, uint32_t flags, WT_LSN *lsnp)
{
WT_DECL_ITEM(logrec);
WT_DECL_RET;
diff --git a/src/txn/txn_nsnap.c b/src/txn/txn_nsnap.c
new file mode 100644
index 00000000000..a5ec9cb9b82
--- /dev/null
+++ b/src/txn/txn_nsnap.c
@@ -0,0 +1,367 @@
+/*-
+ * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2008-2014 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __nsnap_destroy --
+ * Destroy a named snapshot structure.
+ */
+static void
+__nsnap_destroy(WT_SESSION_IMPL *session, WT_NAMED_SNAPSHOT *nsnap)
+{
+ __wt_free(session, nsnap->name);
+ __wt_free(session, nsnap->snapshot);
+ __wt_free(session, nsnap);
+}
+
+/*
+ * __nsnap_drop_one --
+ * Drop a single named snapshot. The named snapshot lock must be held
+ * write locked.
+ */
+static int
+__nsnap_drop_one(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name)
+{
+ WT_DECL_RET;
+ WT_NAMED_SNAPSHOT *found;
+ WT_TXN_GLOBAL *txn_global;
+
+ txn_global = &S2C(session)->txn_global;
+
+ TAILQ_FOREACH(found, &txn_global->nsnaph, q)
+ if (WT_STRING_MATCH(found->name, name->str, name->len))
+ break;
+
+ if (found == NULL)
+ return (WT_NOTFOUND);
+
+ /* Bump the global ID if we are removing the first entry */
+ if (found == TAILQ_FIRST(&txn_global->nsnaph))
+ txn_global->nsnap_oldest_id = (TAILQ_NEXT(found, q) != NULL) ?
+ TAILQ_NEXT(found, q)->snap_min : WT_TXN_NONE;
+ TAILQ_REMOVE(&txn_global->nsnaph, found, q);
+ __nsnap_destroy(session, found);
+
+ return (ret);
+}
+
+/*
+ * __nsnap_drop_to --
+ * Drop named snapshots, if the name is NULL all snapshots will be
+ * dropped. The named snapshot lock must be held write locked.
+ */
+static int
+__nsnap_drop_to(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name, bool inclusive)
+{
+ WT_DECL_RET;
+ WT_NAMED_SNAPSHOT *last, *nsnap, *prev;
+ WT_TXN_GLOBAL *txn_global;
+ uint64_t new_nsnap_oldest;
+
+ last = nsnap = prev = NULL;
+ txn_global = &S2C(session)->txn_global;
+
+ if (TAILQ_EMPTY(&txn_global->nsnaph)) {
+ if (name == NULL)
+ return (0);
+ /*
+ * Dropping specific snapshots when there aren't any it's an
+ * error.
+ */
+ WT_RET_MSG(session, EINVAL,
+ "Named snapshot '%.*s' for drop not found",
+ (int)name->len, name->str);
+ }
+
+ /*
+ * The new ID will be none if we are removing all named snapshots
+ * which is the default behavior of this loop.
+ */
+ new_nsnap_oldest = WT_TXN_NONE;
+ if (name != NULL) {
+ TAILQ_FOREACH(last, &txn_global->nsnaph, q) {
+ if (WT_STRING_MATCH(last->name, name->str, name->len))
+ break;
+ prev = last;
+ }
+ if (last == NULL)
+ WT_RET_MSG(session, EINVAL,
+ "Named snapshot '%.*s' for drop not found",
+ (int)name->len, name->str);
+
+ if (!inclusive) {
+ /* We are done if a drop before points to the head */
+ if (prev == 0)
+ return (0);
+ last = prev;
+ }
+
+ if (TAILQ_NEXT(last, q) != NULL)
+ new_nsnap_oldest = TAILQ_NEXT(last, q)->snap_min;
+ }
+
+ do {
+ nsnap = TAILQ_FIRST(&txn_global->nsnaph);
+ WT_ASSERT(session, nsnap != NULL);
+ TAILQ_REMOVE(&txn_global->nsnaph, nsnap, q);
+ __nsnap_destroy(session, nsnap);
+ /* Last will be NULL in the all case so it will never match */
+ } while (nsnap != last && !TAILQ_EMPTY(&txn_global->nsnaph));
+
+ /* Now that the queue of named snapshots is updated, update the ID */
+ txn_global->nsnap_oldest_id = new_nsnap_oldest;
+
+ return (ret);
+}
+
+/*
+ * __wt_txn_named_snapshot_begin --
+ * Begin an named in-memory snapshot.
+ */
+int
+__wt_txn_named_snapshot_begin(WT_SESSION_IMPL *session, const char *cfg[])
+{
+ WT_CONFIG_ITEM cval;
+ WT_DECL_RET;
+ WT_NAMED_SNAPSHOT *nsnap, *nsnap_new;
+ WT_TXN *txn;
+ WT_TXN_GLOBAL *txn_global;
+ const char *txn_cfg[] =
+ { WT_CONFIG_BASE(session, WT_SESSION_begin_transaction),
+ "isolation=snapshot", NULL };
+ bool started_txn;
+
+ started_txn = false;
+ nsnap_new = NULL;
+ txn_global = &S2C(session)->txn_global;
+ txn = &session->txn;
+
+ WT_RET(__wt_config_gets_def(session, cfg, "name", 0, &cval));
+ WT_ASSERT(session, cval.len != 0);
+
+ if (!F_ISSET(txn, WT_TXN_RUNNING)) {
+ WT_RET(__wt_txn_begin(session, txn_cfg));
+ started_txn = true;
+ }
+ F_SET(txn, WT_TXN_READONLY);
+
+ /* Save a copy of the transaction's snapshot. */
+ WT_ERR(__wt_calloc_one(session, &nsnap_new));
+ nsnap = nsnap_new;
+ WT_ERR(__wt_strndup(session, cval.str, cval.len, &nsnap->name));
+ nsnap->snap_min = txn->snap_min;
+ nsnap->snap_max = txn->snap_max;
+ if (txn->snapshot_count > 0) {
+ WT_ERR(__wt_calloc_def(
+ session, txn->snapshot_count, &nsnap->snapshot));
+ memcpy(nsnap->snapshot, txn->snapshot,
+ txn->snapshot_count * sizeof(*nsnap->snapshot));
+ }
+ nsnap->snapshot_count = txn->snapshot_count;
+
+ /* Update the list. */
+
+ /*
+ * The semantic is that a new snapshot with the same name as an
+ * existing snapshot will replace the old one.
+ */
+ WT_ERR_NOTFOUND_OK(__nsnap_drop_one(session, &cval));
+
+ if (TAILQ_EMPTY(&txn_global->nsnaph))
+ txn_global->nsnap_oldest_id = nsnap_new->snap_min;
+ TAILQ_INSERT_TAIL(&txn_global->nsnaph, nsnap_new, q);
+ nsnap_new = NULL;
+
+err: if (started_txn)
+ WT_TRET(__wt_txn_rollback(session, NULL));
+ else if (ret == 0)
+ F_SET(txn, WT_TXN_NAMED_SNAPSHOT);
+
+ if (nsnap_new != NULL)
+ __nsnap_destroy(session, nsnap_new);
+
+ return (ret);
+}
+
+/*
+ * __wt_txn_named_snapshot_drop --
+ * Drop named snapshots
+ */
+int
+__wt_txn_named_snapshot_drop(WT_SESSION_IMPL *session, const char *cfg[])
+{
+ WT_CONFIG objectconf;
+ WT_CONFIG_ITEM all_config, k, names_config, to_config, before_config, v;
+ WT_DECL_RET;
+
+ WT_RET(__wt_config_gets_def(session, cfg, "drop.all", 0, &all_config));
+ WT_RET(__wt_config_gets_def(
+ session, cfg, "drop.names", 0, &names_config));
+ WT_RET(__wt_config_gets_def(session, cfg, "drop.to", 0, &to_config));
+ WT_RET(__wt_config_gets_def(
+ session, cfg, "drop.before", 0, &before_config));
+
+ if (all_config.val != 0)
+ WT_RET(__nsnap_drop_to(session, NULL, true));
+ else if (before_config.len != 0)
+ WT_RET(__nsnap_drop_to(session, &before_config, false));
+ else if (to_config.len != 0)
+ WT_RET(__nsnap_drop_to(session, &to_config, true));
+
+ /* We are done if there are no named drops */
+
+ if (names_config.len != 0) {
+ WT_RET(__wt_config_subinit(
+ session, &objectconf, &names_config));
+ while ((ret = __wt_config_next(&objectconf, &k, &v)) == 0) {
+ ret = __nsnap_drop_one(session, &k);
+ if (ret != 0)
+ WT_RET_MSG(session, EINVAL,
+ "Named snapshot '%.*s' for drop not found",
+ (int)k.len, k.str);
+ }
+ if (ret == WT_NOTFOUND)
+ ret = 0;
+ }
+
+ return (ret);
+}
+
+/*
+ * __wt_txn_named_snapshot_get --
+ * Lookup a named snapshot for a transaction.
+ */
+int
+__wt_txn_named_snapshot_get(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *nameval)
+{
+ WT_NAMED_SNAPSHOT *nsnap;
+ WT_TXN *txn;
+ WT_TXN_GLOBAL *txn_global;
+ WT_TXN_STATE *txn_state;
+
+ txn = &session->txn;
+ txn_global = &S2C(session)->txn_global;
+ txn_state = WT_SESSION_TXN_STATE(session);
+
+ txn->isolation = WT_ISO_SNAPSHOT;
+ if (session->ncursors > 0)
+ WT_RET(__wt_session_copy_values(session));
+
+ WT_RET(__wt_readlock(session, txn_global->nsnap_rwlock));
+ TAILQ_FOREACH(nsnap, &txn_global->nsnaph, q)
+ if (WT_STRING_MATCH(nsnap->name, nameval->str, nameval->len)) {
+ txn->snap_min = txn_state->snap_min = nsnap->snap_min;
+ txn->snap_max = nsnap->snap_max;
+ if ((txn->snapshot_count = nsnap->snapshot_count) != 0)
+ memcpy(txn->snapshot, nsnap->snapshot,
+ nsnap->snapshot_count *
+ sizeof(*nsnap->snapshot));
+ F_SET(txn, WT_TXN_HAS_SNAPSHOT);
+ break;
+ }
+ WT_RET(__wt_readunlock(session, txn_global->nsnap_rwlock));
+
+ if (nsnap == NULL)
+ WT_RET_MSG(session, EINVAL,
+ "Named snapshot '%.*s' not found",
+ (int)nameval->len, nameval->str);
+
+ /* Flag that this transaction is opened on a named snapshot */
+ F_SET(txn, WT_TXN_NAMED_SNAPSHOT);
+
+ return (0);
+}
+
+/*
+ * __wt_txn_named_snapshot_config --
+ * Check the configuration for a named snapshot
+ */
+int
+__wt_txn_named_snapshot_config(WT_SESSION_IMPL *session,
+ const char *cfg[], bool *has_create, bool *has_drops)
+{
+ WT_CONFIG_ITEM cval;
+ WT_CONFIG_ITEM all_config, names_config, to_config, before_config;
+ WT_TXN *txn;
+
+ txn = &session->txn;
+ *has_create = *has_drops = false;
+
+ /* Verify that the name is legal. */
+ WT_RET(__wt_config_gets_def(session, cfg, "name", 0, &cval));
+ if (cval.len != 0) {
+ if (WT_STRING_MATCH("all", cval.str, cval.len))
+ WT_RET_MSG(session, EINVAL,
+ "Can't create snapshot with reserved \"all\" name");
+
+ WT_RET(__wt_name_check(session, cval.str, cval.len));
+
+ if (F_ISSET(txn, WT_TXN_RUNNING) &&
+ txn->isolation != WT_ISO_SNAPSHOT)
+ WT_RET_MSG(session, EINVAL,
+ "Can't create a named snapshot from a running "
+ "transaction that isn't snapshot isolation");
+ else if (F_ISSET(txn, WT_TXN_RUNNING) && txn->mod_count != 0)
+ WT_RET_MSG(session, EINVAL,
+ "Can't create a named snapshot from a running "
+ "transaction that has made updates");
+ *has_create = true;
+ }
+
+ /* Verify that the drop configuration is sane. */
+ WT_RET(__wt_config_gets_def(session, cfg, "drop.all", 0, &all_config));
+ WT_RET(__wt_config_gets_def(
+ session, cfg, "drop.names", 0, &names_config));
+ WT_RET(__wt_config_gets_def(session, cfg, "drop.to", 0, &to_config));
+ WT_RET(__wt_config_gets_def(
+ session, cfg, "drop.before", 0, &before_config));
+
+ /* Avoid more work if no drops are configured. */
+ if (all_config.val != 0 || names_config.len != 0 ||
+ before_config.len != 0 || to_config.len != 0) {
+ if (before_config.len != 0 && to_config.len != 0)
+ WT_RET_MSG(session, EINVAL,
+ "Illegal configuration; named snapshot drop can't "
+ "specify both before and to options");
+ if (all_config.val != 0 && (names_config.len != 0 ||
+ to_config.len != 0 || before_config.len != 0))
+ WT_RET_MSG(session, EINVAL,
+ "Illegal configuration; named snapshot drop can't "
+ "specify all and any other options");
+ *has_drops = true;
+ }
+
+ if (!*has_create && !*has_drops)
+ WT_RET_MSG(session, EINVAL,
+ "WT_SESSION::snapshot API called without any drop or "
+ "name option.");
+
+ return (0);
+}
+
+/*
+ * __wt_txn_named_snapshot_destroy --
+ * Destroy all named snapshots on connection close
+ */
+int
+__wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session)
+{
+ WT_NAMED_SNAPSHOT *nsnap;
+ WT_TXN_GLOBAL *txn_global;
+
+ txn_global = &S2C(session)->txn_global;
+ txn_global->nsnap_oldest_id = WT_TXN_NONE;
+
+ while ((nsnap = TAILQ_FIRST(&txn_global->nsnaph)) != NULL) {
+ TAILQ_REMOVE(&txn_global->nsnaph, nsnap, q);
+ __nsnap_destroy(session, nsnap);
+ }
+
+ return (0);
+}
diff --git a/src/txn/txn_recover.c b/src/txn/txn_recover.c
index f64d2d58cfc..5799bbc2a79 100644
--- a/src/txn/txn_recover.c
+++ b/src/txn/txn_recover.c
@@ -24,9 +24,8 @@ typedef struct {
WT_LSN ckpt_lsn; /* Start LSN for main recovery loop. */
- int missing; /* Were there missing files? */
- int modified; /* Did recovery make any changes? */
- int metadata_only; /*
+ bool missing; /* Were there missing files? */
+ bool metadata_only; /*
* Set during the first recovery pass,
* when only the metadata is recovered.
*/
@@ -38,12 +37,12 @@ typedef struct {
*/
static int
__recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r,
- WT_LSN *lsnp, u_int id, int duplicate, WT_CURSOR **cp)
+ WT_LSN *lsnp, u_int id, bool duplicate, WT_CURSOR **cp)
{
WT_CURSOR *c;
const char *cfg[] = { WT_CONFIG_BASE(session, session_open_cursor),
"overwrite", NULL };
- int metadata_op;
+ bool metadata_op;
c = NULL;
@@ -55,7 +54,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r,
* is more recent than the last checkpoint. If there is no entry for a
* file, assume it was dropped or missing after a hot backup.
*/
- metadata_op = (id == WT_METAFILE_ID);
+ metadata_op = id == WT_METAFILE_ID;
if (r->metadata_only != metadata_op)
;
else if (id >= r->nfiles || r->files[id].uri == NULL) {
@@ -64,7 +63,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r,
WT_RET(__wt_verbose(session, WT_VERB_RECOVERY,
"No file found with ID %u (max %u)",
id, r->nfiles));
- r->missing = 1;
+ r->missing = true;
} else if (LOG_CMP(lsnp, &r->files[id].ckpt_lsn) >= 0) {
/*
* We're going to apply the operation. Get the cursor, opening
@@ -90,7 +89,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r,
*/
#define GET_RECOVERY_CURSOR(session, r, lsnp, fileid, cp) \
WT_ERR(__recovery_cursor( \
- (session), (r), (lsnp), (fileid), 0, (cp))); \
+ (session), (r), (lsnp), (fileid), false, (cp))); \
WT_ERR(__wt_verbose((session), WT_VERB_RECOVERY, \
"%s op %d to file %d at LSN %u/%" PRIuMAX, \
(cursor == NULL) ? "Skipping" : "Applying", \
@@ -153,7 +152,7 @@ __txn_op_apply(
} else {
start = cursor;
WT_ERR(__recovery_cursor(
- session, r, lsnp, fileid, 1, &stop));
+ session, r, lsnp, fileid, true, &stop));
}
/* Set the keys. */
@@ -200,7 +199,7 @@ __txn_op_apply(
case TXN_TRUNC_BOTH:
start = cursor;
WT_ERR(__recovery_cursor(
- session, r, lsnp, fileid, 1, &stop));
+ session, r, lsnp, fileid, true, &stop));
break;
case TXN_TRUNC_START:
start = cursor;
@@ -233,8 +232,6 @@ __txn_op_apply(
if (cursor != NULL)
WT_ERR(cursor->reset(cursor));
- r->modified = 1;
-
err: if (ret != 0)
__wt_err(session, ret, "Operation failed during recovery");
return (ret);
@@ -451,7 +448,7 @@ __wt_txn_recover(WT_SESSION_IMPL *session)
* backup: we already have the correct metadata in that case.
*/
if (!was_backup) {
- r.metadata_only = 1;
+ r.metadata_only = true;
if (WT_IS_INIT_LSN(&metafile->ckpt_lsn))
WT_ERR(__wt_log_scan(session,
NULL, WT_LOGSCAN_FIRST, __txn_log_recover, &r));
@@ -485,7 +482,7 @@ __wt_txn_recover(WT_SESSION_IMPL *session)
* Now, recover all the files apart from the metadata.
* Pass WT_LOGSCAN_RECOVER so that old logs get truncated.
*/
- r.metadata_only = 0;
+ r.metadata_only = false;
WT_ERR(__wt_verbose(session, WT_VERB_RECOVERY,
"Main recovery loop: starting at %u/%" PRIuMAX,
r.ckpt_lsn.file, (uintmax_t)r.ckpt_lsn.offset));
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 cad91591a61..4170b141f58 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 b02186cee75..dc909ad1a7e 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:
@@ -144,7 +145,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;
@@ -278,13 +279,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, *stripped;
- static const char * const indent = " ";
- once = 0;
+ once = false;
if (printf(" \"%s\" : [", header) < 0)
return (util_err(session, EIO, NULL));
@@ -341,15 +343,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);
@@ -582,7 +584,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;
@@ -603,16 +605,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";
@@ -628,10 +630,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));
@@ -665,14 +667,14 @@ dup_json_string(const char *str, char **result)
nchars = 0;
for (p = str; *p; p++, nchars++)
- nchars += __wt_json_unpack_char(*p, NULL, 0, 0);
+ nchars += __wt_json_unpack_char(*p, NULL, 0, false);
q = malloc(nchars + 1);
if (q == NULL)
return (1);
*result = q;
left = nchars;
for (p = str; *p; p++, nchars++) {
- nchars = __wt_json_unpack_char(*p, (u_char *)q, left, 0);
+ nchars = __wt_json_unpack_char(*p, (u_char *)q, left, false);
left -= nchars;
q += nchars;
}
diff --git a/src/utilities/util_list.c b/src/utilities/util_list.c
index 270f06666a2..729bac82fc5 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:
@@ -60,11 +61,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. */
@@ -94,7 +95,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 994df10b70b..095ce55f835 100644
--- a/src/utilities/util_load.c
+++ b/src/utilities/util_load.c
@@ -9,7 +9,7 @@
#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 void config_remove(char *, const char *);
static int format(WT_SESSION *);
@@ -17,18 +17,18 @@ 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;
@@ -36,7 +36,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)
@@ -47,10 +47,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;
@@ -63,7 +63,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"));
@@ -94,12 +94,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. */
@@ -218,11 +219,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;
@@ -230,31 +232,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;
@@ -548,7 +550,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;
@@ -563,14 +565,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 f498b821073..0fb118a0185 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;
@@ -214,12 +214,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;
@@ -247,7 +248,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++;
@@ -346,10 +347,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;
@@ -464,7 +465,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;
@@ -478,7 +479,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)
@@ -500,7 +501,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",
@@ -534,7 +535,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);
}
@@ -547,7 +548,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);
@@ -565,7 +566,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 79d768f5752..75b8a5cd9c4 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 = "[-Vv] [-R] [-C config] [-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;
const char *cmd_config, *config, *rec_config;
@@ -65,7 +65,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:h:LRVv")) != EOF)
switch (ch) {
@@ -77,17 +77,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 20a7060f729..caac13be94c 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 "