Remove dead stores detected by static analysis
None of these are harmful, and they are almost certainly optimized away by the compiler. The motivation for fixing them anyway is that we'd like to enable static analysis as part of CI, and the first step towards that is resolving the warnings it produces at present.
This commit is contained in:
parent
0288126d9c
commit
3e2ba7a651
@ -96,8 +96,7 @@ log_impl_varargs(const char *name, ...) {
|
|||||||
dst_offset += malloc_snprintf(buf, JEMALLOC_LOG_BUFSIZE, "%s: ", name);
|
dst_offset += malloc_snprintf(buf, JEMALLOC_LOG_BUFSIZE, "%s: ", name);
|
||||||
dst_offset += malloc_vsnprintf(buf + dst_offset,
|
dst_offset += malloc_vsnprintf(buf + dst_offset,
|
||||||
JEMALLOC_LOG_BUFSIZE - dst_offset, format, ap);
|
JEMALLOC_LOG_BUFSIZE - dst_offset, format, ap);
|
||||||
dst_offset += malloc_snprintf(buf + dst_offset,
|
malloc_snprintf(buf + dst_offset, JEMALLOC_LOG_BUFSIZE - dst_offset, "\n");
|
||||||
JEMALLOC_LOG_BUFSIZE - dst_offset, "\n");
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
malloc_write(buf);
|
malloc_write(buf);
|
||||||
|
@ -2745,7 +2745,6 @@ arena_i_dss_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
int ret;
|
int ret;
|
||||||
const char *dss = NULL;
|
const char *dss = NULL;
|
||||||
unsigned arena_ind;
|
unsigned arena_ind;
|
||||||
dss_prec_t dss_prec_old = dss_prec_limit;
|
|
||||||
dss_prec_t dss_prec = dss_prec_limit;
|
dss_prec_t dss_prec = dss_prec_limit;
|
||||||
|
|
||||||
malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx);
|
malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx);
|
||||||
@ -2773,6 +2772,7 @@ arena_i_dss_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
* Access via index narenas is deprecated, and scheduled for removal in
|
* Access via index narenas is deprecated, and scheduled for removal in
|
||||||
* 6.0.0.
|
* 6.0.0.
|
||||||
*/
|
*/
|
||||||
|
dss_prec_t dss_prec_old;
|
||||||
if (arena_ind == MALLCTL_ARENAS_ALL || arena_ind ==
|
if (arena_ind == MALLCTL_ARENAS_ALL || arena_ind ==
|
||||||
ctl_arenas->narenas) {
|
ctl_arenas->narenas) {
|
||||||
if (dss_prec != dss_prec_limit &&
|
if (dss_prec != dss_prec_limit &&
|
||||||
|
@ -2389,7 +2389,6 @@ imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
|
|||||||
* from the ind_large bucket.
|
* from the ind_large bucket.
|
||||||
*/
|
*/
|
||||||
szind_t ind_large;
|
szind_t ind_large;
|
||||||
size_t bumped_usize = usize;
|
|
||||||
|
|
||||||
dopts->alignment = prof_sample_align(dopts->alignment);
|
dopts->alignment = prof_sample_align(dopts->alignment);
|
||||||
if (usize <= SC_SMALL_MAXCLASS) {
|
if (usize <= SC_SMALL_MAXCLASS) {
|
||||||
@ -2398,7 +2397,7 @@ imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
|
|||||||
sz_sa2u(SC_LARGE_MINCLASS, dopts->alignment))
|
sz_sa2u(SC_LARGE_MINCLASS, dopts->alignment))
|
||||||
== SC_LARGE_MINCLASS);
|
== SC_LARGE_MINCLASS);
|
||||||
ind_large = sz_size2index(SC_LARGE_MINCLASS);
|
ind_large = sz_size2index(SC_LARGE_MINCLASS);
|
||||||
bumped_usize = sz_s2u(SC_LARGE_MINCLASS);
|
size_t bumped_usize = sz_s2u(SC_LARGE_MINCLASS);
|
||||||
ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize,
|
ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize,
|
||||||
bumped_usize, ind_large);
|
bumped_usize, ind_large);
|
||||||
if (unlikely(ret == NULL)) {
|
if (unlikely(ret == NULL)) {
|
||||||
|
@ -423,7 +423,6 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
|||||||
unsigned char len = '?';
|
unsigned char len = '?';
|
||||||
char *s;
|
char *s;
|
||||||
size_t slen;
|
size_t slen;
|
||||||
bool first_width_digit = true;
|
|
||||||
bool pad_zero = false;
|
bool pad_zero = false;
|
||||||
|
|
||||||
f++;
|
f++;
|
||||||
@ -462,9 +461,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
if (first_width_digit) {
|
|
||||||
pad_zero = true;
|
pad_zero = true;
|
||||||
}
|
|
||||||
JEMALLOC_FALLTHROUGH;
|
JEMALLOC_FALLTHROUGH;
|
||||||
case '1': case '2': case '3': case '4':
|
case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9': {
|
case '5': case '6': case '7': case '8': case '9': {
|
||||||
@ -474,7 +471,6 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
|||||||
assert(uwidth != UINTMAX_MAX || get_errno() !=
|
assert(uwidth != UINTMAX_MAX || get_errno() !=
|
||||||
ERANGE);
|
ERANGE);
|
||||||
width = (int)uwidth;
|
width = (int)uwidth;
|
||||||
first_width_digit = false;
|
|
||||||
break;
|
break;
|
||||||
} default:
|
} default:
|
||||||
break;
|
break;
|
||||||
|
@ -68,7 +68,6 @@ static int madvise_dont_need_zeros_is_faulty = -1;
|
|||||||
*/
|
*/
|
||||||
static int madvise_MADV_DONTNEED_zeroes_pages()
|
static int madvise_MADV_DONTNEED_zeroes_pages()
|
||||||
{
|
{
|
||||||
int works = -1;
|
|
||||||
size_t size = PAGE;
|
size_t size = PAGE;
|
||||||
|
|
||||||
void * addr = mmap(NULL, size, PROT_READ|PROT_WRITE,
|
void * addr = mmap(NULL, size, PROT_READ|PROT_WRITE,
|
||||||
@ -83,6 +82,7 @@ static int madvise_MADV_DONTNEED_zeroes_pages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(addr, 'A', size);
|
memset(addr, 'A', size);
|
||||||
|
int works;
|
||||||
if (madvise(addr, size, MADV_DONTNEED) == 0) {
|
if (madvise(addr, size, MADV_DONTNEED) == 0) {
|
||||||
works = memchr(addr, 'A', size) == NULL;
|
works = memchr(addr, 'A', size) == NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1803,7 +1803,7 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
VARIABLE_ARRAY(bool, initialized, narenas);
|
VARIABLE_ARRAY(bool, initialized, narenas);
|
||||||
bool destroyed_initialized;
|
bool destroyed_initialized;
|
||||||
unsigned i, j, ninitialized;
|
unsigned i, ninitialized;
|
||||||
|
|
||||||
xmallctlnametomib("arena.0.initialized", mib, &miblen);
|
xmallctlnametomib("arena.0.initialized", mib, &miblen);
|
||||||
for (i = ninitialized = 0; i < narenas; i++) {
|
for (i = ninitialized = 0; i < narenas; i++) {
|
||||||
@ -1843,7 +1843,7 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
|
|||||||
|
|
||||||
/* Unmerged stats. */
|
/* Unmerged stats. */
|
||||||
if (unmerged) {
|
if (unmerged) {
|
||||||
for (i = j = 0; i < narenas; i++) {
|
for (i = 0; i < narenas; i++) {
|
||||||
if (initialized[i]) {
|
if (initialized[i]) {
|
||||||
char arena_ind_str[20];
|
char arena_ind_str[20];
|
||||||
malloc_snprintf(arena_ind_str,
|
malloc_snprintf(arena_ind_str,
|
||||||
|
Loading…
Reference in New Issue
Block a user