diff --git a/include/jemalloc/jemalloc_protos.h.in b/include/jemalloc/jemalloc_protos.h.in index 3e1d3223..e474930f 100644 --- a/include/jemalloc/jemalloc_protos.h.in +++ b/include/jemalloc/jemalloc_protos.h.in @@ -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); diff --git a/scripts/run_static_analysis.sh b/scripts/run_static_analysis.sh index 70c813d1..e2185ec9 100755 --- a/scripts/run_static_analysis.sh +++ b/scripts/run_static_analysis.sh @@ -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 \ diff --git a/src/ctl.c b/src/ctl.c index 454766da..2607aed2 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -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, \ diff --git a/src/inspect.c b/src/inspect.c index 911b5d52..2575b5c1 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -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, diff --git a/src/jemalloc.c b/src/jemalloc.c index c5a06f6e..e2b4917f 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -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; diff --git a/src/jemalloc_cpp.cpp b/src/jemalloc_cpp.cpp index 44569c14..08107a8a 100644 --- a/src/jemalloc_cpp.cpp +++ b/src/jemalloc_cpp.cpp @@ -2,7 +2,6 @@ #include // NOLINTBEGIN(misc-use-anonymous-namespace) -#define JEMALLOC_CPP_CPP_ #ifdef __cplusplus extern "C" { #endif diff --git a/src/mutex.c b/src/mutex.c index 0b3547a8..5655100d 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -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 diff --git a/src/pa.c b/src/pa.c index 63eef2b5..ebc6861d 100644 --- a/src/pa.c +++ b/src/pa.c @@ -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) { diff --git a/src/pages.c b/src/pages.c index 58d9cfaf..8cf2fd9f 100644 --- a/src/pages.c +++ b/src/pages.c @@ -21,7 +21,7 @@ #else #define PAGES_FD_TAG -1 #endif -#ifdef JEMALLOC_HAVE_PRCTL +#if defined(JEMALLOC_HAVE_PRCTL) && defined(JEMALLOC_PAGEID) #include #ifndef PR_SET_VMA #define PR_SET_VMA 0x53564d41 diff --git a/src/prof_sys.c b/src/prof_sys.c index dbb4c80a..c2998926 100644 --- a/src/prof_sys.c +++ b/src/prof_sys.c @@ -1,4 +1,3 @@ -#define JEMALLOC_PROF_SYS_C_ #include "jemalloc/internal/jemalloc_preamble.h" #include "jemalloc/internal/jemalloc_internal_includes.h" diff --git a/test/src/mtx.c b/test/src/mtx.c index d9ce375c..6cb3ecd5 100644 --- a/test/src/mtx.c +++ b/test/src/mtx.c @@ -1,6 +1,6 @@ #include "test/jemalloc_test.h" -#ifndef _CRT_SPINCOUNT +#if defined(_WIN32) && !defined(_CRT_SPINCOUNT) #define _CRT_SPINCOUNT 4000 #endif