Disable some spuriously-triggering warnings

This commit is contained in:
David Goldblatt 2019-12-04 10:16:44 -08:00 committed by David Goldblatt
parent a70909b130
commit 1b1e76acfe
3 changed files with 22 additions and 2 deletions

View File

@ -250,6 +250,11 @@ if test "x$GCC" = "xyes" ; then
JE_CFLAGS_ADD([-Wsign-compare])
JE_CFLAGS_ADD([-Wundef])
JE_CFLAGS_ADD([-Wno-format-zero-length])
dnl This warning triggers on the use of the universal zero initializer, which
dnl is a very handy idiom for things like the tcache static initializer (which
dnl has lots of nested structs). See the discussion at.
dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
JE_CFLAGS_ADD([-Wno-missing-braces])
JE_CFLAGS_ADD([-pipe])
JE_CFLAGS_ADD([-g3])
elif test "x$je_cv_msvc" = "xyes" ; then

View File

@ -51,7 +51,7 @@ typedef struct tcaches_s tcaches_t;
#define TCACHE_GC_INCR_BYTES 65536U
/* Used in TSD static initializer only. Real init in tsd_tcache_data_init(). */
#define TCACHE_ZERO_INITIALIZER {{0}}
#define TCACHE_ZERO_INITIALIZER {0}
/* Used in TSD static initializer only. Will be initialized to opt_tcache. */
#define TCACHE_ENABLED_ZERO_INITIALIZER false

View File

@ -113,6 +113,21 @@ bool prof_booted = false;
/******************************************************************************/
/*
* If profiling is off, then PROF_DUMP_FILENAME_LEN is 1, so we'll end up
* calling strncpy with a size of 0, which triggers a -Wstringop-truncation
* warning (strncpy can never actually be called in this case, since we bail out
* much earlier when config_prof is false). This function works around the
* warning to let us leave the warning on.
*/
static inline void
prof_strncpy(char *UNUSED dest, const char *UNUSED src, size_t UNUSED size) {
cassert(config_prof);
#ifdef JEMALLOC_PROF
strncpy(dest, src, size);
#endif
}
static bool
prof_tctx_should_destroy(tsdn_t *tsdn, prof_tctx_t *tctx) {
malloc_mutex_assert_owner(tsdn, tctx->tdata->lock);
@ -692,7 +707,7 @@ prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) {
}
assert(prof_dump_prefix != NULL);
strncpy(prof_dump_prefix, prefix, PROF_DUMP_FILENAME_LEN - 1);
prof_strncpy(prof_dump_prefix, prefix, PROF_DUMP_FILENAME_LEN - 1);
prof_dump_prefix[PROF_DUMP_FILENAME_LEN - 1] = '\0';
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);