diff options
41 files changed, 261 insertions, 246 deletions
diff --git a/src/block/block_addr.c b/src/block/block_addr.c index 3099f5ba8dc..6d50e5f0f4e 100644 --- a/src/block/block_addr.c +++ b/src/block/block_addr.c @@ -89,7 +89,7 @@ __wt_block_buffer_to_addr(WT_BLOCK *block, */ int __wt_block_addr_invalid(WT_SESSION_IMPL *session, - WT_BLOCK *block, const uint8_t *addr, size_t addr_size, int live) + WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool live) { wt_off_t offset; uint32_t cksum, size; diff --git a/src/block/block_ckpt.c b/src/block/block_ckpt.c index 62338da90c5..a23b95233e1 100644 --- a/src/block/block_ckpt.c +++ b/src/block/block_ckpt.c @@ -12,7 +12,7 @@ static int __ckpt_process(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); static int __ckpt_string( WT_SESSION_IMPL *, WT_BLOCK *, const uint8_t *, WT_ITEM *); static int __ckpt_update( - WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *, WT_BLOCK_CKPT *, int); + WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *, WT_BLOCK_CKPT *, bool); /* * __wt_block_ckpt_init -- @@ -27,12 +27,14 @@ __wt_block_ckpt_init( ci->version = WT_BM_CHECKPOINT_VERSION; ci->root_offset = WT_BLOCK_INVALID_OFFSET; - WT_RET(__wt_block_extlist_init(session, &ci->alloc, name, "alloc", 0)); - WT_RET(__wt_block_extlist_init(session, &ci->avail, name, "avail", 1)); WT_RET(__wt_block_extlist_init( - session, &ci->discard, name, "discard", 0)); + session, &ci->alloc, name, "alloc", false)); WT_RET(__wt_block_extlist_init( - session, &ci->ckpt_avail, name, "ckpt_avail", 1)); + session, &ci->avail, name, "avail", true)); + WT_RET(__wt_block_extlist_init( + session, &ci->discard, name, "discard", false)); + WT_RET(__wt_block_extlist_init( + session, &ci->ckpt_avail, name, "ckpt_avail", true)); return (0); } @@ -165,7 +167,7 @@ err: /* */ int __wt_block_checkpoint_unload( - WT_SESSION_IMPL *session, WT_BLOCK *block, int checkpoint) + WT_SESSION_IMPL *session, WT_BLOCK *block, bool checkpoint) { WT_DECL_RET; @@ -225,7 +227,7 @@ __wt_block_checkpoint(WT_SESSION_IMPL *session, ci = &block->live; /* Switch to first-fit allocation. */ - __wt_block_configure_first_fit(block, 1); + __wt_block_configure_first_fit(block, true); /* * Write the root page: it's possible for there to be a checkpoint of @@ -257,7 +259,7 @@ __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_TRET(__wt_block_ext_discard(session, 250)); /* Restore the original allocation plan. */ -err: __wt_block_configure_first_fit(block, 0); +err: __wt_block_configure_first_fit(block, false); return (ret); } @@ -363,10 +365,10 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) WT_DECL_ITEM(tmp); WT_DECL_RET; uint64_t ckpt_size; - int deleting, locked; + bool deleting, locked; ci = &block->live; - locked = 0; + locked = false; #ifdef HAVE_DIAGNOSTIC WT_RET(__ckpt_verify(session, ckptbase)); @@ -427,7 +429,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) */ __wt_block_extlist_free(session, &ci->ckpt_avail); WT_RET(__wt_block_extlist_init( - session, &ci->ckpt_avail, "live", "ckpt_avail", 1)); + session, &ci->ckpt_avail, "live", "ckpt_avail", true)); __wt_block_extlist_free(session, &ci->ckpt_alloc); __wt_block_extlist_free(session, &ci->ckpt_discard); @@ -436,12 +438,12 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) * the subsequent checkpoint into which it gets rolled; read them from * disk before we lock things down. */ - deleting = 0; + deleting = false; WT_CKPT_FOREACH(ckptbase, ckpt) { if (F_ISSET(ckpt, WT_CKPT_FAKE) || !F_ISSET(ckpt, WT_CKPT_DELETE)) continue; - deleting = 1; + deleting = true; /* * Read the checkpoint and next checkpoint extent lists if we @@ -473,7 +475,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) * the final merge of ranges into the live tree. */ __wt_spin_lock(session, &block->live_lock); - locked = 1; + locked = true; /* * We've allocated our last page, update the checkpoint size. We need @@ -599,7 +601,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) WT_CKPT_FOREACH(ckptbase, ckpt) if (F_ISSET(ckpt, WT_CKPT_UPDATE)) WT_ERR(__ckpt_update( - session, block, ckpt, ckpt->bpriv, 0)); + session, block, ckpt, ckpt->bpriv, false)); live_update: /* Truncate the file if that's possible. */ @@ -620,7 +622,7 @@ live_update: */ ckpt->ckpt_size = ci->ckpt_size = ckpt_size; - WT_ERR(__ckpt_update(session, block, ckpt, ci, 1)); + WT_ERR(__ckpt_update(session, block, ckpt, ci, true)); } /* @@ -631,10 +633,10 @@ live_update: */ ci->ckpt_alloc = ci->alloc; WT_ERR(__wt_block_extlist_init( - session, &ci->alloc, "live", "alloc", 0)); + session, &ci->alloc, "live", "alloc", false)); ci->ckpt_discard = ci->discard; WT_ERR(__wt_block_extlist_init( - session, &ci->discard, "live", "discard", 0)); + session, &ci->discard, "live", "discard", false)); #ifdef HAVE_DIAGNOSTIC /* @@ -675,7 +677,7 @@ err: if (locked) */ static int __ckpt_update(WT_SESSION_IMPL *session, - WT_BLOCK *block, WT_CKPT *ckpt, WT_BLOCK_CKPT *ci, int is_live) + WT_BLOCK *block, WT_CKPT *ckpt, WT_BLOCK_CKPT *ci, bool is_live) { WT_DECL_ITEM(tmp); WT_DECL_RET; diff --git a/src/block/block_compact.c b/src/block/block_compact.c index 4cd29698536..d45d0a96da7 100644 --- a/src/block/block_compact.c +++ b/src/block/block_compact.c @@ -20,7 +20,7 @@ __wt_block_compact_start(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_UNUSED(session); /* Switch to first-fit allocation. */ - __wt_block_configure_first_fit(block, 1); + __wt_block_configure_first_fit(block, true); block->compact_pct_tenths = 0; @@ -37,7 +37,7 @@ __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_UNUSED(session); /* Restore the original allocation plan. */ - __wt_block_configure_first_fit(block, 0); + __wt_block_configure_first_fit(block, false); block->compact_pct_tenths = 0; diff --git a/src/block/block_ext.c b/src/block/block_ext.c index c3332b647cf..a56df220390 100644 --- a/src/block/block_ext.c +++ b/src/block/block_ext.c @@ -24,7 +24,7 @@ static int __block_append(WT_SESSION_IMPL *, static int __block_ext_overlap(WT_SESSION_IMPL *, WT_BLOCK *, WT_EXTLIST *, WT_EXT **, WT_EXTLIST *, WT_EXT **); static int __block_extlist_dump( - WT_SESSION_IMPL *, const char *, WT_EXTLIST *, int); + WT_SESSION_IMPL *, const char *, WT_EXTLIST *, bool); static int __block_merge(WT_SESSION_IMPL *, WT_BLOCK *, WT_EXTLIST *, wt_off_t, wt_off_t); @@ -59,7 +59,7 @@ __block_off_srch_last(WT_EXT **head, WT_EXT ***stack) * by-offset list referenced by a size entry), for the specified offset. */ static inline void -__block_off_srch(WT_EXT **head, wt_off_t off, WT_EXT ***stack, int skip_off) +__block_off_srch(WT_EXT **head, wt_off_t off, WT_EXT ***stack, bool skip_off) { WT_EXT **extp; int i; @@ -102,7 +102,7 @@ __block_first_srch(WT_EXT **head, wt_off_t size, WT_EXT ***stack) return (false); /* Build a stack for the offset we want. */ - __block_off_srch(head, ext->off, stack, 0); + __block_off_srch(head, ext->off, stack, false); return (true); } @@ -199,7 +199,7 @@ __block_ext_insert(WT_SESSION_IMPL *session, WT_EXTLIST *el, WT_EXT *ext) * Insert the new WT_EXT structure into the size element's * offset skiplist. */ - __block_off_srch(szp->off, ext->off, astack, 1); + __block_off_srch(szp->off, ext->off, astack, true); for (i = 0; i < ext->depth; ++i) { ext->next[i + ext->depth] = *astack[i]; *astack[i] = ext; @@ -212,7 +212,7 @@ __block_ext_insert(WT_SESSION_IMPL *session, WT_EXTLIST *el, WT_EXT *ext) #endif /* Insert the new WT_EXT structure into the offset skiplist. */ - __block_off_srch(el->off, ext->off, astack, 0); + __block_off_srch(el->off, ext->off, astack, false); for (i = 0; i < ext->depth; ++i) { ext->next[i] = *astack[i]; *astack[i] = ext; @@ -273,7 +273,7 @@ __block_off_match(WT_EXTLIST *el, wt_off_t off, wt_off_t size) */ int __wt_block_misplaced(WT_SESSION_IMPL *session, - WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, int live) + WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, bool live) { const char *name; @@ -329,7 +329,7 @@ __block_off_remove(WT_SESSION_IMPL *session, WT_BLOCK *block, u_int i; /* Find and remove the record from the by-offset skiplist. */ - __block_off_srch(el->off, off, astack, 0); + __block_off_srch(el->off, off, astack, false); ext = *astack[0]; if (ext == NULL || ext->off != off) goto corrupt; @@ -345,7 +345,7 @@ __block_off_remove(WT_SESSION_IMPL *session, WT_BLOCK *block, szp = *sstack[0]; if (szp == NULL || szp->size != ext->size) return (EINVAL); - __block_off_srch(szp->off, off, astack, 1); + __block_off_srch(szp->off, off, astack, true); ext = *astack[0]; if (ext == NULL || ext->off != off) goto corrupt; @@ -359,11 +359,11 @@ __block_off_remove(WT_SESSION_IMPL *session, WT_BLOCK *block, } #ifdef HAVE_DIAGNOSTIC if (!el->track_size) { - int not_null; - for (i = 0, not_null = 0; i < ext->depth; ++i) + bool not_null; + for (i = 0, not_null = false; i < ext->depth; ++i) if (ext->next[i + ext->depth] != NULL) - not_null = 1; - WT_ASSERT(session, not_null == 0); + not_null = true; + WT_ASSERT(session, not_null == false); } #endif @@ -603,7 +603,8 @@ __wt_block_free(WT_SESSION_IMPL *session, "free %" PRIdMAX "/%" PRIdMAX, (intmax_t)offset, (intmax_t)size)); #ifdef HAVE_DIAGNOSTIC - WT_RET(__wt_block_misplaced(session, block, "free", offset, size, 1)); + WT_RET( + __wt_block_misplaced(session, block, "free", offset, size, true)); #endif WT_RET(__wt_block_ext_prealloc(session, 5)); __wt_spin_lock(session, &block->live_lock); @@ -1386,7 +1387,7 @@ __wt_block_extlist_truncate( */ int __wt_block_extlist_init(WT_SESSION_IMPL *session, - WT_EXTLIST *el, const char *name, const char *extname, int track_size) + WT_EXTLIST *el, const char *name, const char *extname, bool track_size) { size_t size; @@ -1434,7 +1435,7 @@ __wt_block_extlist_free(WT_SESSION_IMPL *session, WT_EXTLIST *el) */ static int __block_extlist_dump( - WT_SESSION_IMPL *session, const char *tag, WT_EXTLIST *el, int show_size) + WT_SESSION_IMPL *session, const char *tag, WT_EXTLIST *el, bool show_size) { WT_EXT *ext; WT_SIZE *szp; diff --git a/src/block/block_open.c b/src/block/block_open.c index fbd1b8e465e..e1f3e6de0fe 100644 --- a/src/block/block_open.c +++ b/src/block/block_open.c @@ -22,7 +22,8 @@ __wt_block_manager_truncate( WT_FH *fh; /* Open the underlying file handle. */ - WT_RET(__wt_open(session, filename, 0, 0, WT_FILE_TYPE_DATA, &fh)); + WT_RET(__wt_open( + session, filename, false, false, WT_FILE_TYPE_DATA, &fh)); /* Truncate the file. */ WT_ERR(__wt_block_truncate(session, fh, (wt_off_t)0)); @@ -53,7 +54,8 @@ __wt_block_manager_create( WT_DECL_RET; WT_DECL_ITEM(tmp); WT_FH *fh; - int exists, suffix; + int suffix; + bool exists; char *path; /* @@ -65,8 +67,8 @@ __wt_block_manager_create( * in our space. Move any existing files out of the way and complain. */ for (;;) { - if ((ret = __wt_open( - session, filename, 1, 1, WT_FILE_TYPE_DATA, &fh)) == 0) + if ((ret = __wt_open(session, + filename, true, true, WT_FILE_TYPE_DATA, &fh)) == 0) break; WT_ERR_TEST(ret != EEXIST, ret); @@ -149,7 +151,7 @@ __block_destroy(WT_SESSION_IMPL *session, WT_BLOCK *block) * Configure first-fit allocation. */ void -__wt_block_configure_first_fit(WT_BLOCK *block, int on) +__wt_block_configure_first_fit(WT_BLOCK *block, bool on) { /* * Switch to first-fit allocation so we rewrite blocks at the start of @@ -170,7 +172,7 @@ __wt_block_configure_first_fit(WT_BLOCK *block, int on) int __wt_block_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], - int forced_salvage, int readonly, uint32_t allocsize, WT_BLOCK **blockp) + bool forced_salvage, bool readonly, uint32_t allocsize, WT_BLOCK **blockp) { WT_BLOCK *block; WT_CONFIG_ITEM cval; @@ -247,7 +249,7 @@ __wt_block_open(WT_SESSION_IMPL *session, #endif /* Open the underlying file handle. */ - WT_ERR(__wt_open(session, filename, 0, 0, + WT_ERR(__wt_open(session, filename, false, false, readonly ? WT_FILE_TYPE_CHECKPOINT : WT_FILE_TYPE_DATA, &block->fh)); diff --git a/src/block/block_read.c b/src/block/block_read.c index 9f7c869dd38..4b32e02a73a 100644 --- a/src/block/block_read.c +++ b/src/block/block_read.c @@ -20,7 +20,7 @@ __wt_bm_preload(WT_BM *bm, WT_DECL_RET; wt_off_t offset; uint32_t cksum, size; - int mapped; + bool mapped; WT_UNUSED(addr_size); block = bm->block; @@ -63,9 +63,9 @@ __wt_bm_read(WT_BM *bm, WT_SESSION_IMPL *session, WT_ITEM *buf, const uint8_t *addr, size_t addr_size) { WT_BLOCK *block; - int mapped; wt_off_t offset; uint32_t cksum, size; + bool mapped; WT_UNUSED(addr_size); block = bm->block; diff --git a/src/block/block_slvg.c b/src/block/block_slvg.c index c8ed0b08aab..9f3093c741d 100644 --- a/src/block/block_slvg.c +++ b/src/block/block_slvg.c @@ -66,7 +66,7 @@ int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block) { /* Discard the checkpoint. */ - return (__wt_block_checkpoint_unload(session, block, 0)); + return (__wt_block_checkpoint_unload(session, block, false)); } /* @@ -165,7 +165,7 @@ err: __wt_scr_free(session, &tmp); */ int __wt_block_salvage_valid(WT_SESSION_IMPL *session, - WT_BLOCK *block, uint8_t *addr, size_t addr_size, int valid) + WT_BLOCK *block, uint8_t *addr, size_t addr_size, bool valid) { wt_off_t offset; uint32_t size, cksum; diff --git a/src/block/block_vrfy.c b/src/block/block_vrfy.c index e5233f0e47f..9904dcccd14 100644 --- a/src/block/block_vrfy.c +++ b/src/block/block_vrfy.c @@ -12,7 +12,7 @@ static int __verify_ckptfrag_add( WT_SESSION_IMPL *, WT_BLOCK *, wt_off_t, wt_off_t); static int __verify_ckptfrag_chk(WT_SESSION_IMPL *, WT_BLOCK *); static int __verify_filefrag_add( - WT_SESSION_IMPL *, WT_BLOCK *, const char *, wt_off_t, wt_off_t, int); + WT_SESSION_IMPL *, WT_BLOCK *, const char *, wt_off_t, wt_off_t, bool); static int __verify_filefrag_chk(WT_SESSION_IMPL *, WT_BLOCK *); static int __verify_last_avail(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); static int __verify_last_truncate(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); @@ -97,7 +97,7 @@ __wt_block_verify_start(WT_SESSION_IMPL *session, * set of checkpoints. */ WT_RET(__wt_block_extlist_init( - session, &block->verify_alloc, "verify", "alloc", 0)); + session, &block->verify_alloc, "verify", "alloc", false)); /* * The only checkpoint avail list we care about is the last one written; @@ -133,8 +133,9 @@ __verify_last_avail(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckpt) WT_ERR(__wt_block_extlist_read_avail( session, block, el, ci->file_size)); WT_EXT_FOREACH(ext, el->off) - if ((ret = __verify_filefrag_add(session, block, - "avail-list chunk", ext->off, ext->size, 1)) != 0) + if ((ret = __verify_filefrag_add( + session, block, "avail-list chunk", + ext->off, ext->size, true)) != 0) break; } @@ -209,16 +210,16 @@ __wt_verify_ckpt_load( */ if (ci->root_offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "checkpoint", - ci->root_offset, (wt_off_t)ci->root_size, 1)); + ci->root_offset, (wt_off_t)ci->root_size, true)); if (ci->alloc.offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "alloc list", - ci->alloc.offset, (wt_off_t)ci->alloc.size, 1)); + ci->alloc.offset, (wt_off_t)ci->alloc.size, true)); if (ci->avail.offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "avail list", - ci->avail.offset, (wt_off_t)ci->avail.size, 1)); + ci->avail.offset, (wt_off_t)ci->avail.size, true)); if (ci->discard.offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "discard list", - ci->discard.offset, (wt_off_t)ci->discard.size, 1)); + ci->discard.offset, (wt_off_t)ci->discard.size, true)); /* * Checkpoint verification is similar to deleting checkpoints. As we @@ -325,7 +326,8 @@ __wt_block_verify_addr(WT_SESSION_IMPL *session, WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); /* Add to the per-file list. */ - WT_RET(__verify_filefrag_add(session, block, NULL, offset, size, 0)); + WT_RET( + __verify_filefrag_add(session, block, NULL, offset, size, false)); /* * It's tempting to try and flag a page as "verified" when we read it. @@ -354,7 +356,7 @@ __wt_block_verify_addr(WT_SESSION_IMPL *session, */ static int __verify_filefrag_add(WT_SESSION_IMPL *session, WT_BLOCK *block, - const char *type, wt_off_t offset, wt_off_t size, int nodup) + const char *type, wt_off_t offset, wt_off_t size, bool nodup) { uint64_t f, frag, frags, i; diff --git a/src/block/block_write.c b/src/block/block_write.c index 2dcea87aef7..c6115f1446d 100644 --- a/src/block/block_write.c +++ b/src/block/block_write.c @@ -40,10 +40,10 @@ __wt_block_truncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t len) */ static inline int __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, - WT_FH *fh, wt_off_t offset, size_t align_size, int *release_lockp) + WT_FH *fh, wt_off_t offset, size_t align_size, bool *release_lockp) { WT_DECL_RET; - int locked; + bool locked; /* * The locking in this function is messy: by definition, the live system @@ -58,7 +58,7 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, * need a lock after all, we re-acquire the lock and set release_lock so * our caller knows to release it. */ - locked = 1; + locked = true; /* If not configured to extend the file, we're done. */ if (fh->extend_len == 0) @@ -97,7 +97,7 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, * over the extend call.) */ if (!fh->fallocate_requires_locking && *release_lockp) { - *release_lockp = locked = 0; + *release_lockp = locked = false; __wt_spin_unlock(session, &block->live_lock); } @@ -122,7 +122,7 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, */ if (!locked) { __wt_spin_lock(session, &block->live_lock); - *release_lockp = 1; + *release_lockp = true; } /* @@ -203,7 +203,7 @@ __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_FH *fh; size_t align_size; wt_off_t offset; - int local_locked; + bool local_locked; blk = WT_BLOCK_HEADER_REF(buf->mem); fh = block->fh; diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c index b1155d06826..4d93604d886 100644 --- a/src/conn/conn_api.c +++ b/src/conn/conn_api.c @@ -818,12 +818,12 @@ __conn_load_extension( WT_DLH *dlh; WT_SESSION_IMPL *session; int (*load)(WT_CONNECTION *, WT_CONFIG_ARG *); - int is_local; + bool is_local; const char *init_name, *terminate_name; dlh = NULL; init_name = terminate_name = NULL; - is_local = (strcmp(path, "local") == 0); + is_local = strcmp(path, "local") == 0; conn = (WT_CONNECTION_IMPL *)wt_conn; CONNECTION_API_CALL(conn, session, load_extension, config, cfg); @@ -1048,7 +1048,7 @@ __conn_reconfigure(WT_CONNECTION *wt_conn, const char *config) /* Second, reconfigure the system. */ WT_ERR(__conn_statistics_config(session, cfg)); WT_ERR(__wt_async_reconfig(session, cfg)); - WT_ERR(__wt_cache_config(session, 1, cfg)); + WT_ERR(__wt_cache_config(session, true, cfg)); WT_ERR(__wt_checkpoint_server_create(session, cfg)); WT_ERR(__wt_lsm_manager_reconfig(session, cfg)); WT_ERR(__wt_statlog_create(session, cfg)); @@ -1139,13 +1139,13 @@ __conn_config_check_version(WT_SESSION_IMPL *session, const char *config) */ static int __conn_config_file(WT_SESSION_IMPL *session, - const char *filename, int is_user, const char **cfg, WT_ITEM *cbuf) + const char *filename, bool is_user, const char **cfg, WT_ITEM *cbuf) { WT_DECL_RET; WT_FH *fh; size_t len; wt_off_t size; - int exist, quoted; + bool exist, quoted; char *p, *t; fh = NULL; @@ -1156,7 +1156,7 @@ __conn_config_file(WT_SESSION_IMPL *session, return (0); /* Open the configuration file. */ - WT_RET(__wt_open(session, filename, 0, 0, 0, &fh)); + WT_RET(__wt_open(session, filename, false, false, 0, &fh)); WT_ERR(__wt_filesize(session, fh, &size)); if (size == 0) goto err; @@ -1193,7 +1193,7 @@ __conn_config_file(WT_SESSION_IMPL *session, * escaped. Comment lines (an unescaped newline where the next non- * white-space character is a hash), are discarded. */ - for (quoted = 0, p = t = cbuf->mem; len > 0;) { + for (quoted = false, p = t = cbuf->mem; len > 0;) { /* * Backslash pairs pass through untouched, unless immediately * preceding a newline, in which case both the backslash and @@ -1372,14 +1372,14 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[]) WT_FH *fh; size_t len; wt_off_t size; - int exist, is_create; + bool exist, is_create; char buf[256]; conn = S2C(session); fh = NULL; WT_RET(__wt_config_gets(session, cfg, "create", &cval)); - is_create = cval.val == 0 ? 0 : 1; + is_create = cval.val != 0; __wt_spin_lock(session, &__wt_process.spinlock); @@ -1435,11 +1435,11 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[]) * file exists in the directory, create the lock file, covering the case * of a hot backup. */ - exist = 0; + exist = false; if (!is_create) WT_ERR(__wt_exist(session, WT_WIREDTIGER, &exist)); WT_ERR(__wt_open(session, - WT_SINGLETHREAD, is_create || exist, 0, 0, &conn->lock_fh)); + WT_SINGLETHREAD, is_create || exist, false, 0, &conn->lock_fh)); /* * Lock a byte of the file: if we don't get the lock, some other process @@ -1467,7 +1467,7 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[]) strlen(WT_SINGLETHREAD_STRING), WT_SINGLETHREAD_STRING)); /* We own the lock file, optionally create the WiredTiger file. */ - WT_ERR(__wt_open(session, WT_WIREDTIGER, is_create, 0, 0, &fh)); + WT_ERR(__wt_open(session, WT_WIREDTIGER, is_create, false, 0, &fh)); /* * Lock the WiredTiger file (for backward compatibility reasons as @@ -1650,7 +1650,7 @@ __conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[]) WT_CONFIG parser; WT_CONFIG_ITEM cval, k, v; WT_DECL_RET; - int exist; + bool exist; const char *base_config; fp = NULL; @@ -1881,9 +1881,10 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, /* Ignore the base_config file if we config_base set to false. */ if (config_base_set != 0) - WT_ERR(__conn_config_file(session, WT_BASECONFIG, 0, cfg, i1)); + WT_ERR( + __conn_config_file(session, WT_BASECONFIG, false, cfg, i1)); __conn_config_append(cfg, config); - WT_ERR(__conn_config_file(session, WT_USERCONFIG, 1, cfg, i2)); + WT_ERR(__conn_config_file(session, WT_USERCONFIG, true, cfg, i2)); WT_ERR(__conn_config_env(session, cfg, i3)); /* diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c index a00b4f35562..0c1cfa60b25 100644 --- a/src/conn/conn_cache.c +++ b/src/conn/conn_cache.c @@ -13,7 +13,7 @@ * Configure the underlying cache. */ static int -__cache_config_local(WT_SESSION_IMPL *session, int shared, const char *cfg[]) +__cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[]) { WT_CACHE *cache; WT_CONFIG_ITEM cval; @@ -76,7 +76,7 @@ __cache_config_local(WT_SESSION_IMPL *session, int shared, const char *cfg[]) * Configure or reconfigure the current cache and shared cache. */ int -__wt_cache_config(WT_SESSION_IMPL *session, int reconfigure, const char *cfg[]) +__wt_cache_config(WT_SESSION_IMPL *session, bool reconfigure, const char *cfg[]) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; @@ -137,7 +137,7 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]) cache = conn->cache; /* Use a common routine for run-time configuration options. */ - WT_RET(__wt_cache_config(session, 0, cfg)); + WT_RET(__wt_cache_config(session, false, cfg)); /* * The target size must be lower than the trigger size or we will never diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c index aaae58ef168..e27d4f983aa 100644 --- a/src/conn/conn_cache_pool.c +++ b/src/conn/conn_cache_pool.c @@ -35,9 +35,9 @@ #define WT_CACHE_POOL_READ_MULTIPLIER 1 static int __cache_pool_adjust( - WT_SESSION_IMPL *, uint64_t, uint64_t, int, int *); + WT_SESSION_IMPL *, uint64_t, uint64_t, bool, bool *); static int __cache_pool_assess(WT_SESSION_IMPL *, uint64_t *); -static int __cache_pool_balance(WT_SESSION_IMPL *, int); +static int __cache_pool_balance(WT_SESSION_IMPL *, bool); /* * __wt_cache_pool_config -- @@ -51,17 +51,17 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg) WT_CONNECTION_IMPL *conn, *entry; WT_DECL_RET; char *pool_name; - int created, updating; + bool created, updating; uint64_t chunk, quota, reserve, size, used_cache; conn = S2C(session); - created = updating = 0; + created = updating = false; pool_name = NULL; cp = NULL; size = 0; if (F_ISSET(conn, WT_CONN_CACHE_POOL)) - updating = 1; + updating = true; else { WT_RET(__wt_config_gets_none( session, cfg, "shared_cache.name", &cval)); @@ -99,7 +99,7 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg) WT_ASSERT(session, !updating); /* Create a cache pool. */ WT_ERR(__wt_calloc_one(session, &cp)); - created = 1; + created = true; cp->name = pool_name; pool_name = NULL; /* Belongs to the cache pool now. */ TAILQ_INIT(&cp->cache_pool_qh); @@ -299,21 +299,21 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) WT_CONNECTION_IMPL *conn, *entry; WT_DECL_RET; WT_SESSION *wt_session; - int cp_locked, found; + bool cp_locked, found; conn = S2C(session); cache = conn->cache; - cp_locked = found = 0; + cp_locked = found = false; cp = __wt_process.cache_pool; if (!F_ISSET(conn, WT_CONN_CACHE_POOL)) return (0); __wt_spin_lock(session, &cp->cache_pool_lock); - cp_locked = 1; + cp_locked = true; TAILQ_FOREACH(entry, &cp->cache_pool_qh, cpq) if (entry == conn) { - found = 1; + found = true; break; } @@ -336,7 +336,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * operation. */ __wt_spin_unlock(session, &cp->cache_pool_lock); - cp_locked = 0; + cp_locked = false; F_CLR(cache, WT_CACHE_POOL_RUN); WT_TRET(__wt_cond_signal(session, cp->cache_pool_cond)); @@ -351,7 +351,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * participant. */ __wt_spin_lock(session, &cp->cache_pool_lock); - cp_locked = 1; + cp_locked = true; } /* @@ -383,7 +383,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) __wt_process.cache_pool = NULL; __wt_spin_unlock(session, &__wt_process.spinlock); __wt_spin_unlock(session, &cp->cache_pool_lock); - cp_locked = 0; + cp_locked = false; /* Now free the pool. */ __wt_free(session, cp->name); @@ -413,11 +413,11 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * effectively used. */ static int -__cache_pool_balance(WT_SESSION_IMPL *session, int forward) +__cache_pool_balance(WT_SESSION_IMPL *session, bool forward) { WT_CACHE_POOL *cp; WT_DECL_RET; - int adjusted; + bool adjusted; uint64_t bump_threshold, highest; cp = __wt_process.cache_pool; @@ -557,19 +557,19 @@ __cache_pool_assess(WT_SESSION_IMPL *session, uint64_t *phighest) */ static int __cache_pool_adjust(WT_SESSION_IMPL *session, - uint64_t highest, uint64_t bump_threshold, int forward, int *adjustedp) + uint64_t highest, uint64_t bump_threshold, bool forward, bool *adjustedp) { WT_CACHE_POOL *cp; WT_CACHE *cache; WT_CONNECTION_IMPL *entry; uint64_t adjustment, highest_percentile, pressure, reserved, smallest; - int busy, pool_full, grow; u_int pct_full; + bool busy, pool_full, grow; - *adjustedp = 0; + *adjustedp = false; cp = __wt_process.cache_pool; - grow = 0; - pool_full = (cp->currently_used >= cp->size); + grow = false; + pool_full = cp->currently_used >= cp->size; /* Highest as a percentage, avoid 0 */ highest_percentile = (highest / 100) + 1; @@ -615,7 +615,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, * - the reserved size has been adjusted */ if (entry->cache_size < reserved) { - grow = 1; + grow = true; adjustment = reserved - entry->cache_size; /* * Conditions for reducing the amount of resources for an @@ -632,7 +632,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, } else if (pool_full && !busy && entry->cache_size > reserved && pressure < WT_CACHE_POOL_REDUCE_THRESHOLD && highest > 1) { - grow = 0; + grow = false; /* * Don't drop the size down too much - or it can * trigger aggressive eviction in the connection, @@ -665,7 +665,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, (entry->cache_size * cache->eviction_target) / 100 && (pressure > bump_threshold || cp->currently_used < cp->size * 0.5)) { - grow = 1; + grow = true; adjustment = WT_MIN(WT_MIN(cp->chunk, cp->size - cp->currently_used), cache->cp_quota - entry->cache_size); @@ -682,7 +682,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, * gradually without stalling application threads. */ if (adjustment > 0) { - *adjustedp = 1; + *adjustedp = true; if (grow) { cache->cp_skip_count = WT_CACHE_POOL_BUMP_SKIPS; entry->cache_size += adjustment; @@ -720,13 +720,13 @@ __wt_cache_pool_server(void *arg) WT_CACHE_POOL *cp; WT_DECL_RET; WT_SESSION_IMPL *session; - int forward; + bool forward; session = (WT_SESSION_IMPL *)arg; cp = __wt_process.cache_pool; cache = S2C(session)->cache; - forward = 1; + forward = true; while (F_ISSET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE) && F_ISSET(cache, WT_CACHE_POOL_RUN)) { diff --git a/src/conn/conn_ckpt.c b/src/conn/conn_ckpt.c index 74f27d8bd18..a2e985ee1ea 100644 --- a/src/conn/conn_ckpt.c +++ b/src/conn/conn_ckpt.c @@ -15,7 +15,7 @@ static int __ckpt_server_start(WT_CONNECTION_IMPL *); * Parse and setup the checkpoint server options. */ static int -__ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, int *startp) +__ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, bool *startp) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; @@ -38,10 +38,10 @@ __ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, int *startp) if ((conn->ckpt_usecs == 0 && conn->ckpt_logsize == 0) || (conn->ckpt_logsize && conn->ckpt_usecs == 0 && !FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))) { - *startp = 0; + *startp = false; return (0); } - *startp = 1; + *startp = true; /* * The application can specify a checkpoint name, which we ignore if @@ -161,7 +161,7 @@ int __wt_checkpoint_server_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; - int start; + bool start; conn = S2C(session); start = 0; diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c index 58211eb33c5..794fbe23c90 100644 --- a/src/conn/conn_dhandle.c +++ b/src/conn/conn_dhandle.c @@ -145,16 +145,16 @@ __conn_dhandle_mark_dead(WT_SESSION_IMPL *session) * Sync and close the underlying btree handle. */ int -__wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force) +__wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, bool final, bool force) { WT_BTREE *btree; WT_DATA_HANDLE *dhandle; WT_DECL_RET; - int marked_dead, no_schema_lock; + bool marked_dead, no_schema_lock; btree = S2BT(session); dhandle = session->dhandle; - marked_dead = 0; + marked_dead = false; if (!F_ISSET(dhandle, WT_DHANDLE_OPEN)) return (0); @@ -166,9 +166,9 @@ __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force) * we might deadlock with a thread that has the schema lock and wants * a handle lock (specifically, checkpoint). */ - no_schema_lock = 0; + no_schema_lock = false; if (!F_ISSET(session, WT_SESSION_LOCKED_SCHEMA)) { - no_schema_lock = 1; + no_schema_lock = true; F_SET(session, WT_SESSION_NO_SCHEMA_LOCK); } @@ -193,7 +193,7 @@ __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force) WT_BTREE_SALVAGE | WT_BTREE_UPGRADE | WT_BTREE_VERIFY)) { if (force && (btree->bm == NULL || btree->bm->map == NULL)) { WT_ERR(__conn_dhandle_mark_dead(session)); - marked_dead = 1; + marked_dead = true; } else WT_ERR(__wt_checkpoint_close(session, final)); } @@ -321,7 +321,7 @@ __wt_conn_btree_open( * in the tree that can block the close. */ if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) - WT_RET(__wt_conn_btree_sync_and_close(session, 0, 0)); + WT_RET(__wt_conn_btree_sync_and_close(session, false, false)); /* Discard any previous configuration, set up the new configuration. */ __conn_btree_config_clear(session); @@ -383,7 +383,7 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle, */ int __wt_conn_btree_apply(WT_SESSION_IMPL *session, - int apply_checkpoints, const char *uri, + bool apply_checkpoints, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]) { WT_CONNECTION_IMPL *conn; @@ -522,7 +522,7 @@ __wt_conn_btree_apply_single(WT_SESSION_IMPL *session, */ int __wt_conn_dhandle_close_all( - WT_SESSION_IMPL *session, const char *uri, int force) + WT_SESSION_IMPL *session, const char *uri, bool force) { WT_CONNECTION_IMPL *conn; WT_DATA_HANDLE *dhandle; @@ -556,7 +556,7 @@ __wt_conn_dhandle_close_all( if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) { if ((ret = __wt_meta_track_sub_on(session)) == 0) ret = __wt_conn_btree_sync_and_close( - session, 0, force); + session, false, force); /* * If the close succeeded, drop any locks it acquired. @@ -582,7 +582,7 @@ err: session->dhandle = NULL; * Remove a handle from the shared list. */ static int -__conn_dhandle_remove(WT_SESSION_IMPL *session, int final) +__conn_dhandle_remove(WT_SESSION_IMPL *session, bool final) { WT_CONNECTION_IMPL *conn; WT_DATA_HANDLE *dhandle; @@ -610,7 +610,8 @@ __conn_dhandle_remove(WT_SESSION_IMPL *session, int final) * Close/discard a single data handle. */ int -__wt_conn_dhandle_discard_single(WT_SESSION_IMPL *session, int final, int force) +__wt_conn_dhandle_discard_single( + WT_SESSION_IMPL *session, bool final, bool force) { WT_DATA_HANDLE *dhandle; WT_DECL_RET; @@ -678,7 +679,8 @@ restart: continue; WT_WITH_DHANDLE(session, dhandle, - WT_TRET(__wt_conn_dhandle_discard_single(session, 1, 0))); + WT_TRET(__wt_conn_dhandle_discard_single( + session, true, false))); goto restart; } @@ -694,7 +696,8 @@ restart: /* Close the metadata file handle. */ while ((dhandle = TAILQ_FIRST(&conn->dhqh)) != NULL) WT_WITH_DHANDLE(session, dhandle, - WT_TRET(__wt_conn_dhandle_discard_single(session, 1, 0))); + WT_TRET(__wt_conn_dhandle_discard_single( + session, true, false))); return (ret); } diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c index f4baf6962ef..86b0edca13a 100644 --- a/src/conn/conn_log.c +++ b/src/conn/conn_log.c @@ -42,7 +42,7 @@ __logmgr_sync_cfg(WT_SESSION_IMPL *session, const char **cfg) * Parse and setup the logging server options. */ static int -__logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) +__logmgr_config(WT_SESSION_IMPL *session, const char **cfg, bool *runp) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; @@ -67,7 +67,7 @@ __logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) WT_RET(__wt_strndup(session, cval.str, cval.len, &conn->log_path)); /* We are done if logging isn't enabled. */ - if (*runp == 0) + if (!*runp) return (0); WT_RET(__wt_config_gets(session, cfg, "log.archive", &cval)); @@ -289,12 +289,12 @@ __log_file_server(void *arg) WT_LSN close_end_lsn, min_lsn; WT_SESSION_IMPL *session; uint32_t filenum; - int locked; + bool locked; session = arg; conn = S2C(session); log = conn->log; - locked = 0; + locked = false; while (F_ISSET(conn, WT_CONN_LOG_SERVER_RUN)) { /* * If there is a log file to close, make sure any outstanding @@ -338,14 +338,14 @@ __log_file_server(void *arg) close_end_lsn.offset = 0; WT_ERR(__wt_fsync(session, close_fh)); __wt_spin_lock(session, &log->log_sync_lock); - locked = 1; + locked = true; WT_ERR(__wt_close(session, &close_fh)); WT_ASSERT(session, __wt_log_cmp( &close_end_lsn, &log->sync_lsn) >= 0); log->sync_lsn = close_end_lsn; WT_ERR(__wt_cond_signal( session, log->log_sync_cond)); - locked = 0; + locked = false; __wt_spin_unlock(session, &log->log_sync_lock); } } @@ -366,7 +366,7 @@ __log_file_server(void *arg) if (__wt_log_cmp(&log->bg_sync_lsn, &min_lsn) <= 0) { WT_ERR(__wt_fsync(session, log->log_fh)); __wt_spin_lock(session, &log->log_sync_lock); - locked = 1; + locked = true; /* * The sync LSN could have advanced while we * were writing to disk. @@ -377,7 +377,7 @@ __log_file_server(void *arg) WT_ERR(__wt_cond_signal( session, log->log_sync_cond)); } - locked = 0; + locked = false; __wt_spin_unlock(session, &log->log_sync_lock); } else { WT_ERR(__wt_cond_signal( @@ -609,12 +609,13 @@ __log_server(void *arg) WT_DECL_RET; WT_LOG *log; WT_SESSION_IMPL *session; - int freq_per_sec, signalled; + int freq_per_sec; + bool signalled; session = arg; conn = S2C(session); log = conn->log; - signalled = 0; + signalled = false; /* * Set this to the number of times per second we want to force out the @@ -649,7 +650,7 @@ __log_server(void *arg) * we want to force out log buffers. Only do it once per second * or if the condition was signalled. */ - if (--freq_per_sec <= 0 || signalled != 0) { + if (--freq_per_sec <= 0 || signalled) { freq_per_sec = WT_FORCE_PER_SECOND; /* @@ -696,7 +697,7 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; WT_LOG *log; - int run; + bool run; conn = S2C(session); diff --git a/src/conn/conn_open.c b/src/conn/conn_open.c index 8bc69bb3e80..879ca08beb8 100644 --- a/src/conn/conn_open.c +++ b/src/conn/conn_open.c @@ -116,7 +116,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn) F_SET(conn, WT_CONN_CLOSING); WT_TRET(__wt_checkpoint_server_destroy(session)); - WT_TRET(__wt_statlog_destroy(session, 1)); + WT_TRET(__wt_statlog_destroy(session, true)); WT_TRET(__wt_evict_destroy(session)); /* Shut down the lookaside table, after all eviction is complete. */ diff --git a/src/conn/conn_stat.c b/src/conn/conn_stat.c index 3b188bfd22a..e5599ce0fce 100644 --- a/src/conn/conn_stat.c +++ b/src/conn/conn_stat.c @@ -68,7 +68,7 @@ __wt_conn_stat_init(WT_SESSION_IMPL *session) * Parse and setup the statistics server options. */ static int -__statlog_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) +__statlog_config(WT_SESSION_IMPL *session, const char **cfg, bool *runp) { WT_CONFIG objectconf; WT_CONFIG_ITEM cval, k, v; @@ -82,7 +82,7 @@ __statlog_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) WT_RET(__wt_config_gets(session, cfg, "statistics_log.wait", &cval)); /* Only start the server if wait time is non-zero */ - *runp = (cval.val == 0) ? 0 : 1; + *runp = cval.val != 0; conn->stat_usecs = (uint64_t)cval.val * 1000000; WT_RET(__wt_config_gets( @@ -94,7 +94,7 @@ __statlog_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) * Statistics logging configuration requires either a wait time or an * on-close setting. */ - if (*runp == 0 && !FLD_ISSET(conn->stat_flags, WT_CONN_STAT_ON_CLOSE)) + if (!*runp && !FLD_ISSET(conn->stat_flags, WT_CONN_STAT_ON_CLOSE)) return (0); WT_RET(__wt_config_gets(session, cfg, "statistics_log.sources", &cval)); @@ -145,7 +145,7 @@ err: __stat_sources_free(session, &sources); * Dump out handle/connection statistics. */ static int -__statlog_dump(WT_SESSION_IMPL *session, const char *name, int conn_stats) +__statlog_dump(WT_SESSION_IMPL *session, const char *name, bool conn_stats) { WT_CONNECTION_IMPL *conn; WT_CURSOR *cursor; @@ -218,8 +218,8 @@ __statlog_apply(WT_SESSION_IMPL *session, const char *cfg[]) /* Check for a match on the set of sources. */ for (p = S2C(session)->stat_sources; *p != NULL; ++p) if (WT_PREFIX_MATCH(dhandle->name, *p)) { - WT_WITHOUT_DHANDLE(session, - ret = __statlog_dump(session, dhandle->name, 0)); + WT_WITHOUT_DHANDLE(session, ret = + __statlog_dump(session, dhandle->name, false)); return (ret); } return (0); @@ -238,7 +238,8 @@ __statlog_lsm_apply(WT_SESSION_IMPL *session) #define WT_LSM_TREE_LIST_SLOTS 100 WT_LSM_TREE *lsm_tree, *list[WT_LSM_TREE_LIST_SLOTS]; WT_DECL_RET; - int cnt, locked; + int cnt; + bool locked; char **p; cnt = locked = 0; @@ -258,7 +259,7 @@ __statlog_lsm_apply(WT_SESSION_IMPL *session) * will bump a reference count, so the tree won't go away. */ __wt_spin_lock(session, &S2C(session)->schema_lock); - locked = 1; + locked = true; TAILQ_FOREACH(lsm_tree, &S2C(session)->lsmqh, q) { if (cnt == WT_LSM_TREE_LIST_SLOTS) break; @@ -270,11 +271,11 @@ __statlog_lsm_apply(WT_SESSION_IMPL *session) } } __wt_spin_unlock(session, &S2C(session)->schema_lock); - locked = 0; + locked = false; while (cnt > 0) { --cnt; - WT_TRET(__statlog_dump(session, list[cnt]->name, 0)); + WT_TRET(__statlog_dump(session, list[cnt]->name, false)); __wt_lsm_tree_release(session, list[cnt]); } @@ -329,7 +330,7 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp) conn->stat_stamp = tmp->mem; /* Dump the connection statistics. */ - WT_RET(__statlog_dump(session, conn->home, 1)); + WT_RET(__statlog_dump(session, conn->home, true)); /* * Lock the schema and walk the list of open handles, dumping @@ -338,7 +339,7 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp) if (conn->stat_sources != NULL) { WT_WITH_HANDLE_LIST_LOCK(session, ret = __wt_conn_btree_apply( - session, 0, NULL, __statlog_apply, NULL)); + session, false, NULL, __statlog_apply, NULL)); WT_RET(ret); } @@ -479,7 +480,7 @@ int __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; - int start; + bool start; conn = S2C(session); start = 0; @@ -490,7 +491,7 @@ __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]) * configuration changes - but that makes our lives easier. */ if (conn->stat_session != NULL) - WT_RET(__wt_statlog_destroy(session, 0)); + WT_RET(__wt_statlog_destroy(session, false)); WT_RET(__statlog_config(session, cfg, &start)); if (start) @@ -504,7 +505,7 @@ __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]) * Destroy the statistics server thread. */ int -__wt_statlog_destroy(WT_SESSION_IMPL *session, int is_close) +__wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; diff --git a/src/conn/conn_sweep.c b/src/conn/conn_sweep.c index 925e1c68815..73680e0b70b 100644 --- a/src/conn/conn_sweep.c +++ b/src/conn/conn_sweep.c @@ -100,7 +100,7 @@ __sweep_expire_one(WT_SESSION_IMPL *session) * handle. Closing the handle decrements the open file count, * meaning the close loop won't overrun the configured minimum. */ - ret = __wt_conn_btree_sync_and_close(session, 0, 1); + ret = __wt_conn_btree_sync_and_close(session, false, true); if (evict_reset) __wt_evict_file_exclusive_off(session); @@ -172,7 +172,7 @@ __sweep_discard_trees(WT_SESSION_IMPL *session, u_int *dead_handlesp) /* If the handle is marked "dead", flush it from cache. */ WT_WITH_DHANDLE(session, dhandle, ret = - __wt_conn_btree_sync_and_close(session, 0, 0)); + __wt_conn_btree_sync_and_close(session, false, false)); /* We closed the btree handle. */ if (ret == 0) { @@ -207,7 +207,7 @@ __sweep_remove_one(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle) WT_ERR(EBUSY); WT_WITH_DHANDLE(session, dhandle, - ret = __wt_conn_dhandle_discard_single(session, 0, 1)); + ret = __wt_conn_dhandle_discard_single(session, false, true)); /* * If the handle was not successfully discarded, unlock it and diff --git a/src/cursor/cur_backup.c b/src/cursor/cur_backup.c index e3097c0095f..f910560794b 100644 --- a/src/cursor/cur_backup.c +++ b/src/cursor/cur_backup.c @@ -191,7 +191,8 @@ __backup_start( { WT_CONNECTION_IMPL *conn; WT_DECL_RET; - int exist, log_only, target_list; + bool exist; + int log_only, target_list; conn = S2C(session); diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index ff87130a455..a148b8ebc3c 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -11,9 +11,9 @@ static int __evict_clear_all_walks(WT_SESSION_IMPL *); static int __evict_clear_walks(WT_SESSION_IMPL *); static int WT_CDECL __evict_lru_cmp(const void *, const void *); -static int __evict_lru_pages(WT_SESSION_IMPL *, int); +static int __evict_lru_pages(WT_SESSION_IMPL *, bool); static int __evict_lru_walk(WT_SESSION_IMPL *); -static int __evict_page(WT_SESSION_IMPL *, int); +static int __evict_page(WT_SESSION_IMPL *, bool); static int __evict_pass(WT_SESSION_IMPL *); static int __evict_walk(WT_SESSION_IMPL *); static int __evict_walk_file(WT_SESSION_IMPL *, u_int *); @@ -399,7 +399,7 @@ __evict_worker(void *arg) while (F_ISSET(conn, WT_CONN_EVICTION_RUN) && F_ISSET(worker, WT_EVICT_WORKER_RUN)) { /* Don't spin in a busy loop if there is no work to do */ - if ((ret = __evict_lru_pages(session, 0)) == WT_NOTFOUND) + if ((ret = __evict_lru_pages(session, false)) == WT_NOTFOUND) WT_ERR(__wt_cond_wait( session, cache->evict_waiter_cond, 10000)); else @@ -775,7 +775,7 @@ __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session) * Get pages from the LRU queue to evict. */ static int -__evict_lru_pages(WT_SESSION_IMPL *session, int is_server) +__evict_lru_pages(WT_SESSION_IMPL *session, bool is_server) { WT_DECL_RET; @@ -905,7 +905,7 @@ __evict_server_work(WT_SESSION_IMPL *session) cache->evict_current != NULL) __wt_yield(); } else - WT_RET_NOTFOUND_OK(__evict_lru_pages(session, 1)); + WT_RET_NOTFOUND_OK(__evict_lru_pages(session, true)); return (0); } @@ -923,12 +923,12 @@ __evict_walk(WT_SESSION_IMPL *session) WT_DATA_HANDLE *dhandle; WT_DECL_RET; u_int max_entries, prev_slot, retries, slot, start_slot, spins; - int incr, dhandle_locked; + bool dhandle_locked, incr; conn = S2C(session); cache = S2C(session)->cache; dhandle = NULL; - incr = dhandle_locked = 0; + dhandle_locked = incr = false; retries = 0; if (cache->evict_current == NULL) @@ -967,7 +967,7 @@ retry: while (slot < max_entries && ret == 0) { } if (ret != 0) break; - dhandle_locked = 1; + dhandle_locked = true; } if (dhandle == NULL) { @@ -985,7 +985,7 @@ retry: while (slot < max_entries && ret == 0) { WT_ASSERT(session, dhandle->session_inuse > 0); (void)__wt_atomic_subi32( &dhandle->session_inuse, 1); - incr = 0; + incr = false; } dhandle = TAILQ_NEXT(dhandle, q); } @@ -1029,9 +1029,9 @@ retry: while (slot < max_entries && ret == 0) { prev_slot = slot; (void)__wt_atomic_addi32(&dhandle->session_inuse, 1); - incr = 1; + incr = true; __wt_spin_unlock(session, &conn->dhandle_lock); - dhandle_locked = 0; + dhandle_locked = false; __wt_spin_lock(session, &cache->evict_walk_lock); @@ -1064,12 +1064,12 @@ retry: while (slot < max_entries && ret == 0) { WT_ASSERT(session, dhandle->session_inuse > 0); (void)__wt_atomic_subi32(&dhandle->session_inuse, 1); - incr = 0; + incr = false; } if (dhandle_locked) { __wt_spin_unlock(session, &conn->dhandle_lock); - dhandle_locked = 0; + dhandle_locked = false; } /* @@ -1135,7 +1135,8 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) WT_REF *ref; uint64_t pages_walked; uint32_t walk_flags; - int enough, internal_pages, modified, restarts; + int internal_pages, restarts; + bool enough, modified; conn = S2C(session); btree = S2BT(session); @@ -1143,7 +1144,8 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) start = cache->evict_queue + *slotp; end = WT_MIN(start + WT_EVICT_WALK_PER_FILE, cache->evict_queue + cache->evict_slots); - enough = internal_pages = restarts = 0; + internal_pages = restarts = 0; + enough = false; walk_flags = WT_READ_CACHE | WT_READ_NO_EVICT | WT_READ_NO_GEN | WT_READ_NO_WAIT; @@ -1167,7 +1169,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) evict < end && !enough && (ret == 0 || ret == WT_NOTFOUND); ret = __wt_tree_walk( session, &btree->evict_ref, &pages_walked, walk_flags)) { - enough = (pages_walked > WT_EVICT_MAX_PER_FILE); + enough = pages_walked > WT_EVICT_MAX_PER_FILE; if ((ref = btree->evict_ref) == NULL) { if (++restarts == 2 || enough) break; @@ -1298,7 +1300,7 @@ fast: /* If the page can't be evicted, give up. */ */ static int __evict_get_ref( - WT_SESSION_IMPL *session, int is_server, WT_BTREE **btreep, WT_REF **refp) + WT_SESSION_IMPL *session, bool is_server, WT_BTREE **btreep, WT_REF **refp) { WT_CACHE *cache; WT_EVICT_ENTRY *evict; @@ -1380,7 +1382,7 @@ __evict_get_ref( * Called by both eviction and application threads to evict a page. */ static int -__evict_page(WT_SESSION_IMPL *session, int is_server) +__evict_page(WT_SESSION_IMPL *session, bool is_server) { WT_BTREE *btree; WT_CACHE *cache; @@ -1454,8 +1456,8 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) WT_DECL_RET; WT_TXN_GLOBAL *txn_global; WT_TXN_STATE *txn_state; - int count, q_found; - bool txn_busy; + int count; + bool q_found, txn_busy; conn = S2C(session); cache = conn->cache; @@ -1505,14 +1507,14 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) } /* Evict a page. */ - q_found = 0; - switch (ret = __evict_page(session, 0)) { + q_found = false; + switch (ret = __evict_page(session, false)) { case 0: cache->app_evicts++; if (--count == 0) return (0); - q_found = 1; + q_found = true; break; case EBUSY: continue; diff --git a/src/evict/evict_page.c b/src/evict/evict_page.c index 04c6fe6273f..e94281cb525 100644 --- a/src/evict/evict_page.c +++ b/src/evict/evict_page.c @@ -9,7 +9,7 @@ #include "wt_internal.h" static int __evict_page_dirty_update(WT_SESSION_IMPL *, WT_REF *, bool); -static int __evict_review(WT_SESSION_IMPL *, WT_REF *, int *, bool); +static int __evict_review(WT_SESSION_IMPL *, WT_REF *, bool *, bool); /* * __evict_exclusive_clear -- @@ -55,7 +55,7 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) WT_DECL_RET; WT_PAGE *page; WT_PAGE_MODIFY *mod; - int forced_eviction, inmem_split; + bool forced_eviction, inmem_split; conn = S2C(session); @@ -64,7 +64,7 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) page = ref->page; forced_eviction = page->read_gen == WT_READGEN_OLDEST; - inmem_split = 0; + inmem_split = false; WT_RET(__wt_verbose(session, WT_VERB_EVICT, "page %p (%s)", page, __wt_page_type_string(page->type))); @@ -297,7 +297,7 @@ __evict_child_check(WT_SESSION_IMPL *session, WT_REF *parent) */ static int __evict_review( - WT_SESSION_IMPL *session, WT_REF *ref, int *inmem_splitp, bool closing) + WT_SESSION_IMPL *session, WT_REF *ref, bool *inmem_splitp, bool closing) { WT_DECL_RET; WT_PAGE *page; diff --git a/src/include/block.h b/src/include/block.h index 037e59d8d61..41f2423206b 100644 --- a/src/include/block.h +++ b/src/include/block.h @@ -54,7 +54,7 @@ struct __wt_extlist { wt_off_t offset; /* Written extent offset */ uint32_t cksum, size; /* Written extent cksum, size */ - int track_size; /* Maintain per-size skiplist */ + bool track_size; /* Maintain per-size skiplist */ WT_EXT *last; /* Cached last element */ diff --git a/src/include/btree.i b/src/include/btree.i index b35a0cf37b1..75e4100fda0 100644 --- a/src/include/btree.i +++ b/src/include/btree.i @@ -1035,14 +1035,14 @@ __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, int *inmem_splitp) + WT_PAGE *page, int check_splits, bool *inmem_splitp) { WT_BTREE *btree; WT_PAGE_MODIFY *mod; WT_TXN_GLOBAL *txn_global; if (inmem_splitp != NULL) - *inmem_splitp = 0; + *inmem_splitp = false; btree = S2BT(session); mod = page->modify; @@ -1059,7 +1059,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, */ if (__wt_page_can_split(session, page)) { if (inmem_splitp != NULL) - *inmem_splitp = 1; + *inmem_splitp = true; return (true); } diff --git a/src/include/extern.h b/src/include/extern.h index b5172dbcb0b..e9413b5d33c 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -11,13 +11,13 @@ extern int __wt_async_op_init(WT_SESSION_IMPL *session); extern WT_THREAD_RET __wt_async_worker(void *arg); extern int __wt_block_addr_to_buffer(WT_BLOCK *block, uint8_t **pp, wt_off_t offset, uint32_t size, uint32_t cksum); extern int __wt_block_buffer_to_addr(WT_BLOCK *block, const uint8_t *p, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump); -extern int __wt_block_addr_invalid(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, int live); +extern int __wt_block_addr_invalid(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool live); extern int __wt_block_addr_string(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, const uint8_t *addr, size_t addr_size); extern int __wt_block_buffer_to_ckpt(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *p, WT_BLOCK_CKPT *ci); extern int __wt_block_ckpt_to_buffer(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t **pp, WT_BLOCK_CKPT *ci); extern int __wt_block_ckpt_init( WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci, const char *name); extern int __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, uint8_t *root_addr, size_t *root_addr_sizep, bool checkpoint); -extern int __wt_block_checkpoint_unload( WT_SESSION_IMPL *session, WT_BLOCK *block, int checkpoint); +extern int __wt_block_checkpoint_unload( WT_SESSION_IMPL *session, WT_BLOCK *block, bool checkpoint); extern void __wt_block_ckpt_destroy(WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci); extern int __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum); extern int __wt_block_checkpoint_resolve(WT_SESSION_IMPL *session, WT_BLOCK *block); @@ -25,7 +25,7 @@ extern int __wt_block_compact_start(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp); extern int __wt_block_compact_page_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool *skipp); -extern int __wt_block_misplaced(WT_SESSION_IMPL *session, WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, int live); +extern int __wt_block_misplaced(WT_SESSION_IMPL *session, WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, bool live); extern int __wt_block_off_remove_overlap(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el, wt_off_t off, wt_off_t size); extern int __wt_block_alloc( WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t *offp, wt_off_t size); extern int __wt_block_free(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size); @@ -38,15 +38,15 @@ extern int __wt_block_extlist_read_avail(WT_SESSION_IMPL *session, WT_BLOCK *blo extern int __wt_block_extlist_read(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el, wt_off_t ckpt_size); extern int __wt_block_extlist_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el, WT_EXTLIST *additional); extern int __wt_block_extlist_truncate( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el); -extern int __wt_block_extlist_init(WT_SESSION_IMPL *session, WT_EXTLIST *el, const char *name, const char *extname, int track_size); +extern int __wt_block_extlist_init(WT_SESSION_IMPL *session, WT_EXTLIST *el, const char *name, const char *extname, bool track_size); extern void __wt_block_extlist_free(WT_SESSION_IMPL *session, WT_EXTLIST *el); extern int __wt_block_map( WT_SESSION_IMPL *session, WT_BLOCK *block, void *mapp, size_t *maplenp, void **mappingcookie); extern int __wt_block_unmap( WT_SESSION_IMPL *session, WT_BLOCK *block, void *map, size_t maplen, void **mappingcookie); extern int __wt_block_manager_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], bool forced_salvage, bool readonly, uint32_t allocsize, WT_BM **bmp); extern int __wt_block_manager_truncate( WT_SESSION_IMPL *session, const char *filename, uint32_t allocsize); extern int __wt_block_manager_create( WT_SESSION_IMPL *session, const char *filename, uint32_t allocsize); -extern void __wt_block_configure_first_fit(WT_BLOCK *block, int on); -extern int __wt_block_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], int forced_salvage, int readonly, uint32_t allocsize, WT_BLOCK **blockp); +extern void __wt_block_configure_first_fit(WT_BLOCK *block, bool on); +extern int __wt_block_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], bool forced_salvage, bool readonly, uint32_t allocsize, WT_BLOCK **blockp); extern int __wt_block_close(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_desc_init(WT_SESSION_IMPL *session, WT_FH *fh, uint32_t allocsize); extern void __wt_block_stat(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_DSRC_STATS *stats); @@ -65,7 +65,7 @@ extern int __wt_block_salvage_start(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern bool __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size); extern int __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, bool *eofp); -extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, int valid); +extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, bool valid); extern int __wt_block_verify_start(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]); extern int __wt_block_verify_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_verify_ckpt_load( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_BLOCK_CKPT *ci); @@ -224,7 +224,7 @@ extern int __wt_conn_remove_encryptor(WT_SESSION_IMPL *session); extern int __wt_extractor_config(WT_SESSION_IMPL *session, const char *uri, const char *config, WT_EXTRACTOR **extractorp, int *ownp); extern int __wt_conn_remove_extractor(WT_SESSION_IMPL *session); extern int __wt_verbose_config(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_cache_config(WT_SESSION_IMPL *session, int reconfigure, const char *cfg[]); +extern int __wt_cache_config(WT_SESSION_IMPL *session, bool reconfigure, const char *cfg[]); extern int __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]); extern void __wt_cache_stats_update(WT_SESSION_IMPL *session); extern int __wt_cache_destroy(WT_SESSION_IMPL *session); @@ -236,13 +236,13 @@ extern int __wt_checkpoint_server_create(WT_SESSION_IMPL *session, const char *c extern int __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session); extern int __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize); extern int __wt_conn_dhandle_find( WT_SESSION_IMPL *session, const char *uri, const char *checkpoint); -extern int __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force); +extern int __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, bool final, bool force); extern int __wt_conn_btree_open( WT_SESSION_IMPL *session, const char *cfg[], uint32_t flags); -extern int __wt_conn_btree_apply(WT_SESSION_IMPL *session, int apply_checkpoints, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); +extern int __wt_conn_btree_apply(WT_SESSION_IMPL *session, bool apply_checkpoints, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); extern int __wt_conn_btree_apply_single_ckpt(WT_SESSION_IMPL *session, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); extern int __wt_conn_btree_apply_single(WT_SESSION_IMPL *session, const char *uri, const char *checkpoint, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); -extern int __wt_conn_dhandle_close_all( WT_SESSION_IMPL *session, const char *uri, int force); -extern int __wt_conn_dhandle_discard_single(WT_SESSION_IMPL *session, int final, int force); +extern int __wt_conn_dhandle_close_all( WT_SESSION_IMPL *session, const char *uri, bool force); +extern int __wt_conn_dhandle_discard_single( WT_SESSION_IMPL *session, bool final, bool force); extern int __wt_conn_dhandle_discard(WT_SESSION_IMPL *session); extern int __wt_connection_init(WT_CONNECTION_IMPL *conn); extern int __wt_connection_destroy(WT_CONNECTION_IMPL *conn); @@ -257,7 +257,7 @@ extern int __wt_connection_workers(WT_SESSION_IMPL *session, const char *cfg[]); extern void __wt_conn_stat_init(WT_SESSION_IMPL *session); extern int __wt_statlog_log_one(WT_SESSION_IMPL *session); extern int __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_statlog_destroy(WT_SESSION_IMPL *session, int is_close); +extern int __wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close); extern int __wt_sweep_config(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_sweep_create(WT_SESSION_IMPL *session); extern int __wt_sweep_destroy(WT_SESSION_IMPL *session); @@ -469,7 +469,7 @@ extern int __wt_dlsym(WT_SESSION_IMPL *session, WT_DLH *dlh, const char *name, i 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); -extern int __wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp); +extern int __wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *existp); 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); @@ -488,7 +488,7 @@ extern int __wt_mmap_preload(WT_SESSION_IMPL *session, const void *p, size_t siz 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_wait_signal( WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, int *signalled); +extern int __wt_cond_wait_signal( WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled); extern int __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond); extern int __wt_cond_destroy(WT_SESSION_IMPL *session, WT_CONDVAR **condp); extern int __wt_rwlock_alloc( WT_SESSION_IMPL *session, WT_RWLOCK **rwlockp, const char *name); @@ -500,7 +500,7 @@ extern int __wt_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *rwlock); extern int __wt_writeunlock(WT_SESSION_IMPL *session, WT_RWLOCK *rwlock); extern int __wt_rwlock_destroy(WT_SESSION_IMPL *session, WT_RWLOCK **rwlockp); extern int __wt_once(void (*init_routine)(void)); -extern int __wt_open(WT_SESSION_IMPL *session, const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp); +extern int __wt_open(WT_SESSION_IMPL *session, const char *name, bool ok_create, bool exclusive, int dio_type, WT_FH **fhp); 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); diff --git a/src/include/misc.i b/src/include/misc.i index 6b502c4c1d1..4361b8e1ce3 100644 --- a/src/include/misc.i +++ b/src/include/misc.i @@ -13,7 +13,7 @@ static inline int __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs) { - int notused; + bool notused; return (__wt_cond_wait_signal(session, cond, usecs, ¬used)); } diff --git a/src/log/log.c b/src/log/log.c index afc8cd503a8..391d0cf05f1 100644 --- a/src/log/log.c +++ b/src/log/log.c @@ -598,7 +598,7 @@ __log_openfile(WT_SESSION_IMPL *session, WT_ERR(__wt_verbose(session, WT_VERB_LOG, "opening log %s", (const char *)buf->data)); WT_ERR(__wt_open( - session, buf->data, ok_create, 0, WT_FILE_TYPE_LOG, fh)); + session, buf->data, ok_create, false, WT_FILE_TYPE_LOG, fh)); /* * If we are not creating the log file but opening it for reading, * check that the magic number and versions are correct. @@ -991,7 +991,7 @@ __wt_log_open(WT_SESSION_IMPL *session) WT_RET(__wt_verbose(session, WT_VERB_LOG, "log_open: open fh to directory %s", conn->log_path)); WT_RET(__wt_open(session, conn->log_path, - 0, 0, WT_FILE_TYPE_DIRECTORY, &log->log_dir_fh)); + false, false, WT_FILE_TYPE_DIRECTORY, &log->log_dir_fh)); } /* * Clean up any old interim pre-allocated files. diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c index 76f623a85ae..41e0c7c81e6 100644 --- a/src/lsm/lsm_tree.c +++ b/src/lsm/lsm_tree.c @@ -239,7 +239,7 @@ __lsm_tree_cleanup_old(WT_SESSION_IMPL *session, const char *uri) WT_DECL_RET; const char *cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_drop), "force", NULL }; - int exists; + bool exists; WT_RET(__wt_exist(session, uri + strlen("file:"), &exists)); if (exists) diff --git a/src/meta/meta_turtle.c b/src/meta/meta_turtle.c index a44e647ff08..1aa9c953689 100644 --- a/src/meta/meta_turtle.c +++ b/src/meta/meta_turtle.c @@ -72,7 +72,7 @@ __metadata_load_hot_backup(WT_SESSION_IMPL *session) WT_DECL_ITEM(key); WT_DECL_ITEM(value); WT_DECL_RET; - int exist; + bool exist; /* Look for a hot backup file: if we find it, load it. */ WT_RET(__wt_exist(session, WT_METADATA_BACKUP, &exist)); @@ -112,7 +112,7 @@ __metadata_load_bulk(WT_SESSION_IMPL *session) WT_CURSOR *cursor; WT_DECL_RET; uint32_t allocsize; - int exist; + bool exist; const char *filecfg[] = { WT_CONFIG_BASE(session, file_meta), NULL }; const char *key; @@ -155,7 +155,7 @@ int __wt_turtle_init(WT_SESSION_IMPL *session) { WT_DECL_RET; - int exist, exist_incr; + bool exist, exist_incr; char *metaconf; metaconf = NULL; @@ -222,7 +222,7 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep) FILE *fp; WT_DECL_ITEM(buf); WT_DECL_RET; - int exist, match; + bool exist, match; *valuep = NULL; @@ -241,12 +241,12 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep) /* Search for the key. */ WT_ERR(__wt_scr_alloc(session, 512, &buf)); - for (match = 0;;) { + for (match = false;;) { WT_ERR(__wt_getline(session, buf, fp)); if (buf->size == 0) WT_ERR(WT_NOTFOUND); if (strcmp(key, buf->data) == 0) - match = 1; + match = true; /* Key matched: read the subsequent line for the value. */ WT_ERR(__wt_getline(session, buf, fp)); @@ -284,8 +284,8 @@ __wt_turtle_update( * Create the turtle setup file: we currently re-write it from scratch * every time. */ - WT_RET(__wt_open( - session, WT_METADATA_TURTLE_SET, 1, 1, WT_FILE_TYPE_TURTLE, &fh)); + WT_RET(__wt_open(session, + WT_METADATA_TURTLE_SET, true, true, WT_FILE_TYPE_TURTLE, &fh)); version = wiredtiger_version(&vmajor, &vminor, &vpatch); WT_ERR(__wt_scr_alloc(session, 2 * 1024, &buf)); diff --git a/src/os_posix/os_exist.c b/src/os_posix/os_exist.c index 173021e6100..644a27dca9a 100644 --- a/src/os_posix/os_exist.c +++ b/src/os_posix/os_exist.c @@ -13,13 +13,13 @@ * Return if the file exists. */ int -__wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) +__wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *existp) { struct stat sb; WT_DECL_RET; char *path; - *existp = 0; + *existp = false; WT_RET(__wt_filename(session, filename, &path)); @@ -28,7 +28,7 @@ __wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) __wt_free(session, path); if (ret == 0) { - *existp = 1; + *existp = true; return (0); } if (ret == ENOENT) diff --git a/src/os_posix/os_mtx_cond.c b/src/os_posix/os_mtx_cond.c index 7946b4ab0cc..bf7aedb2381 100644 --- a/src/os_posix/os_mtx_cond.c +++ b/src/os_posix/os_mtx_cond.c @@ -47,7 +47,7 @@ err: __wt_free(session, cond); */ int __wt_cond_wait_signal( - WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, int *signalled) + WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled) { struct timespec ts; WT_DECL_RET; @@ -56,7 +56,7 @@ __wt_cond_wait_signal( locked = 0; /* Fast path if already signalled. */ - *signalled = 1; + *signalled = true; if (__wt_atomic_addi32(&cond->waiters, 1) == 0) return (0); @@ -92,7 +92,7 @@ __wt_cond_wait_signal( ret == ETIME || #endif ret == ETIMEDOUT) { - *signalled = 0; + *signalled = false; ret = 0; } diff --git a/src/os_posix/os_open.c b/src/os_posix/os_open.c index ef4662aa369..8118a979597 100644 --- a/src/os_posix/os_open.c +++ b/src/os_posix/os_open.c @@ -30,7 +30,7 @@ __open_directory(WT_SESSION_IMPL *session, char *path, int *fd) */ int __wt_open(WT_SESSION_IMPL *session, - const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp) + const char *name, bool ok_create, bool exclusive, int dio_type, WT_FH **fhp) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; diff --git a/src/os_win/os_exist.c b/src/os_win/os_exist.c index 747ea7dfc27..4a727801569 100644 --- a/src/os_win/os_exist.c +++ b/src/os_win/os_exist.c @@ -13,7 +13,7 @@ * Return if the file exists. */ int -__wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) +__wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *existp) { WT_DECL_RET; char *path; @@ -25,9 +25,9 @@ __wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) __wt_free(session, path); if (ret != INVALID_FILE_ATTRIBUTES) - *existp = 1; + *existp = true; else - *existp = 0; + *existp = false; return (0); } diff --git a/src/os_win/os_mtx_cond.c b/src/os_win/os_mtx_cond.c index 14ca5d61282..be631d07781 100644 --- a/src/os_win/os_mtx_cond.c +++ b/src/os_win/os_mtx_cond.c @@ -43,7 +43,7 @@ __wt_cond_alloc(WT_SESSION_IMPL *session, */ int __wt_cond_wait_signal( - WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, int *signalled) + WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled) { DWORD err, milliseconds; WT_DECL_RET; @@ -53,7 +53,7 @@ __wt_cond_wait_signal( locked = 0; /* Fast path if already signalled. */ - *signalled = 1; + *signalled = true; if (__wt_atomic_addi32(&cond->waiters, 1) == 0) return (0); @@ -101,7 +101,7 @@ __wt_cond_wait_signal( */ if (ret == 0) { if ((err = GetLastError()) == ERROR_TIMEOUT) - *signalled = 0; + *signalled = false; else ret = __wt_errno(); } else diff --git a/src/os_win/os_open.c b/src/os_win/os_open.c index 3bd24369242..9bdae92774b 100644 --- a/src/os_win/os_open.c +++ b/src/os_win/os_open.c @@ -14,7 +14,7 @@ */ int __wt_open(WT_SESSION_IMPL *session, - const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp) + const char *name, bool ok_create, bool exclusive, int dio_type, WT_FH **fhp) { DWORD dwCreationDisposition; HANDLE filehandle, filehandle_secondary; diff --git a/src/schema/schema_drop.c b/src/schema/schema_drop.c index 0fb0e735ae1..27d0a2bb614 100644 --- a/src/schema/schema_drop.c +++ b/src/schema/schema_drop.c @@ -14,7 +14,7 @@ */ static int __drop_file( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[]) { WT_CONFIG_ITEM cval; WT_DECL_RET; @@ -53,7 +53,7 @@ __drop_file( */ static int __drop_colgroup( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -78,7 +78,7 @@ __drop_colgroup( */ static int __drop_index( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[]) { WT_INDEX *idx; WT_DECL_RET; @@ -100,8 +100,7 @@ __drop_index( * WT_SESSION::drop for a table. */ static int -__drop_table( - WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) +__drop_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -164,10 +163,10 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) WT_CONFIG_ITEM cval; WT_DATA_SOURCE *dsrc; WT_DECL_RET; - int force; + bool force; WT_RET(__wt_config_gets_def(session, cfg, "force", 0, &cval)); - force = (cval.val != 0); + force = cval.val != 0; WT_RET(__wt_meta_track_on(session)); diff --git a/src/schema/schema_rename.c b/src/schema/schema_rename.c index 1031b27db3d..d1788f43e3f 100644 --- a/src/schema/schema_rename.c +++ b/src/schema/schema_rename.c @@ -17,7 +17,7 @@ __rename_file( WT_SESSION_IMPL *session, const char *uri, const char *newuri) { WT_DECL_RET; - int exist; + bool exist; const char *filename, *newfile; char *newvalue, *oldvalue; @@ -31,7 +31,7 @@ __rename_file( /* Close any btree handles in the file. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_conn_dhandle_close_all(session, uri, 0)); + ret = __wt_conn_dhandle_close_all(session, uri, false)); WT_ERR(ret); /* diff --git a/src/schema/schema_truncate.c b/src/schema/schema_truncate.c index 899c46470ca..bf0aef22d30 100644 --- a/src/schema/schema_truncate.c +++ b/src/schema/schema_truncate.c @@ -34,7 +34,7 @@ __truncate_file(WT_SESSION_IMPL *session, const char *uri) /* Close any btree handles in the file. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_conn_dhandle_close_all(session, uri, 0)); + ret = __wt_conn_dhandle_close_all(session, uri, false)); WT_RET(ret); /* Delete the root address and truncate the file. */ diff --git a/src/schema/schema_worker.c b/src/schema/schema_worker.c index 4dc337a309c..5a10a78263a 100644 --- a/src/schema/schema_worker.c +++ b/src/schema/schema_worker.c @@ -51,7 +51,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session, if (FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE)) { WT_WITH_HANDLE_LIST_LOCK(session, ret = __wt_conn_dhandle_close_all( - session, uri, 0)); + session, uri, false)); WT_ERR(ret); } diff --git a/src/session/session_dhandle.c b/src/session/session_dhandle.c index 9a6854574c5..6a5276a54fb 100644 --- a/src/session/session_dhandle.c +++ b/src/session/session_dhandle.c @@ -248,12 +248,12 @@ __wt_session_release_btree(WT_SESSION_IMPL *session) } if (F_ISSET(dhandle, WT_DHANDLE_DISCARD_FORCE)) { - ret = __wt_conn_btree_sync_and_close(session, 0, 1); + ret = __wt_conn_btree_sync_and_close(session, false, true); F_CLR(dhandle, WT_DHANDLE_DISCARD_FORCE); } else if (F_ISSET(dhandle, WT_DHANDLE_DISCARD) || F_ISSET(btree, WT_BTREE_SPECIAL_FLAGS)) { WT_ASSERT(session, F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE)); - ret = __wt_conn_btree_sync_and_close(session, 0, 0); + ret = __wt_conn_btree_sync_and_close(session, false, false); F_CLR(dhandle, WT_DHANDLE_DISCARD); } diff --git a/src/support/filename.c b/src/support/filename.c index c66e35e2ade..02a83803e25 100644 --- a/src/support/filename.c +++ b/src/support/filename.c @@ -56,7 +56,7 @@ __wt_nfilename( int __wt_remove_if_exists(WT_SESSION_IMPL *session, const char *name) { - int exist; + bool exist; WT_RET(__wt_exist(session, name, &exist)); if (exist) diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c index 1f87e84627f..713a6a6b922 100644 --- a/src/txn/txn_ckpt.c +++ b/src/txn/txn_ckpt.c @@ -157,7 +157,7 @@ __checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[], } WT_ERR(ckpt_closed ? __wt_meta_btree_apply(session, op, cfg) : - __wt_conn_btree_apply(session, 0, NULL, op, cfg)); + __wt_conn_btree_apply(session, false, NULL, op, cfg)); } if (fullp != NULL) |