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)
|
if (usize <= arena_maxclass && alignment <= PAGE_SIZE)
|
||||||
ret = arena_malloc(usize, zero);
|
ret = arena_malloc(usize, zero);
|
||||||
else {
|
else {
|
||||||
size_t run_size
|
size_t run_size JEMALLOC_CC_SILENCE_INIT(0);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= 0
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ideally we would only ever call sa2u() once per aligned
|
* Ideally we would only ever call sa2u() once per aligned
|
||||||
|
@ -16,6 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
#define JEMALLOC_CONCAT(...) __VA_ARGS__
|
#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
|
* Define a custom assert() in order to reduce the chances of deadlock during
|
||||||
* assertion failure.
|
* assertion failure.
|
||||||
|
@ -751,11 +751,7 @@ je_malloc(size_t size)
|
|||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
size_t usize;
|
size_t usize;
|
||||||
prof_thr_cnt_t *cnt
|
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
if (malloc_init()) {
|
if (malloc_init()) {
|
||||||
ret = NULL;
|
ret = NULL;
|
||||||
@ -818,11 +814,7 @@ imemalign(void **memptr, size_t alignment, size_t size,
|
|||||||
int ret;
|
int ret;
|
||||||
size_t usize;
|
size_t usize;
|
||||||
void *result;
|
void *result;
|
||||||
prof_thr_cnt_t *cnt
|
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
assert(min_alignment != 0);
|
assert(min_alignment != 0);
|
||||||
|
|
||||||
@ -932,11 +924,7 @@ je_calloc(size_t num, size_t size)
|
|||||||
void *ret;
|
void *ret;
|
||||||
size_t num_size;
|
size_t num_size;
|
||||||
size_t usize;
|
size_t usize;
|
||||||
prof_thr_cnt_t *cnt
|
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
if (malloc_init()) {
|
if (malloc_init()) {
|
||||||
num_size = 0;
|
num_size = 0;
|
||||||
@ -1010,16 +998,8 @@ je_realloc(void *ptr, size_t size)
|
|||||||
void *ret;
|
void *ret;
|
||||||
size_t usize;
|
size_t usize;
|
||||||
size_t old_size = 0;
|
size_t old_size = 0;
|
||||||
prof_thr_cnt_t *cnt
|
prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
prof_ctx_t *old_ctx JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
prof_ctx_t *old_ctx
|
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
@ -1173,11 +1153,7 @@ JEMALLOC_ATTR(visibility("default"))
|
|||||||
void *
|
void *
|
||||||
je_memalign(size_t alignment, size_t size)
|
je_memalign(size_t alignment, size_t size)
|
||||||
{
|
{
|
||||||
void *ret
|
void *ret JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
imemalign(&ret, alignment, size, 1);
|
imemalign(&ret, alignment, size, 1);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
@ -1189,11 +1165,7 @@ JEMALLOC_ATTR(visibility("default"))
|
|||||||
void *
|
void *
|
||||||
je_valloc(size_t size)
|
je_valloc(size_t size)
|
||||||
{
|
{
|
||||||
void *ret
|
void *ret JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||||
#ifdef JEMALLOC_CC_SILENCE
|
|
||||||
= NULL
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
imemalign(&ret, PAGE_SIZE, size, 1);
|
imemalign(&ret, PAGE_SIZE, size, 1);
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
|||||||
char *s;
|
char *s;
|
||||||
size_t slen;
|
size_t slen;
|
||||||
case 'd': case 'i': {
|
case 'd': case 'i': {
|
||||||
intmax_t val;
|
intmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||||
char buf[D2S_BUFSIZE];
|
char buf[D2S_BUFSIZE];
|
||||||
|
|
||||||
GET_ARG_NUMERIC(val, len);
|
GET_ARG_NUMERIC(val, len);
|
||||||
@ -363,7 +363,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
|||||||
f++;
|
f++;
|
||||||
break;
|
break;
|
||||||
} case 'o': {
|
} case 'o': {
|
||||||
uintmax_t val;
|
uintmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||||
char buf[O2S_BUFSIZE];
|
char buf[O2S_BUFSIZE];
|
||||||
|
|
||||||
GET_ARG_NUMERIC(val, len);
|
GET_ARG_NUMERIC(val, len);
|
||||||
@ -372,7 +372,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
|||||||
f++;
|
f++;
|
||||||
break;
|
break;
|
||||||
} case 'u': {
|
} case 'u': {
|
||||||
uintmax_t val;
|
uintmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||||
char buf[U2S_BUFSIZE];
|
char buf[U2S_BUFSIZE];
|
||||||
|
|
||||||
GET_ARG_NUMERIC(val, len);
|
GET_ARG_NUMERIC(val, len);
|
||||||
@ -381,7 +381,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
|||||||
f++;
|
f++;
|
||||||
break;
|
break;
|
||||||
} case 'x': case 'X': {
|
} case 'x': case 'X': {
|
||||||
uintmax_t val;
|
uintmax_t val JEMALLOC_CC_SILENCE_INIT(0);
|
||||||
char buf[X2S_BUFSIZE];
|
char buf[X2S_BUFSIZE];
|
||||||
|
|
||||||
GET_ARG_NUMERIC(val, len);
|
GET_ARG_NUMERIC(val, len);
|
||||||
|
Loading…
Reference in New Issue
Block a user