diff options
author | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-07-06 15:57:08 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-06 15:57:08 +1000 |
commit | 502d4cc5f4d7a41ccd5306f33e60aa6a451fe6e6 (patch) | |
tree | ba8fee0f1ef86688c5a81a970f548e3eab96bf1d | |
parent | d5f82a43f1e0c8aafd38f0098bc9349a6de335e6 (diff) | |
download | mongo-502d4cc5f4d7a41ccd5306f33e60aa6a451fe6e6.tar.gz |
Revert "WT-3394 Build WiredTiger with gcc7 (#3492)" (#3498)
This reverts commit d5f82a43f1e0c8aafd38f0098bc9349a6de335e6.
38 files changed, 159 insertions, 318 deletions
diff --git a/bench/wtperf/config.c b/bench/wtperf/config.c index 1a4f46f5c37..c5a3dd40032 100644 --- a/bench/wtperf/config.c +++ b/bench/wtperf/config.c @@ -798,7 +798,7 @@ config_sanity(WTPERF *wtperf) workp->table_index >= (int32_t)opts->table_count) { fprintf(stderr, "Workload table index %" PRId32 - " is larger than table count %" PRIu32, + " is larger than table count %" PRId32, workp->table_index, opts->table_count); return (EINVAL); } diff --git a/bench/wtperf/track.c b/bench/wtperf/track.c index 9f721ebea0e..13ca85aabfd 100644 --- a/bench/wtperf/track.c +++ b/bench/wtperf/track.c @@ -42,8 +42,8 @@ sum_pop_ops(WTPERF *wtperf) opts = wtperf->opts; total = 0; - thread = wtperf->popthreads; - for (i = 0; i < opts->populate_threads; ++i, ++thread) + for (i = 0, thread = wtperf->popthreads; + thread != NULL && i < opts->populate_threads; ++i, ++thread) total += thread->insert.ops; return (total); } @@ -62,8 +62,8 @@ sum_ckpt_ops(WTPERF *wtperf) opts = wtperf->opts; total = 0; - thread = wtperf->ckptthreads; - for (i = 0; i < opts->checkpoint_threads; ++i, ++thread) + for (i = 0, thread = wtperf->ckptthreads; + thread != NULL && i < opts->checkpoint_threads; ++i, ++thread) total += thread->ckpt.ops; return (total); } @@ -89,7 +89,7 @@ sum_ops(WTPERF *wtperf, size_t field_offset) thread = wtperf->popthreads; th_cnt = opts->populate_threads; } - for (i = 0; i < th_cnt; ++i, ++thread) + for (i = 0; thread != NULL && i < th_cnt; ++i, ++thread) total += ((TRACK *)((uint8_t *)thread + field_offset))->ops; return (total); @@ -143,7 +143,7 @@ latency_op(WTPERF *wtperf, thread = wtperf->popthreads; th_cnt = opts->populate_threads; } - for (i = 0; i < th_cnt; ++i, ++thread) { + for (i = 0; thread != NULL && i < th_cnt; ++i, ++thread) { track = (TRACK *)((uint8_t *)thread + field_offset); tmp = track->latency_ops; ops += tmp - track->last_latency_ops; @@ -246,8 +246,8 @@ sum_latency(WTPERF *wtperf, size_t field_offset, TRACK *total) memset(total, 0, sizeof(*total)); - thread = wtperf->workers; - for (i = 0; i < wtperf->workers_cnt; ++i, ++thread) { + for (i = 0, thread = wtperf->workers; + thread != NULL && i < wtperf->workers_cnt; ++i, ++thread) { trk = (TRACK *)((uint8_t *)thread + field_offset); for (j = 0; j < ELEMENTS(trk->us); ++j) { diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c index 9e18df9a0e3..a8d3f135280 100644 --- a/bench/wtperf/wtperf.c +++ b/bench/wtperf/wtperf.c @@ -1750,7 +1750,7 @@ execute_workload(WTPERF *wtperf) lprintf(wtperf, 0, 1, "Starting workload #%u: %" PRId64 " threads, inserts=%" PRId64 ", reads=%" PRId64 ", updates=%" PRId64 - ", truncate=%" PRId64 ", throttle=%" PRIu64, + ", truncate=%" PRId64 ", throttle=%" PRId64, i + 1, workp->threads, workp->insert, workp->read, workp->update, workp->truncate, workp->throttle); diff --git a/build_posix/aclocal/strict.m4 b/build_posix/aclocal/strict.m4 index f9509df26bf..8c15a22d575 100644 --- a/build_posix/aclocal/strict.m4 +++ b/build_posix/aclocal/strict.m4 @@ -18,6 +18,7 @@ AC_DEFUN([AM_GCC_WARNINGS], [ w="$w -Wjump-misses-init" w="$w -Wmissing-declarations" w="$w -Wmissing-field-initializers" + w="$w -Wmissing-parameter-type" w="$w -Wmissing-prototypes" w="$w -Wnested-externs" w="$w -Wold-style-definition" @@ -32,6 +33,7 @@ AC_DEFUN([AM_GCC_WARNINGS], [ w="$w -Wundef" w="$w -Wuninitialized" w="$w -Wunreachable-code" + w="$w -Wunsafe-loop-optimizations" w="$w -Wunused" w="$w -Wwrite-strings" @@ -46,33 +48,10 @@ AC_DEFUN([AM_GCC_WARNINGS], [ # Additional warning messages. case "$1" in [*4.7.[0-9]*]) # gcc4.7 - w="$w -Wno-c11-extensions" - w="$w -Wunsafe-loop-optimizations";; + w="$w -Wno-c11-extensions";; [*6.[0-9].[0-9]*]) # gcc6.X w="$w -Wduplicated-cond" - w="$w -Wformat-signedness" - w="$w -Wjump-misses-init" - w="$w -Wlogical-op" - w="$w -Wredundant-decls" - w="$w -Wunsafe-loop-optimizations" - w="$w -Wunused-const-variable=2" - w="$w -Wunused-macros" - w="$w -Wvariadic-macros";; - [*7.[0-9].[0-9]*]) # gcc7.X - w="$w -Walloca" - w="$w -Walloc-zero" - w="$w -Wduplicated-branches" - w="$w -Wduplicated-cond" - w="$w -Wformat-overflow=2" - w="$w -Wformat-signedness" - w="$w -Wformat-truncation=2" - w="$w -Wjump-misses-init" - w="$w -Wlogical-op" - w="$w -Wredundant-decls" - w="$w -Wrestrict" - w="$w -Wunused-const-variable=2" - w="$w -Wunused-macros" - w="$w -Wvariadic-macros";; + w="$w -Wmisleading-indentation";; esac wt_cv_strict_warnings="$w" diff --git a/dist/s_string.ok b/dist/s_string.ok index 7a53a6a0a17..2f56933f818 100644 --- a/dist/s_string.ok +++ b/dist/s_string.ok @@ -690,7 +690,6 @@ extern extlist fadvise fallocate -fallthrough fblocks fc fclose @@ -804,7 +803,6 @@ initn initsize initval inline -inlined inmem inmemory insertK @@ -1264,7 +1262,6 @@ valuep valuev vanishingly variable's -variadic vectorized versa vfprintf diff --git a/src/async/async_op.c b/src/async/async_op.c index dc8a3cdf348..d4ca754b95f 100644 --- a/src/async/async_op.c +++ b/src/async/async_op.c @@ -7,7 +7,6 @@ */ #include "wt_internal.h" - /* * __async_get_key -- * WT_ASYNC_OP->get_key implementation for op handles. diff --git a/src/async/async_worker.c b/src/async/async_worker.c index 2626a21435f..57ebe5d8bb1 100644 --- a/src/async/async_worker.c +++ b/src/async/async_worker.c @@ -215,7 +215,7 @@ __async_worker_execop(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op, break; case WT_AOP_NONE: WT_RET_MSG(session, EINVAL, - "Unknown async optype %d", (int)op->optype); + "Unknown async optype %d", op->optype); } return (0); } diff --git a/src/block/block_compact.c b/src/block/block_compact.c index 76c4b1de3ec..e7b9beafb01 100644 --- a/src/block/block_compact.c +++ b/src/block/block_compact.c @@ -8,9 +8,7 @@ #include "wt_internal.h" -#ifdef HAVE_VERBOSE static void __block_dump_avail(WT_SESSION_IMPL *, WT_BLOCK *, bool); -#endif /* * __wt_block_compact_start -- @@ -80,11 +78,9 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp) __wt_spin_lock(session, &block->live_lock); -#ifdef HAVE_VERBOSE /* Dump the current state of the file. */ if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT)) __block_dump_avail(session, block, true); -#endif /* Sum the available bytes in the initial 80% and 90% of the file. */ avail_eighty = avail_ninety = 0; @@ -199,7 +195,6 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session, return (0); } -#ifdef HAVE_VERBOSE /* * __block_dump_avail -- * Dump out the avail list so we can see what compaction will look like. @@ -276,4 +271,3 @@ __block_dump_avail(WT_SESSION_IMPL *session, WT_BLOCK *block, bool start) (uintmax_t)((v * 100) / (wt_off_t)el->bytes)); } } -#endif diff --git a/src/block/block_vrfy.c b/src/block/block_vrfy.c index d2ca561fe82..1058f16bde6 100644 --- a/src/block/block_vrfy.c +++ b/src/block/block_vrfy.c @@ -33,7 +33,7 @@ int __wt_block_verify_start(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]) { - WT_CKPT *ckpt, *t; + WT_CKPT *ckpt; WT_CONFIG_ITEM cval; wt_off_t size; @@ -50,12 +50,14 @@ __wt_block_verify_start(WT_SESSION_IMPL *session, * checkpoint we have is fake, there's no work to do. Don't complain, * that's not our problem to solve. */ - ckpt = NULL; - WT_CKPT_FOREACH(ckptbase, t) - if (t->name != NULL && !F_ISSET(t, WT_CKPT_FAKE)) - ckpt = t; - if (ckpt == NULL) - return (0); + WT_CKPT_FOREACH(ckptbase, ckpt) + ; + for (;; --ckpt) { + if (ckpt->name != NULL && !F_ISSET(ckpt, WT_CKPT_FAKE)) + break; + if (ckpt == ckptbase) + return (0); + } /* Set the size of the file to the size of the last checkpoint. */ WT_RET(__verify_set_file_size(session, block, ckpt)); @@ -385,8 +387,6 @@ __verify_filefrag_add(WT_SESSION_IMPL *session, WT_BLOCK *block, { uint64_t f, frag, frags, i; - WT_UNUSED(type); /* !HAVE_VERBOSE */ - __wt_verbose(session, WT_VERB_VERIFY, "add file block%s%s%s at %" PRIuMAX "-%" PRIuMAX " (%" PRIuMAX ")", type == NULL ? "" : " (", diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c index 5fad76849dc..06fbd6b74c7 100644 --- a/src/btree/bt_handle.c +++ b/src/btree/bt_handle.c @@ -279,9 +279,6 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) bool fixed; const char **cfg, *enc_cfg[] = { NULL, NULL }; - WT_UNUSED(maj_version); /* !HAVE_VERBOSE */ - WT_UNUSED(min_version); /* !HAVE_VERBOSE */ - btree = S2BT(session); cfg = btree->dhandle->cfg; conn = S2C(session); @@ -293,7 +290,7 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) WT_RET(__wt_config_gets(session, cfg, "version.minor", &cval)); min_version = cval.val; __wt_verbose(session, WT_VERB_VERSION, - "%" PRId64 ".%" PRId64, maj_version, min_version); + "%" PRIu64 ".%" PRIu64, maj_version, min_version); } /* Get the file ID. */ diff --git a/src/btree/bt_read.c b/src/btree/bt_read.c index 6a89f505c31..5f8cf3a45e1 100644 --- a/src/btree/bt_read.c +++ b/src/btree/bt_read.c @@ -710,7 +710,7 @@ __btree_verbose_lookaside_read(WT_SESSION_IMPL *session) if (__wt_atomic_casv64(&conn->las_verb_gen_read, ckpt_gen_last, ckpt_gen_current)) { __wt_verbose(session, WT_VERB_LOOKASIDE, - "%s", "Read from lookaside file triggered."); + "Read from lookaside file triggered."); } } #else diff --git a/src/btree/bt_slvg.c b/src/btree/bt_slvg.c index 1f686d904ec..eb39301abc7 100644 --- a/src/btree/bt_slvg.c +++ b/src/btree/bt_slvg.c @@ -1885,8 +1885,6 @@ __slvg_row_build_leaf( uint32_t i, skip_start, skip_stop; int cmp; - WT_UNUSED(ss); /* !HAVE_VERBOSE */ - btree = S2BT(session); page = NULL; diff --git a/src/conn/conn_cache_pool.c b/src/conn/conn_cache_pool.c index 55393a86ba1..adc2e2bffc3 100644 --- a/src/conn/conn_cache_pool.c +++ b/src/conn/conn_cache_pool.c @@ -372,8 +372,8 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) } if (!F_ISSET(cp, WT_CACHE_POOL_ACTIVE)) { - __wt_verbose(session, - WT_VERB_SHARED_CACHE, "%s", "Destroying cache pool"); + __wt_verbose( + session, WT_VERB_SHARED_CACHE, "Destroying cache pool"); __wt_spin_lock(session, &__wt_process.spinlock); /* * We have been holding the pool lock - no connections could @@ -401,7 +401,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) /* Notify other participants if we were managing */ if (FLD_ISSET(cache->pool_flags, WT_CACHE_POOL_MANAGER)) { cp->pool_managed = 0; - __wt_verbose(session, WT_VERB_SHARED_CACHE, "%s", + __wt_verbose(session, WT_VERB_SHARED_CACHE, "Shutting down shared cache manager connection"); } } @@ -585,8 +585,8 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, if (WT_VERBOSE_ISSET(session, WT_VERB_SHARED_CACHE)) { __wt_verbose(session, - WT_VERB_SHARED_CACHE, "%s", "Cache pool distribution: "); - __wt_verbose(session, WT_VERB_SHARED_CACHE, "%s", + WT_VERB_SHARED_CACHE, "Cache pool distribution: "); + __wt_verbose(session, WT_VERB_SHARED_CACHE, "\t" "cache (MB), pressure, skips, busy, %% full:"); } @@ -731,7 +731,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, cp->currently_used -= adjustment; } __wt_verbose(session, WT_VERB_SHARED_CACHE, - "Allocated %s%" PRIu64 " to %s", + "Allocated %s%" PRId64 " to %s", grow ? "" : "-", adjustment, entry->home); /* @@ -778,7 +778,7 @@ __wt_cache_pool_server(void *arg) if (__wt_atomic_cas8(&cp->pool_managed, 0, 1)) { FLD_SET(cache->pool_flags, WT_CACHE_POOL_MANAGER); __wt_verbose(session, WT_VERB_SHARED_CACHE, - "%s", "Cache pool switched manager thread"); + "Cache pool switched manager thread"); } /* diff --git a/src/conn/conn_log.c b/src/conn/conn_log.c index a6290e4ed92..7b9eec895b4 100644 --- a/src/conn/conn_log.c +++ b/src/conn/conn_log.c @@ -937,7 +937,7 @@ __log_server(void *arg) session, &log->log_archive_lock); WT_ERR(ret); } else - __wt_verbose(session, WT_VERB_LOG, "%s", + __wt_verbose(session, WT_VERB_LOG, "log_archive: Blocked due to open " "log cursor holding archive lock"); } diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index 07b3b21b026..4f4ecdf286c 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -305,14 +305,12 @@ __wt_evict_thread_run(WT_SESSION_IMPL *session, WT_THREAD *thread) F_ISSET(thread, WT_THREAD_RUN)) __wt_yield(); else { - __wt_verbose(session, - WT_VERB_EVICTSERVER, "%s", "sleeping"); + __wt_verbose(session, WT_VERB_EVICTSERVER, "sleeping"); /* Don't rely on signals: check periodically. */ __wt_cond_auto_wait(session, cache->evict_cond, did_work, NULL); - __wt_verbose(session, - WT_VERB_EVICTSERVER, "%s", "waking"); + __wt_verbose(session, WT_VERB_EVICTSERVER, "waking"); } } else WT_ERR(__evict_lru_pages(session, false)); @@ -353,8 +351,8 @@ __wt_evict_thread_stop(WT_SESSION_IMPL *session, WT_THREAD *thread) */ WT_ASSERT(session, F_ISSET(conn, WT_CONN_CLOSING | WT_CONN_RECOVERING)); - __wt_verbose(session, - WT_VERB_EVICTSERVER, "%s", "cache eviction thread exiting"); + __wt_verbose( + session, WT_VERB_EVICTSERVER, "cache eviction thread exiting"); if (0) { err: WT_PANIC_MSG(session, ret, "cache eviction thread error"); @@ -517,7 +515,7 @@ __wt_evict_destroy(WT_SESSION_IMPL *session) __wt_evict_server_wake(session); __wt_verbose( - session, WT_VERB_EVICTSERVER, "%s", "waiting for helper threads"); + session, WT_VERB_EVICTSERVER, "waiting for helper threads"); /* * We call the destroy function still holding the write lock. @@ -742,7 +740,7 @@ __evict_pass(WT_SESSION_IMPL *session) WT_STAT_CONN_INCR(session, cache_eviction_slow); __wt_verbose(session, WT_VERB_EVICTSERVER, - "%s", "unable to reach eviction goal"); + "unable to reach eviction goal"); break; } else { if (cache->evict_aggressive_score > 0) { @@ -1108,8 +1106,8 @@ __evict_tune_workers(WT_SESSION_IMPL *session) &conn->evict_threads, false); WT_STAT_CONN_INCR(session, cache_eviction_worker_created); - __wt_verbose(session, - WT_VERB_EVICTSERVER, "%s", "added worker thread"); + __wt_verbose(session, WT_VERB_EVICTSERVER, + "added worker thread"); } conn->evict_tune_last_action_time = current_time; } diff --git a/src/include/api.h b/src/include/api.h index 60ed31b64e8..372ba063cd3 100644 --- a/src/include/api.h +++ b/src/include/api.h @@ -13,7 +13,7 @@ (s)->dhandle = (dh); \ (s)->name = (s)->lastop = #h "." #n; \ WT_ERR(WT_SESSION_CHECK_PANIC(s)); \ - __wt_verbose((s), WT_VERB_API, "%s", "CALL: " #h ":" #n) + __wt_verbose((s), WT_VERB_API, "CALL: " #h ":" #n) #define API_CALL_NOCONF(s, h, n, dh) do { \ API_SESSION_INIT(s, h, n, dh) diff --git a/src/include/bitstring.i b/src/include/bitstring.i index a9ec91d49ff..d3dc3bebd0f 100644 --- a/src/include/bitstring.i +++ b/src/include/bitstring.i @@ -171,18 +171,16 @@ __bit_ffc(uint8_t *bitf, uint64_t nbits, uint64_t *retp) if (nbits == 0) return (-1); - for (byte = 0, stopbyte = __bit_byte(nbits - 1);; ++byte) { + for (byte = 0, + stopbyte = __bit_byte(nbits - 1); byte <= stopbyte; ++byte) if (bitf[byte] != 0xff) { value = byte << 3; for (lb = bitf[byte]; lb & 0x01; ++value, lb >>= 1) ; break; } - if (byte == stopbyte) - return (-1); - } - if (value >= nbits) + if (byte > stopbyte || value >= nbits) return (-1); *retp = value; @@ -203,18 +201,16 @@ __bit_ffs(uint8_t *bitf, uint64_t nbits, uint64_t *retp) if (nbits == 0) return (-1); - for (byte = 0, stopbyte = __bit_byte(nbits - 1);; ++byte) { + for (byte = 0, + stopbyte = __bit_byte(nbits - 1); byte <= stopbyte; ++byte) if (bitf[byte] != 0) { value = byte << 3; for (lb = bitf[byte]; !(lb & 0x01); ++value, lb >>= 1) ; break; } - if (byte == stopbyte) - return (-1); - } - if (value >= nbits) + if (byte > stopbyte || value >= nbits) return (-1); *retp = value; @@ -231,6 +227,13 @@ __bit_getv(uint8_t *bitf, uint64_t entry, uint8_t width) uint8_t value; uint64_t bit; +#define __BIT_GET(len, mask) \ + case len: \ + if (__bit_test(bitf, bit)) \ + value |= (mask); \ + ++bit \ + /* FALLTHROUGH */ + value = 0; bit = entry * width; @@ -238,50 +241,17 @@ __bit_getv(uint8_t *bitf, uint64_t entry, uint8_t width) * Fast-path single bytes, do repeated tests for the rest: we could * slice-and-dice instead, but the compiler is probably going to do * a better job than I will. - * - * The Berkeley version of this file uses a #define to compress this - * case statement. This code expands the case statement because gcc7 - * complains about implicit fallthrough and doesn't support explicit - * fallthrough comments in macros. */ switch (width) { case 8: return (bitf[__bit_byte(bit)]); - case 7: - if (__bit_test(bitf, bit)) - value |= 0x40; - ++bit; - /* FALLTHROUGH */ - case 6: - if (__bit_test(bitf, bit)) - value |= 0x20; - ++bit; - /* FALLTHROUGH */ - case 5: - if (__bit_test(bitf, bit)) - value |= 0x10; - ++bit; - /* FALLTHROUGH */ - case 4: - if (__bit_test(bitf, bit)) - value |= 0x08; - ++bit; - /* FALLTHROUGH */ - case 3: - if (__bit_test(bitf, bit)) - value |= 0x04; - ++bit; - /* FALLTHROUGH */ - case 2: - if (__bit_test(bitf, bit)) - value |= 0x02; - ++bit; - /* FALLTHROUGH */ - case 1: - if (__bit_test(bitf, bit)) - value |= 0x01; - ++bit; - break; + __BIT_GET(7, 0x40); + __BIT_GET(6, 0x20); + __BIT_GET(5, 0x10); + __BIT_GET(4, 0x08); + __BIT_GET(3, 0x04); + __BIT_GET(2, 0x02); + __BIT_GET(1, 0x01); } return (value); } @@ -306,70 +276,32 @@ __bit_setv(uint8_t *bitf, uint64_t entry, uint8_t width, uint8_t value) { uint64_t bit; +#define __BIT_SET(len, mask) \ + case len: \ + if (value & (mask)) \ + __bit_set(bitf, bit); \ + else \ + __bit_clear(bitf, bit); \ + ++bit \ + /* FALLTHROUGH */ + bit = entry * width; /* * Fast-path single bytes, do repeated tests for the rest: we could * slice-and-dice instead, but the compiler is probably going to do * a better job than I will. - * - * The Berkeley version of this file uses a #define to compress this - * case statement. This code expands the case statement because gcc7 - * complains about implicit fallthrough and doesn't support explicit - * fallthrough comments in macros. */ switch (width) { case 8: bitf[__bit_byte(bit)] = value; return; - case 7: - if (value & 0x40) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - /* FALLTHROUGH */ - case 6: - if (value & 0x20) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - /* FALLTHROUGH */ - case 5: - if (value & 0x10) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - /* FALLTHROUGH */ - case 4: - if (value & 0x08) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - /* FALLTHROUGH */ - case 3: - if (value & 0x04) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - /* FALLTHROUGH */ - case 2: - if (value & 0x02) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - /* FALLTHROUGH */ - case 1: - if (value & 0x01) - __bit_set(bitf, bit); - else - __bit_clear(bitf, bit); - ++bit; - break; + __BIT_SET(7, 0x40); + __BIT_SET(6, 0x20); + __BIT_SET(5, 0x10); + __BIT_SET(4, 0x08); + __BIT_SET(3, 0x04); + __BIT_SET(2, 0x02); + __BIT_SET(1, 0x01); } } diff --git a/src/include/btree_cmp.i b/src/include/btree_cmp.i index db7af8daaed..c1354a7ea4b 100644 --- a/src/include/btree_cmp.i +++ b/src/include/btree_cmp.i @@ -217,61 +217,23 @@ __wt_lex_compare_short(const WT_ITEM *user_item, const WT_ITEM *tree_item) /* * The maximum packed uint64_t is 9B, catch row-store objects using * packed record numbers as keys. - * - * Don't use a #define to compress this case statement: gcc7 complains - * about implicit fallthrough and doesn't support explicit fallthrough - * comments in macros. */ #define WT_COMPARE_SHORT_MAXLEN 9 +#undef WT_COMPARE_SHORT +#define WT_COMPARE_SHORT(n) \ + case n: \ + if (*userp != *treep) \ + break; \ + ++userp, ++treep switch (len) { - case 9: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 8: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 7: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 6: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 5: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 4: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 3: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ - case 2: - if (*userp != *treep) - break; - ++userp; - ++treep; - /* FALLTHROUGH */ + WT_COMPARE_SHORT(9); + WT_COMPARE_SHORT(8); + WT_COMPARE_SHORT(7); + WT_COMPARE_SHORT(6); + WT_COMPARE_SHORT(5); + WT_COMPARE_SHORT(4); + WT_COMPARE_SHORT(3); + WT_COMPARE_SHORT(2); case 1: if (*userp != *treep) break; diff --git a/src/include/error.h b/src/include/error.h index 2d302fb6879..465ab4fa859 100644 --- a/src/include/error.h +++ b/src/include/error.h @@ -124,28 +124,3 @@ #define WT_ASSERT(session, exp) \ WT_UNUSED(session) #endif - -/* - * __wt_verbose -- - * Display a verbose message. - * - * Not an inlined function because you can't inline functions taking variadic - * arguments and we don't want to make a function call in production systems - * just to find out a verbose flag isn't set. - * - * The macro must take a format string and at least one additional argument, - * there's no portable way to remove the comma before an empty __VA_ARGS__ - * value. - */ -#ifdef HAVE_VERBOSE -#define __wt_verbose(session, flag, fmt, ...) do { \ - if (WT_VERBOSE_ISSET(session, flag)) \ - __wt_verbose_worker(session, fmt, __VA_ARGS__); \ -} while (0) -#else -#define __wt_verbose(session, flag, fmt, ...) do { \ - WT_UNUSED(session); \ - WT_UNUSED(flag); \ - WT_UNUSED(fmt); \ -} while (0) -#endif diff --git a/src/include/extern.h b/src/include/extern.h index 14d05d4037f..f0ec1af5a8a 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -632,7 +632,6 @@ extern int __wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, cons extern void __wt_err(WT_SESSION_IMPL *session, int error, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))) WT_GCC_FUNC_DECL_ATTRIBUTE((visibility("default"))); extern void __wt_errx(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) 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))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern void __wt_verbose_worker(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 2, 3))) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)); extern int __wt_msg(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((cold)) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 2, 3))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_ext_msg_printf( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern const char *__wt_ext_strerror(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, int error); diff --git a/src/include/gcc.h b/src/include/gcc.h index 043d9b44356..21eaaaef049 100644 --- a/src/include/gcc.h +++ b/src/include/gcc.h @@ -21,7 +21,7 @@ * dist/s_prototypes to create extern.h. */ #define WT_GCC_FUNC_ATTRIBUTE(x) -#define WT_GCC_FUNC_DECL_ATTRIBUTE(x) __attribute__(x) +#define WT_GCC_FUNC_DECL_ATTRIBUTE(x) __attribute__(x) /* * Atomic writes: diff --git a/src/include/misc.i b/src/include/misc.i index bb785a63072..36a1e1f18eb 100644 --- a/src/include/misc.i +++ b/src/include/misc.i @@ -80,6 +80,39 @@ __wt_time_check_monotonic(WT_SESSION_IMPL *session, struct timespec *tsp) } /* + * __wt_verbose -- + * Verbose message. + * + * Inline functions are not parsed for external prototypes, so in cases where we + * want GCC attributes attached to the functions, we have to do so explicitly. + */ +static inline void +__wt_verbose(WT_SESSION_IMPL *session, int flag, const char *fmt, ...) +WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))); + +/* + * __wt_verbose -- + * Verbose message. + */ +static inline void +__wt_verbose(WT_SESSION_IMPL *session, int flag, const char *fmt, ...) +{ +#ifdef HAVE_VERBOSE + va_list ap; + + if (WT_VERBOSE_ISSET(session, flag)) { + va_start(ap, fmt); + WT_IGNORE_RET(__wt_eventv(session, true, 0, NULL, 0, fmt, ap)); + va_end(ap); + } +#else + WT_UNUSED(session); + WT_UNUSED(flag); + WT_UNUSED(fmt); +#endif +} + +/* * __wt_snprintf -- * snprintf convenience function, ignoring the returned size. */ diff --git a/src/log/log_slot.c b/src/log/log_slot.c index e0b301398a3..2d67d92394f 100644 --- a/src/log/log_slot.c +++ b/src/log/log_slot.c @@ -31,7 +31,7 @@ __log_slot_dump(WT_SESSION_IMPL *session) earliest = i; __wt_errx(session, "Slot %d:", i); __wt_errx(session, " State: %" PRIx64 " Flags: %" PRIx32, - (uint64_t)slot->slot_state, slot->flags); + slot->slot_state, slot->flags); __wt_errx(session, " Start LSN: %" PRIu32 "/%" PRIu32, slot->slot_start_lsn.l.file, slot->slot_start_lsn.l.offset); __wt_errx(session, " End LSN: %" PRIu32 "/%" PRIu32, @@ -173,9 +173,9 @@ retry: if (WT_TIMEDIFF_SEC(now, begin) > 10) { __wt_errx(session, "SLOT_CLOSE: Slot %" PRIu32 " Timeout unbuffered, state 0x%" - PRIx64 " unbuffered %" PRId64, + PRIx64 " unbuffered %" PRIu64, (uint32_t)(slot - &log->slot_pool[0]), - (uint64_t)slot->slot_state, + slot->slot_state, slot->slot_unbuffered); __log_slot_dump(session); __wt_abort(session); diff --git a/src/lsm/lsm_merge.c b/src/lsm/lsm_merge.c index f3990a72d95..28e954c6f6a 100644 --- a/src/lsm/lsm_merge.c +++ b/src/lsm/lsm_merge.c @@ -621,7 +621,7 @@ err: if (locked) if (ret == EINTR) __wt_verbose(session, WT_VERB_LSM, - "%s", "Merge aborted due to close"); + "Merge aborted due to close"); else __wt_verbose(session, WT_VERB_LSM, "Merge failed with %s", diff --git a/src/meta/meta_ckpt.c b/src/meta/meta_ckpt.c index 24f991cf549..0e96c4ee6ca 100644 --- a/src/meta/meta_ckpt.c +++ b/src/meta/meta_ckpt.c @@ -429,7 +429,7 @@ __wt_meta_ckptlist_set(WT_SESSION_IMPL *session, } if (strcmp(ckpt->name, WT_CHECKPOINT) == 0) WT_ERR(__wt_buf_catfmt(session, buf, - "%s%s.%" PRId64 "=(addr=\"%.*s\",order=%" PRId64 + "%s%s.%" PRId64 "=(addr=\"%.*s\",order=%" PRIu64 ",time=%" PRIuMAX ",size=%" PRIu64 ",write_gen=%" PRIu64 ")", sep, ckpt->name, ckpt->order, @@ -438,7 +438,7 @@ __wt_meta_ckptlist_set(WT_SESSION_IMPL *session, ckpt->write_gen)); else WT_ERR(__wt_buf_catfmt(session, buf, - "%s%s=(addr=\"%.*s\",order=%" PRId64 + "%s%s=(addr=\"%.*s\",order=%" PRIu64 ",time=%" PRIuMAX ",size=%" PRIu64 ",write_gen=%" PRIu64 ")", sep, ckpt->name, diff --git a/src/reconcile/rec_track.c b/src/reconcile/rec_track.c index ee97d684529..3e8c71da507 100644 --- a/src/reconcile/rec_track.c +++ b/src/reconcile/rec_track.c @@ -36,9 +36,6 @@ __ovfl_discard_verbose( WT_CELL_UNPACK *unpack, _unpack; WT_DECL_ITEM(tmp); - WT_UNUSED(page); /* !HAVE_VERBOSE */ - WT_UNUSED(tag); /* !HAVE_VERBOSE */ - WT_RET(__wt_scr_alloc(session, 512, &tmp)); unpack = &_unpack; @@ -172,10 +169,6 @@ __ovfl_reuse_verbose(WT_SESSION_IMPL *session, { WT_DECL_ITEM(tmp); - WT_UNUSED(page); /* !HAVE_VERBOSE */ - WT_UNUSED(reuse); /* !HAVE_VERBOSE */ - WT_UNUSED(tag); /* !HAVE_VERBOSE */ - WT_RET(__wt_scr_alloc(session, 64, &tmp)); __wt_verbose(session, WT_VERB_OVERFLOW, @@ -189,8 +182,7 @@ __ovfl_reuse_verbose(WT_SESSION_IMPL *session, F_ISSET(reuse, WT_OVFL_REUSE_INUSE) && F_ISSET(reuse, WT_OVFL_REUSE_JUST_ADDED) ? ", " : "", F_ISSET(reuse, WT_OVFL_REUSE_JUST_ADDED) ? "just-added" : "", - (int)WT_MIN(reuse->value_size, 40), - (char *)WT_OVFL_REUSE_VALUE(reuse)); + WT_MIN(reuse->value_size, 40), (char *)WT_OVFL_REUSE_VALUE(reuse)); __wt_scr_free(session, &tmp); return (0); diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c index 970f760f4ca..857ea3b7b8a 100644 --- a/src/reconcile/rec_write.c +++ b/src/reconcile/rec_write.c @@ -5032,7 +5032,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) cell = NULL; key_onpage_ovfl = false; - WT_RET(__rec_split_init(session, r, page, 0, btree->maxintlpage)); + WT_RET(__rec_split_init(session, r, page, 0ULL, btree->maxintlpage)); /* * Ideally, we'd never store the 0th key on row-store internal pages @@ -5314,7 +5314,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, key = &r->k; val = &r->v; - WT_RET(__rec_split_init(session, r, page, 0, btree->maxleafpage)); + WT_RET(__rec_split_init(session, r, page, 0ULL, btree->maxleafpage)); /* * Write any K/V pairs inserted into the page before the first from-disk diff --git a/src/session/session_api.c b/src/session/session_api.c index 2ad2380dc2c..3610cd17d71 100644 --- a/src/session/session_api.c +++ b/src/session/session_api.c @@ -1828,7 +1828,7 @@ __open_session(WT_CONNECTION_IMPL *conn, if (i == conn->session_size) WT_ERR_MSG(session, ENOMEM, "only configured to support %" PRIu32 " sessions" - " (including %d additional internal sessions)", + " (including %" PRIu32 " additional internal sessions)", conn->session_size, WT_EXTRA_INTERNAL_SESSIONS); /* diff --git a/src/support/err.c b/src/support/err.c index 94ae27628c2..a62a9895684 100644 --- a/src/support/err.c +++ b/src/support/err.c @@ -361,22 +361,6 @@ __wt_ext_err_printf( } /* - * __wt_verbose_worker -- - * Verbose message. - */ -void -__wt_verbose_worker(WT_SESSION_IMPL *session, const char *fmt, ...) - WT_GCC_FUNC_ATTRIBUTE((format (printf, 2, 3))) - WT_GCC_FUNC_ATTRIBUTE((cold)) -{ - va_list ap; - - va_start(ap, fmt); - WT_IGNORE_RET(__wt_eventv(session, true, 0, NULL, 0, fmt, ap)); - va_end(ap); -} - -/* * info_msg -- * Informational message. */ diff --git a/src/txn/txn_recover.c b/src/txn/txn_recover.c index d08c2717f7a..b5c25a44a31 100644 --- a/src/txn/txn_recover.c +++ b/src/txn/txn_recover.c @@ -235,8 +235,8 @@ __txn_op_apply( return (0); err: __wt_err(session, ret, - "operation apply failed during recovery: operation type %" - PRIu32 " at LSN %" PRIu32 "/%" PRIu32, + "operation apply failed during recovery: operation type %d " + "at LSN %" PRIu32 "/%" PRIu32, optype, lsnp->l.file, lsnp->l.offset); return (ret); } diff --git a/src/utilities/util_list.c b/src/utilities/util_list.c index dcb1c97b529..72888e03183 100644 --- a/src/utilities/util_list.c +++ b/src/utilities/util_list.c @@ -231,8 +231,7 @@ list_print_checkpoint(WT_SESSION *session, const char *key) if (ci.root_size != 0) { printf("\t\t" "root offset: %" PRIuMAX " (0x%" PRIxMAX ")\n", - (uintmax_t)ci.root_offset, - (uintmax_t)ci.root_offset); + (intmax_t)ci.root_offset, (intmax_t)ci.root_offset); printf("\t\t" "root size: %" PRIu32 " (0x%" PRIx32 ")\n", ci.root_size, ci.root_size); diff --git a/test/fops/fops.c b/test/fops/fops.c index cf182d757e2..911bfba55ad 100644 --- a/test/fops/fops.c +++ b/test/fops/fops.c @@ -161,7 +161,7 @@ print_stats(u_int nthreads) s = run_stats; for (id = 0; id < nthreads; ++id, ++s) printf( - "%2u:" + "%2d:" "\t" "bulk %3d, checkpoint %3d, create %3d, cursor %3d,\n" "\t" "drop %3d, rebalance %3d, upgrade %3d, verify %3d\n", id, s->bulk + s->bulk_unique, s->ckpt, diff --git a/test/format/t.c b/test/format/t.c index c70f6facfc5..0cfe4e40421 100644 --- a/test/format/t.c +++ b/test/format/t.c @@ -250,7 +250,7 @@ main(int argc, char *argv[]) /* Overwrite the progress line with a completion line. */ if (!g.c_quiet) printf("\r%78s\r", " "); - printf("%4" PRIu32 ": %s, %s (%.0f seconds)\n", + printf("%4d: %s, %s (%.0f seconds)\n", g.run_cnt, g.c_data_source, g.c_file_type, difftime(time(NULL), start)); fflush(stdout); diff --git a/test/packing/intpack-test.c b/test/packing/intpack-test.c index 172575c3d3d..e7822015091 100644 --- a/test/packing/intpack-test.c +++ b/test/packing/intpack-test.c @@ -31,14 +31,14 @@ int main(void) { - uint64_t ncalls, r, r2, s; - uint8_t buf[WT_INTPACK64_MAXSIZE], *p; const uint8_t *cp; + uint8_t buf[10], *p; + uint64_t ncalls, r, r2, s; int i; - memset(buf, 0xff, sizeof(buf)); /* -Werror=maybe-uninitialized */ + ncalls = 0; - for (ncalls = 0, i = 0; i < 10000000; i++) { + for (i = 0; i < 10000000; i++) { for (s = 0; s < 50; s += 5) { ++ncalls; r = 1ULL << s; @@ -60,11 +60,14 @@ main(void) cp = buf; memmove(&r2, cp, sizeof(r2)); #endif - testutil_assert(r == r2); + if (r != r2) { + fprintf(stderr, "mismatch!\n"); + break; + } } } - printf("Number of calls: %" PRIu64 "\n", ncalls); + printf("Number of calls: %llu\n", (unsigned long long)ncalls); return (0); } diff --git a/test/packing/intpack-test2.c b/test/packing/intpack-test2.c index 13f9ab0d2d7..e216899cebb 100644 --- a/test/packing/intpack-test2.c +++ b/test/packing/intpack-test2.c @@ -31,7 +31,7 @@ int main(void) { - uint8_t buf[WT_INTPACK64_MAXSIZE], *p, *end; + uint8_t buf[10], *p, *end; int64_t i; for (i = 1; i < 1LL << 60; i <<= 1) { diff --git a/test/packing/intpack-test3.c b/test/packing/intpack-test3.c index dad31fd7f7d..00fc80e24a2 100644 --- a/test/packing/intpack-test3.c +++ b/test/packing/intpack-test3.c @@ -35,7 +35,7 @@ void test_value(int64_t val) { const uint8_t *cp; - uint8_t buf[WT_INTPACK64_MAXSIZE], *p; + uint8_t buf[10], *p; int64_t sinput, soutput; uint64_t uinput, uoutput; size_t used_len; @@ -50,8 +50,8 @@ test_value(int64_t val) testutil_check(__wt_vunpack_int(&cp, used_len, &soutput)); /* Ensure we got the correct value back */ if (sinput != soutput) { - fprintf(stderr, - "mismatch %" PRId64 ", %" PRId64 "\n", sinput, soutput); + fprintf(stderr, "mismatch %" PRIu64 ", %" PRIu64 "\n", + sinput, soutput); abort(); } /* Ensure that decoding used the correct amount of buffer */ @@ -74,8 +74,8 @@ test_value(int64_t val) testutil_check(__wt_vunpack_uint(&cp, sizeof(buf), &uoutput)); /* Ensure we got the correct value back */ if (sinput != soutput) { - fprintf(stderr, - "mismatch %" PRId64 ", %" PRId64 "\n", sinput, soutput); + fprintf(stderr, "mismatch %" PRIu64 ", %" PRIu64 "\n", + sinput, soutput); abort(); } /* Ensure that decoding used the correct amount of buffer */ diff --git a/test/packing/packing-test.c b/test/packing/packing-test.c index 684cdec554a..bd48ac7125c 100644 --- a/test/packing/packing-test.c +++ b/test/packing/packing-test.c @@ -51,7 +51,7 @@ check(const char *fmt, ...) printf("%s ", fmt); for (p = buf, end = p + len; p < end; p++) - printf("%02x", (u_char)*p & 0xff); + printf("%02x", *p & 0xff); printf("\n"); } diff --git a/test/thread/rw.c b/test/thread/rw.c index 66f706d0d34..3283f780b32 100644 --- a/test/thread/rw.c +++ b/test/thread/rw.c @@ -347,6 +347,6 @@ print_stats(u_int nthreads) s = run_info; for (id = 0; id < nthreads; ++id, ++s) - printf("%3u: read %6d, remove %6d, update %6d\n", + printf("%3d: read %6d, remove %6d, update %6d\n", id, s->reads, s->remove, s->update); } |