Enable a few additional warnings for CI and fix the issues they uncovered

- `-Wmissing-prototypes` and `-Wmissing-variable-declarations` are
  helpful for finding dead code and/or things that should be `static`
  but aren't marked as such.
- `-Wunused-macros` is of similar utility, but for identifying dead macros.
- `-Wunreachable-code` and `-Wunreachable-code-aggressive` do exactly
  what they say: flag unreachable code.
This commit is contained in:
Kevin Svetlitski 2023-08-10 16:31:35 -07:00 committed by Qi Wang
parent d2c9ed3d1e
commit da66aa391f
11 changed files with 15 additions and 40 deletions

View File

@ -4,6 +4,7 @@
* JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle@install_suffix@.h).
*/
extern JEMALLOC_EXPORT const char *@je_@malloc_conf;
extern JEMALLOC_EXPORT const char *@je_@malloc_conf_2_conf_harder;
extern JEMALLOC_EXPORT void (*@je_@malloc_message)(void *cbopaque,
const char *s);

View File

@ -12,8 +12,16 @@ compile_time_malloc_conf='background_thread:true,'\
'zero_realloc:free,'\
'prof_unbias:false,'\
'prof_time_resolution:high'
extra_flags=(
-Wmissing-prototypes
-Wmissing-variable-declarations
-Wstrict-prototypes
-Wunreachable-code
-Wunreachable-code-aggressive
-Wunused-macros
)
EXTRA_CFLAGS='-Wstrict-prototypes' EXTRA_CXXFLAGS='-Wstrict-prototypes' ./autogen.sh \
EXTRA_CFLAGS="${extra_flags[*]}" EXTRA_CXXFLAGS="${extra_flags[*]}" ./autogen.sh \
--with-private-namespace=jemalloc_ \
--disable-cache-oblivious \
--enable-prof \

View File

@ -1861,31 +1861,6 @@ ctl_mtx_assert_held(tsdn_t *tsdn) {
* There's a lot of code duplication in the following macros due to limitations
* in how nested cpp macros are expanded.
*/
#define CTL_RO_CLGEN(c, l, n, v, t) \
static int \
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
size_t *oldlenp, void *newp, size_t newlen) { \
int ret; \
t oldval; \
\
if (!(c)) { \
return ENOENT; \
} \
if (l) { \
malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx); \
} \
READONLY(); \
oldval = (v); \
READ(oldval, t); \
\
ret = 0; \
label_return: \
if (l) { \
malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx); \
} \
return ret; \
}
#define CTL_RO_CGEN(c, n, v, t) \
static int \
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, \

View File

@ -1,5 +1,6 @@
#include "jemalloc/internal/jemalloc_preamble.h"
#include "jemalloc/internal/jemalloc_internal_includes.h"
#include "jemalloc/internal/inspect.h"
void
inspect_extent_util_stats_get(tsdn_t *tsdn, const void *ptr, size_t *nfree,

View File

@ -1,4 +1,3 @@
#define JEMALLOC_C_
#include "jemalloc/internal/jemalloc_preamble.h"
#include "jemalloc/internal/jemalloc_internal_includes.h"
@ -151,7 +150,7 @@ bool opt_xmalloc = false;
bool opt_experimental_infallible_new = false;
bool opt_zero = false;
unsigned opt_narenas = 0;
fxp_t opt_narenas_ratio = FXP_INIT_INT(4);
static fxp_t opt_narenas_ratio = FXP_INIT_INT(4);
unsigned ncpus;

View File

@ -2,7 +2,6 @@
#include <new>
// NOLINTBEGIN(misc-use-anonymous-namespace)
#define JEMALLOC_CPP_CPP_
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -5,7 +5,7 @@
#include "jemalloc/internal/malloc_io.h"
#include "jemalloc/internal/spin.h"
#ifndef _CRT_SPINCOUNT
#if defined(_WIN32) && !defined(_CRT_SPINCOUNT)
#define _CRT_SPINCOUNT 4000
#endif

View File

@ -220,13 +220,6 @@ pa_dalloc(tsdn_t *tsdn, pa_shard_t *shard, edata_t *edata,
pai_dalloc(tsdn, pai, edata, deferred_work_generated);
}
bool
pa_shard_retain_grow_limit_get_set(tsdn_t *tsdn, pa_shard_t *shard,
size_t *old_limit, size_t *new_limit) {
return pac_retain_grow_limit_get_set(tsdn, &shard->pac, old_limit,
new_limit);
}
bool
pa_decay_ms_set(tsdn_t *tsdn, pa_shard_t *shard, extent_state_t state,
ssize_t decay_ms, pac_purge_eagerness_t eagerness) {

View File

@ -21,7 +21,7 @@
#else
#define PAGES_FD_TAG -1
#endif
#ifdef JEMALLOC_HAVE_PRCTL
#if defined(JEMALLOC_HAVE_PRCTL) && defined(JEMALLOC_PAGEID)
#include <sys/prctl.h>
#ifndef PR_SET_VMA
#define PR_SET_VMA 0x53564d41

View File

@ -1,4 +1,3 @@
#define JEMALLOC_PROF_SYS_C_
#include "jemalloc/internal/jemalloc_preamble.h"
#include "jemalloc/internal/jemalloc_internal_includes.h"

View File

@ -1,6 +1,6 @@
#include "test/jemalloc_test.h"
#ifndef _CRT_SPINCOUNT
#if defined(_WIN32) && !defined(_CRT_SPINCOUNT)
#define _CRT_SPINCOUNT 4000
#endif