summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-06-08 00:58:49 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-06-08 14:58:49 +1000
commit36229a2693aa6e7bcb8fa471edf1ab05ee79869a (patch)
tree4a9e197e64f2d1c1a07b2595c828814cb82019a2
parent1e30ff33750b5a5885420654f6d39101b6cb8610 (diff)
downloadmongo-36229a2693aa6e7bcb8fa471edf1ab05ee79869a.tar.gz
WT-2682 add option to configure WiredTiger with strict compiler flags (#2773)
Add the --enable-strict option that uses our current best guess at the right flags for strict compilation. While adding the option, expand the set of flags we can compile cleanly with.
-rw-r--r--bench/wtperf/wtperf.c2
-rw-r--r--bench/wtperf/wtperf.h3
-rw-r--r--build_posix/aclocal/options.m410
-rw-r--r--build_posix/aclocal/strict.m474
-rw-r--r--build_posix/configure.ac.in37
-rwxr-xr-xdist/s_prototypes15
-rw-r--r--examples/c/ex_event_handler.c5
-rw-r--r--src/async/async_worker.c5
-rw-r--r--src/block/block_ckpt.c5
-rw-r--r--src/block/block_compact.c4
-rw-r--r--src/block/block_open.c2
-rw-r--r--src/block/block_vrfy.c6
-rw-r--r--src/btree/bt_cursor.c11
-rw-r--r--src/btree/bt_debug.c15
-rw-r--r--src/btree/bt_discard.c2
-rw-r--r--src/btree/bt_handle.c2
-rw-r--r--src/btree/bt_io.c2
-rw-r--r--src/btree/bt_sync.c13
-rw-r--r--src/checksum/checksum.c2
-rw-r--r--src/checksum/power8/crc32_wrapper.c5
-rw-r--r--src/cursor/cur_bulk.c1
-rw-r--r--src/evict/evict_file.c3
-rw-r--r--src/evict/evict_lru.c3
-rw-r--r--src/include/btree_cmp.i20
-rw-r--r--src/include/cell.i26
-rw-r--r--src/include/extern.h9
-rw-r--r--src/include/misc.h6
-rw-r--r--src/include/packing.i2
-rw-r--r--src/meta/meta_track.c2
-rw-r--r--src/reconcile/rec_write.c10
-rw-r--r--src/schema/schema_list.c2
-rw-r--r--src/support/err.c19
-rw-r--r--src/support/hash_city.c2
-rw-r--r--src/support/hazard.c14
-rw-r--r--src/support/huffman.c23
-rw-r--r--src/txn/txn.c2
-rw-r--r--src/txn/txn_log.c20
-rw-r--r--test/bloom/test_bloom.c3
-rw-r--r--test/checkpoint/test_checkpoint.c3
-rw-r--r--test/csuite/wt2246_col_append/main.c2
-rw-r--r--test/cursor_order/cursor_order.c3
-rw-r--r--test/fops/t.c3
-rw-r--r--test/format/format.h8
-rw-r--r--test/format/t.c3
-rw-r--r--test/format/wts.c4
-rw-r--r--test/huge/huge.c6
-rw-r--r--test/manydbs/manydbs.c10
-rw-r--r--test/readonly/readonly.c5
-rw-r--r--test/recovery/random-abort.c4
-rw-r--r--test/recovery/truncated-log.c3
-rw-r--r--test/thread/t.c3
-rw-r--r--test/utility/test_util.h5
52 files changed, 308 insertions, 141 deletions
diff --git a/bench/wtperf/wtperf.c b/bench/wtperf/wtperf.c
index 1a3d98d3e3e..9d35f6fa640 100644
--- a/bench/wtperf/wtperf.c
+++ b/bench/wtperf/wtperf.c
@@ -2608,7 +2608,7 @@ wtperf_rand(CONFIG_THREAD *thread)
S2 = wtperf_value_range(cfg) *
(cfg->pareto / 100.0) * (PARETO_SHAPE - 1);
U = 1 - (double)rval / (double)UINT32_MAX;
- rval = (pow(U, S1) - 1) * S2;
+ rval = (uint64_t)((pow(U, S1) - 1) * S2);
/*
* This Pareto calculation chooses out of range values about
* 2% of the time, from my testing. That will lead to the
diff --git a/bench/wtperf/wtperf.h b/bench/wtperf/wtperf.h
index 83fab4d6028..d874fa4eefe 100644
--- a/bench/wtperf/wtperf.h
+++ b/bench/wtperf/wtperf.h
@@ -320,6 +320,9 @@ extract_key(char *key_buf, uint64_t *keynop)
* Print message and exit on failure.
*/
static inline void
+die(int, const char *)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
+static inline void
die(int e, const char *str)
{
fprintf(stderr, "Call to %s failed: %s", str, wiredtiger_strerror(e));
diff --git a/build_posix/aclocal/options.m4 b/build_posix/aclocal/options.m4
index 0fb49dbf1df..5f9b8748df2 100644
--- a/build_posix/aclocal/options.m4
+++ b/build_posix/aclocal/options.m4
@@ -215,6 +215,16 @@ pthread_adaptive|pthreads_adaptive)
esac
AC_MSG_RESULT($with_spinlock)
+AC_MSG_CHECKING(if --enable-strict option specified)
+AC_ARG_ENABLE(strict,
+ [AS_HELP_STRING([--enable-strict],
+ [Enable strict compiler checking.])], r=$enableval, r=no)
+case "$r" in
+no) wt_cv_enable_strict=no;;
+*) wt_cv_enable_strict=yes;;
+esac
+AC_MSG_RESULT($wt_cv_enable_strict)
+
AH_TEMPLATE(HAVE_VERBOSE, [Enable verbose message configuration.])
AC_MSG_CHECKING(if --enable-verbose option specified)
AC_ARG_ENABLE(verbose,
diff --git a/build_posix/aclocal/strict.m4 b/build_posix/aclocal/strict.m4
new file mode 100644
index 00000000000..b59f09fe584
--- /dev/null
+++ b/build_posix/aclocal/strict.m4
@@ -0,0 +1,74 @@
+# AM_STRICT
+# Per compiler-version flags used when compiling in strict mode.
+
+# GCC warnings.
+AC_DEFUN([AM_GCC_WARNINGS], [
+ w="$w -Wall -Wextra -Werror"
+
+ w="$w -Waggregate-return"
+ w="$w -Wbad-function-cast"
+ w="$w -Wcast-align"
+ w="$w -Wdeclaration-after-statement"
+ w="$w -Wdouble-promotion"
+ w="$w -Wfloat-equal"
+ w="$w -Wformat-nonliteral"
+ w="$w -Wformat-security"
+ w="$w -Wformat=2"
+ w="$w -Winit-self"
+ 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"
+ w="$w -Wpacked"
+ w="$w -Wpointer-arith"
+ w="$w -Wpointer-sign"
+ w="$w -Wredundant-decls"
+ w="$w -Wshadow"
+ w="$w -Wsign-conversion"
+ w="$w -Wstrict-prototypes"
+ w="$w -Wswitch-enum"
+ w="$w -Wundef"
+ w="$w -Wunreachable-code"
+ w="$w -Wunsafe-loop-optimizations"
+ w="$w -Wunused"
+ w="$w -Wwrite-strings"
+
+ # Non-fatal informational warnings.
+ w="$w -Wno-error=inline"
+ w="$w -Wno-error=unsafe-loop-optimizations"
+
+ wt_cv_strict_warnings="$w"
+])
+
+# Clang warnings.
+AC_DEFUN([AM_CLANG_WARNINGS], [
+ w="-Weverything -Werror"
+
+ w="$w -Wno-cast-align"
+ w="$w -Wno-documentation-unknown-command"
+ w="$w -Wno-format-nonliteral"
+ w="$w -Wno-packed"
+ w="$w -Wno-padded"
+ w="$w -Wno-reserved-id-macro"
+ w="$w -Wno-zero-length-array"
+
+ # We should turn on cast-qual, but not as a fatal error: see WT-2690.
+ # For now, turn it off.
+ # w="$w -Wno-error=cast-qual"
+ w="$w -Wno-cast-qual"
+
+ # Older OS X releases need some special love; these flags should be
+ # removed in the not-too-distant future.
+ # Apple clang version 4.1
+ # (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
+ w="$w -Wno-pedantic"
+ w="$w -Wno-unused-command-line-argument"
+
+ # Ignore unrecognized options.
+ w="$w -Wno-unknown-warning-option"
+
+ wt_cv_strict_warnings="$w"
+])
diff --git a/build_posix/configure.ac.in b/build_posix/configure.ac.in
index 617304f9215..64d8a3f6d52 100644
--- a/build_posix/configure.ac.in
+++ b/build_posix/configure.ac.in
@@ -9,19 +9,20 @@ AC_CONFIG_AUX_DIR([build_posix/gnu-support])
AC_CONFIG_MACRO_DIR([build_posix/aclocal])
AC_CONFIG_SRCDIR([RELEASE_INFO])
-# If CFLAGS/CXXFLAGS were not set on entry, default to "-O3 -g"
-: ${CFLAGS=-O3 -g}
-: ${CXXFLAGS=-O3 -g}
-
# We rely on some automake features for testing (like AM_TEST_ENVIRONMENT)
# that didn't work before 1.11.6.
AM_INIT_AUTOMAKE([1.11.6 foreign parallel-tests subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
-# Configure options. The AM_OPTIONS and the libtool configuration
-# need to stay here. Moving them below the compiler and other
-# configurations causes -Wcast_align warnings and other warnings
-# on OS X.
+# If CFLAGS/CXXFLAGS were not set on entry, default to "-O3 -g"
+: ${CFLAGS=-O3 -g}
+: ${CXXFLAGS=-O3 -g}
+
+AC_PROG_CC(cc gcc)
+AC_PROG_CXX(c++ g++)
+AM_PROG_AS(as gas)
+
+# Configure options.
AM_OPTIONS
define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
@@ -30,9 +31,23 @@ LT_PREREQ(2.2.6)
LT_INIT([pic-only])
AC_SUBST([LIBTOOL_DEPS])
-AC_PROG_CC(cc gcc)
-AC_PROG_CXX(c++ g++)
-AM_PROG_AS(as gas)
+# If enable-strict is configured, turn on as much error checking as we can for
+# this compiler. Intended for developers, and only works for gcc/clang, but it
+# fills a need.
+if test "$wt_cv_enable_strict" = "yes"; then
+ wt_cv_cc_version="`$CC --version | sed -eq`"
+ case "$wt_cv_cc_version" in
+ *clang*)
+ AM_CLANG_WARNINGS;;
+ *gcc*)
+ AM_GCC_WARNINGS;;
+ *)
+ AC_MSG_ERROR(
+ [--enable-strict does not support "$wt_cv_cc_version".]);;
+ esac
+
+ AM_CFLAGS="$AM_CFLAGS $wt_cv_strict_warnings"
+fi
AM_CONDITIONAL([POSIX_HOST], [true])
AM_CONDITIONAL([WINDOWS_HOST], [false])
diff --git a/dist/s_prototypes b/dist/s_prototypes
index 01d1e9bb4c3..dbcceab117b 100755
--- a/dist/s_prototypes
+++ b/dist/s_prototypes
@@ -28,8 +28,19 @@ proto()
-e 's/\* /\*/g' \
-e 's/ */ /g' \
-e 's/^/extern /' \
- -e 's/WT_GCC_FUNC_/WT_GCC_FUNC_DECL_/' \
- -e 's/$/;/p' < $1
+ -e 's/WT_GCC_FUNC_/WT_GCC_FUNC_DECL_/g' \
+ -e '# If a line ends in #endif, appending a semicolon will result' \
+ -e '# in an illegal expression, force an appended newline using' \
+ -e '# the H command because substitute may not allow newline in' \
+ -e '# the RHS of the expression.' \
+ -e '/#endif$/{' \
+ -e x \
+ -e 's/.*//' \
+ -e H \
+ -e x \
+ -e '}' \
+ -e 's/$/;/' \
+ -e p < $1
}
(
diff --git a/examples/c/ex_event_handler.c b/examples/c/ex_event_handler.c
index f2cdd00d9d7..7122e71882e 100644
--- a/examples/c/ex_event_handler.c
+++ b/examples/c/ex_event_handler.c
@@ -68,7 +68,7 @@ handle_wiredtiger_error(WT_EVENT_HANDLER *handler,
/* Report the error on the console. */
fprintf(stderr,
"app_id %s, thread context %p, error %d, message %s\n",
- custom_handler->app_id, session, error, message);
+ custom_handler->app_id, (void *)session, error, message);
return (0);
}
@@ -83,7 +83,8 @@ handle_wiredtiger_message(
{
/* Cast the handler back to our custom handler. */
printf("app id %s, thread context %p, message %s\n",
- ((CUSTOM_EVENT_HANDLER *)handler)->app_id, session, message);
+ ((CUSTOM_EVENT_HANDLER *)handler)->app_id,
+ (void *)session, message);
return (0);
}
diff --git a/src/async/async_worker.c b/src/async/async_worker.c
index e692bc619a9..90dac557e36 100644
--- a/src/async/async_worker.c
+++ b/src/async/async_worker.c
@@ -216,9 +216,8 @@ __async_worker_execop(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op,
__wt_cursor_set_raw_value(&asyncop->c, &val);
break;
case WT_AOP_NONE:
- default:
- WT_RET_MSG(session, EINVAL, "Unknown async optype %d\n",
- op->optype);
+ WT_RET_MSG(session, EINVAL,
+ "Unknown async optype %d\n", op->optype);
}
return (0);
}
diff --git a/src/block/block_ckpt.c b/src/block/block_ckpt.c
index 716121faa06..b9f0ec25d53 100644
--- a/src/block/block_ckpt.c
+++ b/src/block/block_ckpt.c
@@ -63,6 +63,7 @@ __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block,
*/
*root_addr_sizep = 0;
+#ifdef HAVE_VERBOSE
if (WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT)) {
if (addr != NULL) {
WT_ERR(__wt_scr_alloc(session, 0, &tmp));
@@ -72,6 +73,7 @@ __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block,
"%s: load-checkpoint: %s", block->name,
addr == NULL ? "[Empty]" : (const char *)tmp->data));
}
+#endif
/*
* There's a single checkpoint in the file that can be written, all of
@@ -507,6 +509,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase)
!F_ISSET(ckpt, WT_CKPT_DELETE))
continue;
+#ifdef HAVE_VERBOSE
if (WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT)) {
if (tmp == NULL)
WT_ERR(__wt_scr_alloc(session, 0, &tmp));
@@ -516,7 +519,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase)
"%s: delete-checkpoint: %s: %s",
block->name, ckpt->name, (const char *)tmp->data));
}
-
+#endif
/*
* Find the checkpoint into which we'll roll this checkpoint's
* blocks: it's the next real checkpoint in the list, and it
diff --git a/src/block/block_compact.c b/src/block/block_compact.c
index 24ca6632311..02862ea842f 100644
--- a/src/block/block_compact.c
+++ b/src/block/block_compact.c
@@ -39,12 +39,14 @@ __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block)
/* Restore the original allocation plan. */
__wt_block_configure_first_fit(block, false);
+#ifdef HAVE_VERBOSE
/* Dump the results of the compaction pass. */
if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT)) {
__wt_spin_lock(session, &block->live_lock);
ret = __block_dump_avail(session, block, false);
__wt_spin_unlock(session, &block->live_lock);
}
+#endif
return (ret);
}
@@ -188,6 +190,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
}
__wt_spin_unlock(session, &block->live_lock);
+#ifdef HAVE_VERBOSE
if (WT_VERBOSE_ISSET(session, WT_VERB_COMPACT)) {
++block->compact_pages_reviewed;
if (*skipp)
@@ -195,6 +198,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
else
++block->compact_pages_written;
}
+#endif
return (ret);
}
diff --git a/src/block/block_open.c b/src/block/block_open.c
index e58bef30a6d..1603b1574e7 100644
--- a/src/block/block_open.c
+++ b/src/block/block_open.c
@@ -59,7 +59,7 @@ __wt_block_manager_create(
session, filename, tmp->data));
WT_ERR(__wt_msg(session,
"unexpected file %s found, renamed to %s",
- filename, (char *)tmp->data));
+ filename, (const char *)tmp->data));
break;
}
}
diff --git a/src/block/block_vrfy.c b/src/block/block_vrfy.c
index a8e59ad0af7..36a73fac761 100644
--- a/src/block/block_vrfy.c
+++ b/src/block/block_vrfy.c
@@ -20,8 +20,10 @@ static int __verify_set_file_size(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *);
/* The bit list ignores the first block: convert to/from a frag/offset. */
#define WT_wt_off_TO_FRAG(block, off) \
((off) / (block)->allocsize - 1)
+#ifdef HAVE_VERBOSE
#define WT_FRAG_TO_OFF(block, frag) \
(((wt_off_t)(frag + 1)) * (block)->allocsize)
+#endif
/*
* __wt_block_verify_start --
@@ -443,6 +445,7 @@ __verify_filefrag_chk(WT_SESSION_IMPL *session, WT_BLOCK *block)
__bit_set(block->fragfile, last);
}
+#ifdef HAVE_VERBOSE
if (!WT_VERBOSE_ISSET(session, WT_VERB_VERIFY))
continue;
@@ -450,6 +453,7 @@ __verify_filefrag_chk(WT_SESSION_IMPL *session, WT_BLOCK *block)
"file range %" PRIuMAX "-%" PRIuMAX " never verified",
(uintmax_t)WT_FRAG_TO_OFF(block, first),
(uintmax_t)WT_FRAG_TO_OFF(block, last));
+#endif
}
if (count == 0)
return (0);
@@ -534,6 +538,7 @@ __verify_ckptfrag_chk(WT_SESSION_IMPL *session, WT_BLOCK *block)
__bit_clear(block->fragckpt, last);
}
+#ifdef HAVE_VERBOSE
if (!WT_VERBOSE_ISSET(session, WT_VERB_VERIFY))
continue;
@@ -541,6 +546,7 @@ __verify_ckptfrag_chk(WT_SESSION_IMPL *session, WT_BLOCK *block)
"checkpoint range %" PRIuMAX "-%" PRIuMAX " never verified",
(uintmax_t)WT_FRAG_TO_OFF(block, first),
(uintmax_t)WT_FRAG_TO_OFF(block, last));
+#endif
}
if (count == 0)
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index 4b73b76c8c8..ab9e43fbf39 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -559,7 +559,6 @@ retry: WT_RET(__cursor_func_init(cbt, true));
ret = __cursor_row_modify(session, cbt, false);
break;
- WT_ILLEGAL_VALUE_ERR(session);
}
err: if (ret == WT_RESTART) {
@@ -640,7 +639,8 @@ retry: WT_RET(__cursor_func_init(cbt, true));
break;
case BTREE_COL_FIX:
case BTREE_COL_VAR:
- WT_ILLEGAL_VALUE_ERR(session);
+ WT_ERR(__wt_illegal_value(session, NULL));
+ break;
}
err: if (ret == WT_RESTART) {
@@ -718,7 +718,6 @@ retry: WT_RET(__cursor_func_init(cbt, true));
ret = __cursor_row_modify(session, cbt, true);
break;
- WT_ILLEGAL_VALUE_ERR(session);
}
err: if (ret == WT_RESTART) {
@@ -809,7 +808,6 @@ retry: WT_RET(__cursor_func_init(cbt, true));
}
ret = __cursor_row_modify(session, cbt, false);
break;
- WT_ILLEGAL_VALUE_ERR(session);
}
err: if (ret == WT_RESTART) {
@@ -976,7 +974,6 @@ __wt_btcur_compare(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *cmpp)
WT_RET(__wt_compare(
session, a_arg->btree->collator, &a->key, &b->key, cmpp));
break;
- WT_ILLEGAL_VALUE(session);
}
return (0);
}
@@ -1114,7 +1111,7 @@ __cursor_truncate_fix(WT_SESSION_IMPL *session,
int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, bool))
{
WT_DECL_RET;
- uint8_t *value;
+ const uint8_t *value;
/*
* Handle fixed-length column-store objects separately: for row-store
@@ -1143,7 +1140,7 @@ retry: WT_RET(__wt_btcur_remove(start));
if ((ret = __wt_btcur_next(start, true)) != 0)
break;
start->compare = 0; /* Exact match */
- value = (uint8_t *)start->iface.value.data;
+ value = (const uint8_t *)start->iface.value.data;
if (*value != 0 &&
(ret = rmfunc(session, start, 1)) != 0)
break;
diff --git a/src/btree/bt_debug.c b/src/btree/bt_debug.c
index bd5970ecf86..a0832fc4cf8 100644
--- a/src/btree/bt_debug.c
+++ b/src/btree/bt_debug.c
@@ -431,12 +431,12 @@ __debug_tree_shape_info(WT_PAGE *page)
v = page->memory_footprint;
if (v >= WT_GIGABYTE)
snprintf(buf, sizeof(buf),
- "(%p %" PRIu64 "G)", page, v / WT_GIGABYTE);
+ "(%p %" PRIu64 "G)", (void *)page, v / WT_GIGABYTE);
else if (v >= WT_MEGABYTE)
snprintf(buf, sizeof(buf),
- "(%p %" PRIu64 "M)", page, v / WT_MEGABYTE);
+ "(%p %" PRIu64 "M)", (void *)page, v / WT_MEGABYTE);
else
- snprintf(buf, sizeof(buf), "(%p %" PRIu64 ")", page, v);
+ snprintf(buf, sizeof(buf), "(%p %" PRIu64 ")", (void *)page, v);
return (buf);
}
@@ -636,7 +636,7 @@ __debug_page_metadata(WT_DBG *ds, WT_REF *ref)
page = ref->page;
mod = page->modify;
- __dmsg(ds, "%p", page);
+ __dmsg(ds, "%p", (void *)page);
switch (page->type) {
case WT_PAGE_COL_INT:
@@ -663,7 +663,8 @@ __debug_page_metadata(WT_DBG *ds, WT_REF *ref)
}
__dmsg(ds, ": %s\n", __wt_page_type_string(page->type));
- __dmsg(ds, "\t" "disk %p, entries %" PRIu32, page->dsk, entries);
+ __dmsg(ds,
+ "\t" "disk %p, entries %" PRIu32, (void *)page->dsk, entries);
__dmsg(ds, ", %s", __wt_page_is_modified(page) ? "dirty" : "clean");
__dmsg(ds, ", %s", __wt_fair_islocked(
session, &page->page_lock) ? "locked" : "unlocked");
@@ -990,10 +991,10 @@ __debug_ref(WT_DBG *ds, WT_REF *ref)
__dmsg(ds, "deleted");
break;
case WT_REF_LOCKED:
- __dmsg(ds, "locked %p", ref->page);
+ __dmsg(ds, "locked %p", (void *)ref->page);
break;
case WT_REF_MEM:
- __dmsg(ds, "memory %p", ref->page);
+ __dmsg(ds, "memory %p", (void *)ref->page);
break;
case WT_REF_READING:
__dmsg(ds, "reading");
diff --git a/src/btree/bt_discard.c b/src/btree/bt_discard.c
index 9807d5bc88f..a00bb7dc2b5 100644
--- a/src/btree/bt_discard.c
+++ b/src/btree/bt_discard.c
@@ -82,7 +82,7 @@ __wt_page_out(WT_SESSION_IMPL *session, WT_PAGE **pagep)
if (hp != NULL)
__wt_errx(session,
"discarded page has hazard pointer: (%p: %s, line %d)",
- hp->page, hp->file, hp->line);
+ (void *)hp->page, hp->file, hp->line);
WT_ASSERT(session, hp == NULL);
}
#endif
diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c
index 11d3aafae72..c97e05d74a7 100644
--- a/src/btree/bt_handle.c
+++ b/src/btree/bt_handle.c
@@ -519,7 +519,6 @@ __btree_tree_open_empty(WT_SESSION_IMPL *session, bool creation)
ref->state = WT_REF_DELETED;
WT_ERR(__wt_row_ikey_incr(session, root, 0, "", 1, ref));
break;
- WT_ILLEGAL_VALUE_ERR(session);
}
/* Bulk loads require a leaf page for reconciliation: create it now. */
@@ -567,7 +566,6 @@ __wt_btree_new_leaf_page(WT_SESSION_IMPL *session, WT_PAGE **pagep)
WT_RET(__wt_page_alloc(
session, WT_PAGE_ROW_LEAF, 0, false, pagep));
break;
- WT_ILLEGAL_VALUE(session);
}
return (0);
}
diff --git a/src/btree/bt_io.c b/src/btree/bt_io.c
index aaf906ca785..4339de6f25c 100644
--- a/src/btree/bt_io.c
+++ b/src/btree/bt_io.c
@@ -343,6 +343,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
* Checksum the data if the buffer isn't compressed or checksums are
* configured.
*/
+ data_cksum = true; /* -Werror=maybe-uninitialized */
switch (btree->checksum) {
case CKSUM_ON:
data_cksum = true;
@@ -351,7 +352,6 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
data_cksum = false;
break;
case CKSUM_UNCOMPRESSED:
- default:
data_cksum = !compressed;
break;
}
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c
index 4404069e507..da6c53aa316 100644
--- a/src/btree/bt_sync.c
+++ b/src/btree/bt_sync.c
@@ -188,7 +188,8 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop)
break;
case WT_SYNC_CLOSE:
case WT_SYNC_DISCARD:
- WT_ILLEGAL_VALUE_ERR(session);
+ WT_ERR(__wt_illegal_value(session, NULL));
+ break;
}
if (WT_VERBOSE_ISSET(session, WT_VERB_CHECKPOINT)) {
@@ -273,6 +274,8 @@ err: /* On error, clear any left-over tree walk. */
int
__wt_cache_op(WT_SESSION_IMPL *session, WT_CACHE_OP op)
{
+ WT_DECL_RET;
+
switch (op) {
case WT_SYNC_CHECKPOINT:
case WT_SYNC_CLOSE:
@@ -292,10 +295,12 @@ __wt_cache_op(WT_SESSION_IMPL *session, WT_CACHE_OP op)
switch (op) {
case WT_SYNC_CHECKPOINT:
case WT_SYNC_WRITE_LEAVES:
- return (__sync_file(session, op));
+ ret = __sync_file(session, op);
+ break;
case WT_SYNC_CLOSE:
case WT_SYNC_DISCARD:
- return (__wt_evict_file(session, op));
- WT_ILLEGAL_VALUE(session);
+ ret = __wt_evict_file(session, op);
+ break;
}
+ return (ret);
}
diff --git a/src/checksum/checksum.c b/src/checksum/checksum.c
index 0b086753406..b6a76dacfd8 100644
--- a/src/checksum/checksum.c
+++ b/src/checksum/checksum.c
@@ -1103,6 +1103,7 @@ static const uint32_t g_crc_slicing[8][256] = {
#endif
};
+#if !defined(__powerpc64__)
/*
* __wt_cksum_sw --
* Return a checksum for a chunk of memory, computed in software.
@@ -1171,6 +1172,7 @@ __wt_cksum_sw(const void *chunk, size_t len)
#endif
return (~crc);
}
+#endif
#if (defined(__amd64) || defined(__x86_64))
/*
diff --git a/src/checksum/power8/crc32_wrapper.c b/src/checksum/power8/crc32_wrapper.c
index 34ac4150338..62bd3e64f5c 100644
--- a/src/checksum/power8/crc32_wrapper.c
+++ b/src/checksum/power8/crc32_wrapper.c
@@ -2,7 +2,7 @@
#define CRC_TABLE
#include "crc32_constants.h"
-#define VMX_ALIGN 16
+#define VMX_ALIGN 16U
#define VMX_ALIGN_MASK (VMX_ALIGN-1)
#ifdef REFLECT
@@ -26,6 +26,9 @@ static unsigned int crc32_align(unsigned int crc, unsigned char *p,
unsigned int __crc32_vpmsum(unsigned int crc, unsigned char *p,
unsigned long len);
+/* -Werror=missing-prototypes */
+unsigned int crc32_vpmsum(unsigned int crc, unsigned char *p,
+ unsigned long len);
unsigned int crc32_vpmsum(unsigned int crc, unsigned char *p,
unsigned long len)
{
diff --git a/src/cursor/cur_bulk.c b/src/cursor/cur_bulk.c
index c013383fa61..d1a53057650 100644
--- a/src/cursor/cur_bulk.c
+++ b/src/cursor/cur_bulk.c
@@ -328,7 +328,6 @@ __wt_curbulk_init(WT_SESSION_IMPL *session,
c->insert = skip_sort_check ?
__curbulk_insert_row_skip_check : __curbulk_insert_row;
break;
- WT_ILLEGAL_VALUE(session);
}
cbulk->first_insert = true;
diff --git a/src/evict/evict_file.c b/src/evict/evict_file.c
index ffd48afd1a7..e9f113fdcb2 100644
--- a/src/evict/evict_file.c
+++ b/src/evict/evict_file.c
@@ -88,7 +88,8 @@ __wt_evict_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop)
break;
case WT_SYNC_CHECKPOINT:
case WT_SYNC_WRITE_LEAVES:
- WT_ILLEGAL_VALUE_ERR(session);
+ WT_ERR(__wt_illegal_value(session, NULL));
+ break;
}
}
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index 0c453c9856c..382d6ee1653 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -152,6 +152,7 @@ __wt_evict_server_wake(WT_SESSION_IMPL *session)
conn = S2C(session);
cache = conn->cache;
+#ifdef HAVE_VERBOSE
if (WT_VERBOSE_ISSET(session, WT_VERB_EVICTSERVER)) {
uint64_t bytes_inuse, bytes_max;
@@ -165,6 +166,7 @@ __wt_evict_server_wake(WT_SESSION_IMPL *session)
bytes_inuse <= bytes_max ? "<=" : ">",
bytes_max / WT_MEGABYTE));
}
+#endif
return (__wt_cond_auto_signal(session, cache->evict_cond));
}
@@ -328,6 +330,7 @@ __evict_workers_resize(WT_SESSION_IMPL *session)
uint32_t i, session_flags;
conn = S2C(session);
+ workers = NULL; /* -Wconditional-uninitialized */
if (conn->evict_workers_alloc < conn->evict_workers_max) {
alloc = conn->evict_workers_alloc * sizeof(*workers);
diff --git a/src/include/btree_cmp.i b/src/include/btree_cmp.i
index 1993c1be293..23a462e4e50 100644
--- a/src/include/btree_cmp.i
+++ b/src/include/btree_cmp.i
@@ -52,8 +52,8 @@ __wt_lex_compare(const WT_ITEM *user_item, const WT_ITEM *tree_item)
for (; len > 0;
len -= WT_VECTOR_SIZE,
userp += WT_VECTOR_SIZE, treep += WT_VECTOR_SIZE) {
- u = _mm_load_si128((__m128i *)userp);
- t = _mm_load_si128((__m128i *)treep);
+ u = _mm_load_si128((const __m128i *)userp);
+ t = _mm_load_si128((const __m128i *)treep);
res_eq = _mm_cmpeq_epi8(u, t);
if (_mm_movemask_epi8(res_eq) != 65535)
break;
@@ -62,8 +62,8 @@ __wt_lex_compare(const WT_ITEM *user_item, const WT_ITEM *tree_item)
for (; len > 0;
len -= WT_VECTOR_SIZE,
userp += WT_VECTOR_SIZE, treep += WT_VECTOR_SIZE) {
- u = _mm_loadu_si128((__m128i *)userp);
- t = _mm_loadu_si128((__m128i *)treep);
+ u = _mm_loadu_si128((const __m128i *)userp);
+ t = _mm_loadu_si128((const __m128i *)treep);
res_eq = _mm_cmpeq_epi8(u, t);
if (_mm_movemask_epi8(res_eq) != 65535)
break;
@@ -123,8 +123,8 @@ __wt_lex_compare_skip(
tsz = tree_item->size;
len = WT_MIN(usz, tsz) - *matchp;
- userp = (uint8_t *)user_item->data + *matchp;
- treep = (uint8_t *)tree_item->data + *matchp;
+ userp = (const uint8_t *)user_item->data + *matchp;
+ treep = (const uint8_t *)tree_item->data + *matchp;
#ifdef HAVE_X86INTRIN_H
/* Use vector instructions if we'll execute at least 2 of them. */
@@ -139,8 +139,8 @@ __wt_lex_compare_skip(
len -= WT_VECTOR_SIZE,
userp += WT_VECTOR_SIZE, treep += WT_VECTOR_SIZE,
*matchp += WT_VECTOR_SIZE) {
- u = _mm_load_si128((__m128i *)userp);
- t = _mm_load_si128((__m128i *)treep);
+ u = _mm_load_si128((const __m128i *)userp);
+ t = _mm_load_si128((const __m128i *)treep);
res_eq = _mm_cmpeq_epi8(u, t);
if (_mm_movemask_epi8(res_eq) != 65535)
break;
@@ -150,8 +150,8 @@ __wt_lex_compare_skip(
len -= WT_VECTOR_SIZE,
userp += WT_VECTOR_SIZE, treep += WT_VECTOR_SIZE,
*matchp += WT_VECTOR_SIZE) {
- u = _mm_loadu_si128((__m128i *)userp);
- t = _mm_loadu_si128((__m128i *)treep);
+ u = _mm_loadu_si128((const __m128i *)userp);
+ t = _mm_loadu_si128((const __m128i *)treep);
res_eq = _mm_cmpeq_epi8(u, t);
if (_mm_movemask_epi8(res_eq) != 65535)
break;
diff --git a/src/include/cell.i b/src/include/cell.i
index 481d2a29764..c130768e595 100644
--- a/src/include/cell.i
+++ b/src/include/cell.i
@@ -183,9 +183,9 @@ __wt_cell_pack_addr(WT_CELL *cell, u_int cell_type, uint64_t recno, size_t size)
p = cell->__chunk + 1;
if (recno == WT_RECNO_OOB)
- cell->__chunk[0] = cell_type; /* Type */
+ cell->__chunk[0] = (uint8_t)cell_type; /* Type */
else {
- cell->__chunk[0] = cell_type | WT_CELL_64V;
+ cell->__chunk[0] = (uint8_t)(cell_type | WT_CELL_64V);
(void)__wt_vpack_uint(&p, 0, recno); /* Record number */
}
(void)__wt_vpack_uint(&p, 0, (uint64_t)size); /* Length */
@@ -207,8 +207,8 @@ __wt_cell_pack_data(WT_CELL *cell, uint64_t rle, size_t size)
*/
if (rle < 2 && size <= WT_CELL_SHORT_MAX) {
byte = (uint8_t)size; /* Type + length */
- cell->__chunk[0] =
- (byte << WT_CELL_SHORT_SHIFT) | WT_CELL_VALUE_SHORT;
+ cell->__chunk[0] = (uint8_t)
+ ((byte << WT_CELL_SHORT_SHIFT) | WT_CELL_VALUE_SHORT);
return (1);
}
@@ -331,8 +331,8 @@ __wt_cell_pack_int_key(WT_CELL *cell, size_t size)
/* Short keys have 6 bits of data length in the descriptor byte. */
if (size <= WT_CELL_SHORT_MAX) {
byte = (uint8_t)size;
- cell->__chunk[0] =
- (byte << WT_CELL_SHORT_SHIFT) | WT_CELL_KEY_SHORT;
+ cell->__chunk[0] = (uint8_t)
+ ((byte << WT_CELL_SHORT_SHIFT) | WT_CELL_KEY_SHORT);
return (1);
}
@@ -358,14 +358,14 @@ __wt_cell_pack_leaf_key(WT_CELL *cell, uint8_t prefix, size_t size)
if (size <= WT_CELL_SHORT_MAX) {
if (prefix == 0) {
byte = (uint8_t)size; /* Type + length */
- cell->__chunk[0] =
- (byte << WT_CELL_SHORT_SHIFT) | WT_CELL_KEY_SHORT;
+ cell->__chunk[0] = (uint8_t)
+ ((byte << WT_CELL_SHORT_SHIFT) | WT_CELL_KEY_SHORT);
return (1);
} else {
byte = (uint8_t)size; /* Type + length */
- cell->__chunk[0] =
- (byte << WT_CELL_SHORT_SHIFT) |
- WT_CELL_KEY_SHORT_PFX;
+ cell->__chunk[0] = (uint8_t)
+ ((byte << WT_CELL_SHORT_SHIFT) |
+ WT_CELL_KEY_SHORT_PFX);
cell->__chunk[1] = prefix; /* Prefix */
return (2);
}
@@ -585,8 +585,8 @@ restart:
WT_CELL_LEN_CHK(cell, 0);
unpack->cell = cell;
unpack->v = 0;
- unpack->raw = __wt_cell_type_raw(cell);
- unpack->type = __wt_cell_type(cell);
+ unpack->raw = (uint8_t)__wt_cell_type_raw(cell);
+ unpack->type = (uint8_t)__wt_cell_type(cell);
unpack->ovfl = 0;
/*
diff --git a/src/include/extern.h b/src/include/extern.h
index 34751bfde6c..5bc36454c09 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -598,7 +598,14 @@ extern int __wt_msg(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_
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)));
extern const char *__wt_ext_strerror(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, int error);
extern int __wt_progress(WT_SESSION_IMPL *session, const char *s, uint64_t v);
-extern void __wt_assert(WT_SESSION_IMPL *session, int error, const char *file_name, int line_number, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 5, 6)));
+extern void
+__wt_assert(WT_SESSION_IMPL *session,
+ int error, const char *file_name, int line_number, const char *fmt, ...)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 5, 6)))
+#ifdef HAVE_DIAGNOSTIC
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn))
+#endif
+;
extern int __wt_panic(WT_SESSION_IMPL *session);
extern int __wt_illegal_value(WT_SESSION_IMPL *session, const char *name);
extern int __wt_object_unsupported(WT_SESSION_IMPL *session, const char *uri);
diff --git a/src/include/misc.h b/src/include/misc.h
index 4c7c9572905..e33139387cf 100644
--- a/src/include/misc.h
+++ b/src/include/misc.h
@@ -31,12 +31,12 @@
*/
#define WT_STORE_SIZE(s) ((uint32_t)(s))
#define WT_PTRDIFF(end, begin) \
- ((size_t)((uint8_t *)(end) - (uint8_t *)(begin)))
+ ((size_t)((const uint8_t *)(end) - (const uint8_t *)(begin)))
#define WT_PTRDIFF32(end, begin) \
WT_STORE_SIZE(WT_PTRDIFF((end), (begin)))
#define WT_BLOCK_FITS(p, len, begin, maxlen) \
- ((uint8_t *)(p) >= (uint8_t *)(begin) && \
- ((uint8_t *)(p) + (len) <= (uint8_t *)(begin) + (maxlen)))
+ ((const uint8_t *)(p) >= (const uint8_t *)(begin) && \
+ ((const uint8_t *)(p) + (len) <= (const uint8_t *)(begin) + (maxlen)))
#define WT_PTR_IN_RANGE(p, begin, maxlen) \
WT_BLOCK_FITS((p), 1, (begin), (maxlen))
diff --git a/src/include/packing.i b/src/include/packing.i
index 9d5971ed99f..316169fbe06 100644
--- a/src/include/packing.i
+++ b/src/include/packing.i
@@ -540,7 +540,7 @@ __unpack_read(WT_SESSION_IMPL *session,
break;
case 'R':
WT_SIZE_CHECK_UNPACK(sizeof(uint64_t), maxlen);
- pv->u.u = *(uint64_t *)*pp;
+ pv->u.u = *(const uint64_t *)*pp;
*pp += sizeof(uint64_t);
break;
default:
diff --git a/src/meta/meta_track.c b/src/meta/meta_track.c
index 4fe628e319b..eb06b2bed66 100644
--- a/src/meta/meta_track.c
+++ b/src/meta/meta_track.c
@@ -153,7 +153,6 @@ __meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk)
case WT_ST_REMOVE:
case WT_ST_SET:
break;
- WT_ILLEGAL_VALUE(session);
}
__meta_track_clear(session, trk);
@@ -215,7 +214,6 @@ __meta_track_unroll(WT_SESSION_IMPL *session, WT_META_TRACK *trk)
__wt_err(session, ret,
"metadata unroll update %s to %s", trk->a, trk->b);
break;
- WT_ILLEGAL_VALUE(session);
}
__meta_track_clear(session, trk);
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 6e406fc7180..b49946bb10e 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -1041,6 +1041,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r,
bool append_origv, skipped;
*updp = NULL;
+ append = NULL; /* -Wconditional-uninitialized */
btree = S2BT(session);
page = r->page;
@@ -2428,7 +2429,7 @@ __rec_split(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len)
r->split_size - WT_PAGE_HEADER_BYTE_SIZE(btree);
break;
case SPLIT_TRACKING_RAW:
- WT_ILLEGAL_VALUE(session);
+ return (__wt_illegal_value(session, NULL));
}
/*
@@ -2959,7 +2960,6 @@ __rec_split_finish_std(WT_SESSION_IMPL *session, WT_RECONCILE *r)
* wrote anything, or there's a remaindered block of data.
*/
break;
- WT_ILLEGAL_VALUE(session);
}
/*
@@ -3330,6 +3330,8 @@ supd_check_complete:
}
bnd->entries = r->entries;
+
+#ifdef HAVE_VERBOSE
/* Output a verbose message if we create a page without many entries */
if (WT_VERBOSE_ISSET(session, WT_VERB_SPLIT) && r->entries < 6)
WT_ERR(__wt_verbose(session, WT_VERB_SPLIT,
@@ -3339,6 +3341,7 @@ supd_check_complete:
r->entries, r->page->memory_footprint, r->bnd_next,
F_ISSET(r, WT_EVICTING) ? "evict" : "checkpoint",
r->bnd_state));
+#endif
WT_ERR(__wt_bt_write(session,
buf, addr, &addr_size, false, bnd->already_compressed));
@@ -3527,6 +3530,7 @@ __wt_bulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk)
r = cbulk->reconcile;
r->is_bulk_load = true;
+ recno = WT_RECNO_OOB; /* -Werror=maybe-uninitialized */
switch (btree->type) {
case BTREE_COL_FIX:
case BTREE_COL_VAR:
@@ -3535,7 +3539,6 @@ __wt_bulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk)
case BTREE_ROW:
recno = WT_RECNO_OOB;
break;
- WT_ILLEGAL_VALUE(session);
}
return (__rec_split_init(
@@ -3569,7 +3572,6 @@ __wt_bulk_wrapup(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk)
break;
case BTREE_ROW:
break;
- WT_ILLEGAL_VALUE(session);
}
WT_RET(__rec_split_finish(session, r));
diff --git a/src/schema/schema_list.c b/src/schema/schema_list.c
index 5e9caf94b7a..79e3ef1da7c 100644
--- a/src/schema/schema_list.c
+++ b/src/schema/schema_list.c
@@ -20,6 +20,8 @@ __schema_add_table(WT_SESSION_IMPL *session,
WT_TABLE *table;
uint64_t bucket;
+ table = NULL; /* -Wconditional-uninitialized */
+
/* Make sure the metadata is open before getting other locks. */
WT_RET(__wt_metadata_cursor(session, NULL));
diff --git a/src/support/err.c b/src/support/err.c
index 815b79c16db..93c0af37328 100644
--- a/src/support/err.c
+++ b/src/support/err.c
@@ -469,6 +469,9 @@ void
__wt_assert(WT_SESSION_IMPL *session,
int error, const char *file_name, int line_number, const char *fmt, ...)
WT_GCC_FUNC_ATTRIBUTE((format (printf, 5, 6)))
+#ifdef HAVE_DIAGNOSTIC
+ WT_GCC_FUNC_ATTRIBUTE((noreturn))
+#endif
{
va_list ap;
@@ -493,7 +496,10 @@ __wt_panic(WT_SESSION_IMPL *session)
F_SET(S2C(session), WT_CONN_PANIC);
__wt_err(session, WT_PANIC, "the process must exit and restart");
-#if !defined(HAVE_DIAGNOSTIC)
+#if defined(HAVE_DIAGNOSTIC)
+ __wt_abort(session); /* Drop core if testing. */
+ /* NOTREACHED */
+#else
/*
* Chaos reigns within.
* Reflect, repent, and reboot.
@@ -501,9 +507,6 @@ __wt_panic(WT_SESSION_IMPL *session)
*/
return (WT_PANIC);
#endif
-
- __wt_abort(session); /* Drop core if testing. */
- /* NOTREACHED */
}
/*
@@ -517,12 +520,12 @@ __wt_illegal_value(WT_SESSION_IMPL *session, const char *name)
name == NULL ? "" : name, name == NULL ? "" : ": ",
"encountered an illegal file format or internal value");
-#if !defined(HAVE_DIAGNOSTIC)
- return (__wt_panic(session));
-#endif
-
+#if defined(HAVE_DIAGNOSTIC)
__wt_abort(session); /* Drop core if testing. */
/* NOTREACHED */
+#else
+ return (__wt_panic(session));
+#endif
}
/*
diff --git a/src/support/hash_city.c b/src/support/hash_city.c
index 7a700aa809c..8354532e820 100644
--- a/src/support/hash_city.c
+++ b/src/support/hash_city.c
@@ -85,6 +85,7 @@ static uint32_t UNALIGNED_LOAD32(const char *p) {
return (result);
}
+#ifdef WORDS_BIGENDIAN
#ifdef _MSC_VER
#include <stdlib.h>
@@ -132,7 +133,6 @@ static uint32_t UNALIGNED_LOAD32(const char *p) {
#endif
-#ifdef WORDS_BIGENDIAN
#define uint32_in_expected_order(x) (bswap_32(x))
#define uint64_in_expected_order(x) (bswap_64(x))
#else
diff --git a/src/support/hazard.c b/src/support/hazard.c
index 13e0eb3b9ac..dee85586a4d 100644
--- a/src/support/hazard.c
+++ b/src/support/hazard.c
@@ -121,7 +121,8 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp
return (0);
}
- __wt_errx(session, "session %p: hazard pointer table full", session);
+ __wt_errx(session,
+ "session %p: hazard pointer table full", (void *)session);
#ifdef HAVE_DIAGNOSTIC
__hazard_dump(session);
#endif
@@ -176,7 +177,8 @@ __wt_hazard_clear(WT_SESSION_IMPL *session, WT_PAGE *page)
* because using a page we didn't have pinned down implies corruption.
*/
WT_PANIC_RET(session, EINVAL,
- "session %p: clear hazard pointer: %p: not found", session, page);
+ "session %p: clear hazard pointer: %p: not found",
+ (void *)session, (void *)page);
}
/*
@@ -204,7 +206,8 @@ __wt_hazard_close(WT_SESSION_IMPL *session)
return;
__wt_errx(session,
- "session %p: close hazard pointer table: table not empty", session);
+ "session %p: close hazard pointer table: table not empty",
+ (void *)session);
#ifdef HAVE_DIAGNOSTIC
__hazard_dump(session);
@@ -232,7 +235,7 @@ __wt_hazard_close(WT_SESSION_IMPL *session)
__wt_errx(session,
"session %p: close hazard pointer table: count didn't "
"match entries",
- session);
+ (void *)session);
}
#ifdef HAVE_DIAGNOSTIC
@@ -250,6 +253,7 @@ __hazard_dump(WT_SESSION_IMPL *session)
if (hp->page != NULL)
__wt_errx(session,
"session %p: hazard pointer %p: %s, line %d",
- session, hp->page, hp->file, hp->line);
+ (void *)session,
+ (void *)hp->page, hp->file, hp->line);
}
#endif
diff --git a/src/support/huffman.c b/src/support/huffman.c
index 1e1aaeab5b5..3f35f301935 100644
--- a/src/support/huffman.c
+++ b/src/support/huffman.c
@@ -230,19 +230,19 @@ set_codes(WT_FREQTREE_NODE *node,
* lower-order bits for consecutive numbering.
*/
if (len < MAX_CODE_LENGTH &&
- ((half = 1 << (remaining - 1)) < node->left->weight ||
- half < node->right->weight)) {
- pattern = pattern << remaining;
+ ((half = (uint16_t)(1 << (remaining - 1))) <
+ node->left->weight || half < node->right->weight)) {
+ pattern = (uint16_t)(pattern << remaining);
len = MAX_CODE_LENGTH;
}
if (len < MAX_CODE_LENGTH) {
- patternleft = (pattern << 1) | 0;
- patternright = (pattern << 1) | 1;
+ patternleft = (uint16_t)((pattern << 1) | 0);
+ patternright = (uint16_t)((pattern << 1) | 1);
len++;
} else { /* "low bit mode" */
patternleft = pattern;
- patternright = pattern + node->left->weight;
+ patternright = (uint16_t)(pattern + node->left->weight);
/* len unchanged */
}
@@ -284,12 +284,12 @@ make_table(WT_SESSION_IMPL *session, uint8_t *code2symbol,
* than necessary, we allocate (2 ^ max-code-length) of them.
*/
c = codes[i].pattern;
- shift = max_depth - len;
+ shift = (uint8_t)(max_depth - len);
c1 = (uint32_t)c << shift;
c2 = (uint32_t)(c + 1) << shift;
for (j = c1; j < c2; j++) {
WT_ASSERT(session, code2symbol[j] == 0);
- code2symbol[j] = i;
+ code2symbol[j] = (uint8_t)i;
}
}
}
@@ -694,7 +694,7 @@ __wt_huffman_encode(WT_SESSION_IMPL *session, void *huffman_arg,
* used in the last byte, unless they're 0, in which case there are 8
* bits used in the last byte.
*/
- padding_info = (bitpos % 8) << (8 - WT_HUFFMAN_HEADER);
+ padding_info = (uint8_t)((bitpos % 8) << (8 - WT_HUFFMAN_HEADER));
((uint8_t *)tmp->mem)[0] |= padding_info;
/* Copy result of exact known size into caller's buffer. */
@@ -808,8 +808,9 @@ __wt_huffman_decode(WT_SESSION_IMPL *session, void *huffman_arg,
valid += 8;
from_bytes--;
}
- pattern = valid >= max ? /* short patterns near end */
- (bits >> (valid - max)) : (bits << (max - valid));
+ pattern = (uint16_t)
+ (valid >= max ? /* short patterns near end */
+ (bits >> (valid - max)) : (bits << (max - valid)));
symbol = huffman->code2symbol[pattern & mask];
len = huffman->codes[symbol].length;
valid -= len;
diff --git a/src/txn/txn.c b/src/txn/txn.c
index a2ae97fbd20..d48bb65dea8 100644
--- a/src/txn/txn.c
+++ b/src/txn/txn.c
@@ -343,6 +343,7 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, bool force)
if (WT_TXNID_LT(txn_global->last_running, last_running)) {
txn_global->last_running = last_running;
+#ifdef HAVE_VERBOSE
/* Output a verbose message about long-running transactions,
* but only when some progress is being made. */
if (WT_VERBOSE_ISSET(session, WT_VERB_TRANSACTION) &&
@@ -355,6 +356,7 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, bool force)
oldest_session->lastop,
oldest_session->txn.snap_min));
}
+#endif
}
done: WT_TRET(__wt_writeunlock(session, txn_global->scan_rwlock));
diff --git a/src/txn/txn_log.c b/src/txn/txn_log.c
index da2670fb344..470515244f3 100644
--- a/src/txn/txn_log.c
+++ b/src/txn/txn_log.c
@@ -156,6 +156,7 @@ err: __wt_logrec_free(session, &logrec);
int
__wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
{
+ WT_DECL_RET;
WT_ITEM *logrec;
WT_TXN *txn;
WT_TXN_OP *op;
@@ -179,24 +180,25 @@ __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt)
switch (op->type) {
case WT_TXN_OP_BASIC:
- return (__txn_op_log(session, logrec, op, cbt));
+ ret = __txn_op_log(session, logrec, op, cbt);
+ break;
case WT_TXN_OP_INMEM:
case WT_TXN_OP_REF:
/* Nothing to log, we're done. */
- return (0);
+ break;
case WT_TXN_OP_TRUNCATE_COL:
- return (__wt_logop_col_truncate_pack(session, logrec,
+ ret = __wt_logop_col_truncate_pack(session, logrec,
op->fileid,
- op->u.truncate_col.start, op->u.truncate_col.stop));
+ op->u.truncate_col.start, op->u.truncate_col.stop);
+ break;
case WT_TXN_OP_TRUNCATE_ROW:
- return (__wt_logop_row_truncate_pack(session, txn->logrec,
+ ret = __wt_logop_row_truncate_pack(session, txn->logrec,
op->fileid,
&op->u.truncate_row.start, &op->u.truncate_row.stop,
- (uint32_t)op->u.truncate_row.mode));
- WT_ILLEGAL_VALUE(session);
+ (uint32_t)op->u.truncate_row.mode);
+ break;
}
-
- /* NOTREACHED */
+ return (ret);
}
/*
diff --git a/test/bloom/test_bloom.c b/test/bloom/test_bloom.c
index e9980cd53cb..9a7584f951f 100644
--- a/test/bloom/test_bloom.c
+++ b/test/bloom/test_bloom.c
@@ -50,7 +50,8 @@ void cleanup(void);
void populate_entries(void);
void run(void);
void setup(void);
-void usage(void);
+void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
extern char *__wt_optarg;
extern int __wt_optind;
diff --git a/test/checkpoint/test_checkpoint.c b/test/checkpoint/test_checkpoint.c
index 307cfd914bd..6293d36f916 100644
--- a/test/checkpoint/test_checkpoint.c
+++ b/test/checkpoint/test_checkpoint.c
@@ -32,7 +32,8 @@ GLOBAL g;
static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
-static void onint(int);
+static void onint(int)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static int cleanup(void);
static int usage(void);
static int wt_connect(const char *);
diff --git a/test/csuite/wt2246_col_append/main.c b/test/csuite/wt2246_col_append/main.c
index 3ac96677ed0..798970cbb6d 100644
--- a/test/csuite/wt2246_col_append/main.c
+++ b/test/csuite/wt2246_col_append/main.c
@@ -45,7 +45,7 @@
void (*custom_die)(void) = NULL;
/* Needs to be global for signal handling. */
-TEST_OPTS *opts, _opts;
+static TEST_OPTS *opts, _opts;
static void
page_init(uint64_t n)
diff --git a/test/cursor_order/cursor_order.c b/test/cursor_order/cursor_order.c
index d8cfc0c1421..aa351e6fea8 100644
--- a/test/cursor_order/cursor_order.c
+++ b/test/cursor_order/cursor_order.c
@@ -34,7 +34,8 @@ static FILE *logfp; /* Log file */
static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
-static void onint(int);
+static void onint(int)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void shutdown(void);
static int usage(void);
static void wt_connect(SHARED_CONFIG *, char *);
diff --git a/test/fops/t.c b/test/fops/t.c
index 24994404c7c..bf0588d5a53 100644
--- a/test/fops/t.c
+++ b/test/fops/t.c
@@ -41,7 +41,8 @@ static char home[512];
static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
-static void onint(int);
+static void onint(int)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void shutdown(void);
static int usage(void);
static void wt_startup(char *);
diff --git a/test/format/format.h b/test/format/format.h
index 8fd9b113311..ad5f408ac30 100644
--- a/test/format/format.h
+++ b/test/format/format.h
@@ -33,12 +33,6 @@
#include <db.h>
#endif
-#if defined(__GNUC__)
-#define WT_GCC_ATTRIBUTE(x) __attribute__(x)
-#else
-#define WT_GCC_ATTRIBUTE(x)
-#endif
-
#define EXTPATH "../../ext/" /* Extensions path */
#define LZ4_PATH \
@@ -266,7 +260,7 @@ typedef struct {
#define TINFO_COMPLETE 2 /* Finished */
#define TINFO_JOINED 3 /* Resolved */
volatile int state; /* state */
-} TINFO WT_GCC_ATTRIBUTE((aligned(WT_CACHE_LINE_ALIGNMENT)));
+} TINFO WT_COMPILER_TYPE_ALIGN(WT_CACHE_LINE_ALIGNMENT);
#ifdef HAVE_BERKELEY_DB
void bdb_close(void);
diff --git a/test/format/t.c b/test/format/t.c
index 085163befe2..2eb2b078804 100644
--- a/test/format/t.c
+++ b/test/format/t.c
@@ -32,7 +32,8 @@ GLOBAL g;
static void format_die(void);
static void startup(void);
-static void usage(void);
+static void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
extern int __wt_optind;
extern char *__wt_optarg;
diff --git a/test/format/wts.c b/test/format/wts.c
index 2ee01aa75b5..69195abc3d4 100644
--- a/test/format/wts.c
+++ b/test/format/wts.c
@@ -87,10 +87,10 @@ handle_message(WT_EVENT_HANDLER *handler,
/* Write and flush the message so we're up-to-date on error. */
if (g.logfp == NULL) {
- out = printf("%p:%s\n", session, message);
+ out = printf("%p:%s\n", (void *)session, message);
(void)fflush(stdout);
} else {
- out = fprintf(g.logfp, "%p:%s\n", session, message);
+ out = fprintf(g.logfp, "%p:%s\n", (void *)session, message);
(void)fflush(g.logfp);
}
return (out < 0 ? EIO : 0);
diff --git a/test/huge/huge.c b/test/huge/huge.c
index 1e104a705f2..3aa61a9048e 100644
--- a/test/huge/huge.c
+++ b/test/huge/huge.c
@@ -65,13 +65,13 @@ static size_t lengths[] = {
0
};
+static void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
usage(void)
{
fprintf(stderr, "usage: %s [-s]\n", progname);
- fprintf(stderr, "%s",
- "\t-s small run, only test up to 1GB\n");
-
+ fprintf(stderr, "%s", "\t-s small run, only test up to 1GB\n");
exit(EXIT_FAILURE);
}
diff --git a/test/manydbs/manydbs.c b/test/manydbs/manydbs.c
index d9639198c34..e485e73067f 100644
--- a/test/manydbs/manydbs.c
+++ b/test/manydbs/manydbs.c
@@ -55,6 +55,8 @@ static const char * const uri = "table:main";
#define MAX_KV 100
#define MAX_VAL 128
+static void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
usage(void)
{
@@ -68,10 +70,10 @@ extern char *__wt_optarg;
void (*custom_die)(void) = NULL;
-WT_CONNECTION **connections = NULL;
-WT_CURSOR **cursors = NULL;
-WT_RAND_STATE rnd;
-WT_SESSION **sessions = NULL;
+static WT_CONNECTION **connections = NULL;
+static WT_CURSOR **cursors = NULL;
+static WT_RAND_STATE rnd;
+static WT_SESSION **sessions = NULL;
static int
get_stat(WT_SESSION *stat_session, int stat_field, uint64_t *valuep)
diff --git a/test/readonly/readonly.c b/test/readonly/readonly.c
index 402b99d7d29..31edc0d2a24 100644
--- a/test/readonly/readonly.c
+++ b/test/readonly/readonly.c
@@ -57,6 +57,8 @@ static const char * const uri = "table:main";
#define OP_READ 0
#define OP_WRITE 1
+static void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
usage(void)
{
@@ -119,6 +121,9 @@ run_child(const char *homedir, int op, int expect)
* Child process opens both databases readonly.
*/
static void
+open_dbs(int, const char *, const char *,
+ const char *, const char *) WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
+static void
open_dbs(int op, const char *dir,
const char *dir_wr, const char *dir_rd, const char *dir_rd2)
{
diff --git a/test/recovery/random-abort.c b/test/recovery/random-abort.c
index 33597245966..0d042992223 100644
--- a/test/recovery/random-abort.c
+++ b/test/recovery/random-abort.c
@@ -43,6 +43,8 @@ static const char * const uri = "table:main";
#define ENV_CONFIG_REC "log=(recover=on)"
#define MAX_VAL 4096
+static void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
usage(void)
{
@@ -54,6 +56,8 @@ usage(void)
* Child process creates the database and table, and then writes data into
* the table until it is killed by the parent.
*/
+static void fill_db(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
fill_db(void)
{
diff --git a/test/recovery/truncated-log.c b/test/recovery/truncated-log.c
index 3b99ea2c932..a7509c27566 100644
--- a/test/recovery/truncated-log.c
+++ b/test/recovery/truncated-log.c
@@ -50,6 +50,8 @@ static const char * const uri = "table:main";
#define K_SIZE 16
#define V_SIZE 256
+static void usage(void)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
usage(void)
{
@@ -61,6 +63,7 @@ usage(void)
* Child process creates the database and table, and then writes data into
* the table until it is killed by the parent.
*/
+static void fill_db(void)WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void
fill_db(void)
{
diff --git a/test/thread/t.c b/test/thread/t.c
index 22334076ee1..5b53532e8a6 100644
--- a/test/thread/t.c
+++ b/test/thread/t.c
@@ -42,7 +42,8 @@ static FILE *logfp; /* Log file */
static int handle_error(WT_EVENT_HANDLER *, WT_SESSION *, int, const char *);
static int handle_message(WT_EVENT_HANDLER *, WT_SESSION *, const char *);
-static void onint(int);
+static void onint(int)
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
static void shutdown(void);
static int usage(void);
static void wt_connect(char *);
diff --git a/test/utility/test_util.h b/test/utility/test_util.h
index 6417c5a326b..66ff8de2d19 100644
--- a/test/utility/test_util.h
+++ b/test/utility/test_util.h
@@ -109,10 +109,7 @@ typedef struct {
extern void (*custom_die)(void);
void testutil_die(int, const char *, ...)
-#if defined(__GNUC__)
-__attribute__((__noreturn__))
-#endif
-;
+ WT_GCC_FUNC_DECL_ATTRIBUTE((noreturn));
void *dcalloc(size_t, size_t);
void *dmalloc(size_t);