summaryrefslogtreecommitdiff
path: root/src/support
diff options
context:
space:
mode:
authorAlex Gorrod <alexander.gorrod@mongodb.com>2017-07-07 00:01:20 +1000
committerKeith Bostic <keith.bostic@mongodb.com>2017-07-06 10:01:20 -0400
commit344eca1d9e937e8215817cfc804d2a6e80266943 (patch)
tree26b840a8effc2fd14faebb93a99d22e8bb4a269f /src/support
parent502d4cc5f4d7a41ccd5306f33e60aa6a451fe6e6 (diff)
downloadmongo-344eca1d9e937e8215817cfc804d2a6e80266943.tar.gz
WT-3394 Fix compilation warnings for GCC-7 (#3499)
* WT-3394 Build WiredTiger with gcc7 Simplify wtperf loops to not check both the thread pointer and the count, it makes gcc7's testing for unsafe loops sad. It shouldn't be necessary, the count being non-zero indicates the thread pointers are non-NULL. * Turn off "-Wunsafe-loop-optimizations" for gcc7, it fires all over the place where the loops are just fine. * Rewrite a loop to turn off gcc7's -Wunsafe-loop-optimizations warning. * Gcc7's -Wunsafe-loop-optimizations warning was correct: byte and stopbyte are unsigned, which means the loop could be infinite. Rewrite the loops to check for equality after the last possible byte value. This is safe because nbits must be non-zero and byte must initially be less than stopbyte. Add explicit gcc fallthrough attributes, gcc7's -Wimplicit-fallthrough complaints aren't turned off by /* FALLTHROUGH */ comments that appear in macros. * Add explicit gcc fallthrough attributes, gcc7's -Wimplicit-fallthrough complaints aren't turned off by /* FALLTHROUGH */ comments that appear in macros. * Add a new gcc attribute macro, gcc7's -Wimplicit-fallthrough complaints aren't turned off by /* FALLTHROUGH */ comments that appear in macros, we have to add gcc attributes to turn those warnings off. * Don't hardcode the size of the buffer in the integer-packing test. Use a testutil assertion so a test failure results in a non-zero exit status. * whitespace. * opts->table_count is a uint32_t, switch from PRId32 to PRIu32. * workp->throttle is a uin64_t, switch from PRId64 to PRIu64. * Enums are integers, but the signedness is implementation-dependent. * min_version/maj_version are int64_t's, switch PRIu64 to PRId64. * adjustment is a uint64_t, switch from PRId64 to PRIu64. * Fields slot->slot_state and slot->slot_unbuffered are int64_t's. When printing them as a hex value, cast to (uint64_t), otherwise, use PRId64, not PRIu64. * ckpt->order is an int64_t, switch from PRIu64 to PRId64. * WT_MIN of a uint32_t value has to be cast before being used as an int. * Don't bother declaring uint64_t arguments as 0ULL, we have a prototype in the file and gcc 7.0 complains about the use of "long long". * WT_EXTRA_INTERNAL_SESSIONS is type int, switch from PRI732 to %d. * optype is a uint32_t, switch from %d to PRIu32. * When printing wt_off_t's, use uintmax_t, not intmax_t. * id is a u_int, switch from %d to %u. * g.run_cnt is a uint32_t, switch from %d to PRIu32. * singput/soutput are int64_t's, switch from PRIu64 to PRId64. When printing hex values, cast to unsigned char. * id is unsigned, switch from %d to %u. * gcc wasn't inlining __wt_verbose(), which is bad because that's a function call to no purpose in most production environments. (The problem is gcc won't inline any function with variadic argument handling.) Break __wt_verbose() into two parts, the flag test as a macro and a call to a real function that handles the variadic argument part of the problem. One change: this requires calls to __wt_verbose() include a format argument plus at least one other argument, that is, you can't do: __wt_verbose(session, WT_VERB_LOOKASIDE, "my message"); you have to instead do: __wt_verbose(session, WT_VERB_LOOKASIDE, "%s", "my message"); * Update spell checker and auto-generated files. * Add support for gcc7, including a number of additional compiler warning flags. Remove -Wmissing-parameter-type (implied by -Wextra), and -Wmisleading-indentation (implied by -Wall). * Make configurations without HAVE_VERBOSE build cleanly again. * I can't figure out a way to make __attribute__((fallthrough)) work for gcc 7.X as well as earlier gcc compiler releases without a whole bunch of C preprocessor magic. Explode the macros so we don't need it anymore. * Add additional warning flags to gcc6 where supported. * I broke bitstring.i when I changed the ffs/ffc loops. * gcc7 thinks buffer can be used uninitialized, but I can't find any place where that's true. Explicitly initialize the buffer to clear the warning. * Use WT_INTPACK64_MAXSIZE instead of hard-coding the maximum buffer size. * Add a comment to explain why __wt_verbose() has to take a format string and at least one additional argument. Add comments to explain why we replaced expanded some #define's in switch statements. * Fix Windows compile failure: src\os_win\os_map.c(78) : error C4100: 'length' : unreferenced formal parameter * Revert "WT-3394 Build WiredTiger with gcc7" This reverts commit aebd86717952e409e28468bab03b8663bea612d3.
Diffstat (limited to 'src/support')
-rw-r--r--src/support/err.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/support/err.c b/src/support/err.c
index a62a9895684..94ae27628c2 100644
--- a/src/support/err.c
+++ b/src/support/err.c
@@ -361,6 +361,22 @@ __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.
*/