Add JEMALLOC_CC_SILENCE_INIT().
Add JEMALLOC_CC_SILENCE_INIT(), which provides succinct syntax for initializing a variable to avoid a spurious compiler warning.
This commit is contained in:
parent
cd9a1346e9
commit
9225a1991a
@ -611,11 +611,7 @@ ipalloc(size_t usize, size_t alignment, bool zero)
|
||||
if (usize <= arena_maxclass && alignment <= PAGE_SIZE)
|
||||
ret = arena_malloc(usize, zero);
|
||||
else {
|
||||
size_t run_size
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= 0
|
||||
#endif
|
||||
;
|
||||
size_t run_size JEMALLOC_CC_SILENCE_INIT(0);
|
||||
|
||||
/*
|
||||
* Ideally we would only ever call sa2u() once per aligned
|
||||
|
@ -16,6 +16,17 @@
|
||||
*/
|
||||
#define JEMALLOC_CONCAT(...) __VA_ARGS__
|
||||
|
||||
/*
|
||||
* Silence compiler warnings due to uninitialized values. This is used
|
||||
* wherever the compiler fails to recognize that the variable is never used
|
||||
* uninitialized.
|
||||
*/
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
# define JEMALLOC_CC_SILENCE_INIT(v) = v
|
||||
#else
|
||||
# define JEMALLOC_CC_SILENCE_INIT(v)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define a custom assert() in order to reduce the chances of deadlock during
|
||||
* assertion failure.
|
||||
|
@ -751,11 +751,7 @@ je_malloc(size_t size)
|
||||
{
|
||||
void *ret;
|
||||
size_t usize;
|
||||
prof_thr_cnt_t *cnt
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
|
||||
if (malloc_init()) {
|
||||
ret = NULL;
|
||||
@ -818,11 +814,7 @@ imemalign(void **memptr, size_t alignment, size_t size,
|
||||
int ret;
|
||||
size_t usize;
|
||||
void *result;
|
||||
prof_thr_cnt_t *cnt
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
|
||||
assert(min_alignment != 0);
|
||||
|
||||
@ -932,11 +924,7 @@ je_calloc(size_t num, size_t size)
|
||||
void *ret;
|
||||
size_t num_size;
|
||||
size_t usize;
|
||||
prof_thr_cnt_t *cnt
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
|
||||
if (malloc_init()) {
|
||||
num_size = 0;
|
||||
@ -1010,16 +998,8 @@ je_realloc(void *ptr, size_t size)
|
||||
void *ret;
|
||||
size_t usize;
|
||||
size_t old_size = 0;
|
||||
prof_thr_cnt_t *cnt
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
prof_ctx_t *old_ctx
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
prof_ctx_t *old_ctx JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
|
||||
if (size == 0) {
|
||||
if (ptr != NULL) {
|
||||
@ -1173,11 +1153,7 @@ JEMALLOC_ATTR(visibility("default"))
|
||||
void *
|
||||
je_memalign(size_t alignment, size_t size)
|
||||
{
|
||||
void *ret
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
void *ret JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
imemalign(&ret, alignment, size, 1);
|
||||
return (ret);
|
||||
}
|
||||
@ -1189,11 +1165,7 @@ JEMALLOC_ATTR(visibility("default"))
|
||||
void *
|
||||
je_valloc(size_t size)
|
||||
{
|
||||
void *ret
|
||||
#ifdef JEMALLOC_CC_SILENCE
|
||||
= NULL
|
||||
#endif
|
||||
;
|
||||
void *ret JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
imemalign(&ret, PAGE_SIZE, size, 1);
|
||||
return (ret);
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
char *s;
|
||||
size_t slen;
|
||||
case 'd': case 'i': {
|
||||
intmax_t val;
|
||||
intmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||
char buf[D2S_BUFSIZE];
|
||||
|
||||
GET_ARG_NUMERIC(val, len);
|
||||
@ -363,7 +363,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
f++;
|
||||
break;
|
||||
} case 'o': {
|
||||
uintmax_t val;
|
||||
uintmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||
char buf[O2S_BUFSIZE];
|
||||
|
||||
GET_ARG_NUMERIC(val, len);
|
||||
@ -372,7 +372,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
f++;
|
||||
break;
|
||||
} case 'u': {
|
||||
uintmax_t val;
|
||||
uintmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||
char buf[U2S_BUFSIZE];
|
||||
|
||||
GET_ARG_NUMERIC(val, len);
|
||||
@ -381,7 +381,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
f++;
|
||||
break;
|
||||
} case 'x': case 'X': {
|
||||
uintmax_t val;
|
||||
uintmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||
char buf[X2S_BUFSIZE];
|
||||
|
||||
GET_ARG_NUMERIC(val, len);
|
||||
|
Loading…
Reference in New Issue
Block a user