X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Fstore.c;h=b1a47799b2f6fda42383aba192e4e69057f73a13;hb=493e0e6648552c0dce6c5225c8438d2829f1ac11;hp=1d1458d0fade1afa8608e5ea46e157f8f17869b4;hpb=3634fc257bd0667daef14d72005cd87c735bbb24;p=exim.git diff --git a/src/src/store.c b/src/src/store.c index 1d1458d0f..b1a47799b 100644 --- a/src/src/store.c +++ b/src/src/store.c @@ -2,7 +2,7 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2009 */ +/* Copyright (c) University of Cambridge 1995 - 2016 */ /* See the file NOTICE for conditions of use and distribution. */ /* Exim gets and frees all its store through these functions. In the original @@ -39,6 +39,9 @@ The following different types of store are recognized: #include "exim.h" +/* keep config.h before memcheck.h, for NVALGRIND */ +#include "config.h" + #include "memcheck.h" @@ -174,7 +177,7 @@ if (size > yield_length[store_pool]) yield_length[store_pool] = newblock->length; next_yield[store_pool] = (void *)((char *)current_block[store_pool] + ALIGNED_SIZEOF_STOREBLOCK); - VALGRIND_MAKE_MEM_NOACCESS(next_yield[store_pool], yield_length[store_pool]); + (void) VALGRIND_MAKE_MEM_NOACCESS(next_yield[store_pool], yield_length[store_pool]); } /* There's (now) enough room in the current block; the yield is the next @@ -199,7 +202,7 @@ DEBUG(D_memory) } #endif /* COMPILE_UTILITY */ -VALGRIND_MAKE_MEM_UNDEFINED(store_last_get[store_pool], size); +(void) VALGRIND_MAKE_MEM_UNDEFINED(store_last_get[store_pool], size); /* Update next pointer and number of bytes left in the current block. */ next_yield[store_pool] = (void *)((char *)next_yield[store_pool] + size); @@ -294,7 +297,7 @@ DEBUG(D_memory) if (newsize % alignment != 0) newsize += alignment - (newsize % alignment); next_yield[store_pool] = (char *)ptr + newsize; yield_length[store_pool] -= newsize - rounded_oldsize; -VALGRIND_MAKE_MEM_UNDEFINED(ptr + oldsize, inc); +(void) VALGRIND_MAKE_MEM_UNDEFINED(ptr + oldsize, inc); return TRUE; } @@ -342,7 +345,7 @@ if ((char *)ptr < bc || (char *)ptr > bc + b->length) if ((char *)ptr >= bc && (char *)ptr <= bc + b->length) break; } if (b == NULL) - log_write(0, LOG_MAIN|LOG_PANIC_DIE, "internal error: store_reset(%d) " + log_write(0, LOG_MAIN|LOG_PANIC_DIE, "internal error: store_reset(%p) " "failed: pool=%d %-14s %4d", ptr, store_pool, filename, linenumber); } @@ -351,9 +354,13 @@ the released memory. */ newlength = bc + b->length - (char *)ptr; #ifndef COMPILE_UTILITY -if (running_in_test_harness) memset(ptr, 0xF0, newlength); +if (running_in_test_harness) + { + (void) VALGRIND_MAKE_MEM_DEFINED(ptr, newlength); + memset(ptr, 0xF0, newlength); + } #endif -VALGRIND_MAKE_MEM_NOACCESS(ptr, newlength); +(void) VALGRIND_MAKE_MEM_NOACCESS(ptr, newlength); yield_length[store_pool] = newlength - (newlength % alignment); next_yield[store_pool] = (char *)ptr + (newlength % alignment); current_block[store_pool] = b; @@ -367,7 +374,8 @@ if (yield_length[store_pool] < STOREPOOL_MIN_SIZE && b->next->length == STORE_BLOCK_SIZE) { b = b->next; - VALGRIND_MAKE_MEM_NOACCESS((char *)b + ALIGNED_SIZEOF_STOREBLOCK, b->length - ALIGNED_SIZEOF_STOREBLOCK); + (void) VALGRIND_MAKE_MEM_NOACCESS((char *)b + ALIGNED_SIZEOF_STOREBLOCK, + b->length - ALIGNED_SIZEOF_STOREBLOCK); } bb = b->next; @@ -489,9 +497,8 @@ store_malloc_3(int size, const char *filename, int linenumber) void *yield; if (size < 16) size = 16; -yield = malloc((size_t)size); -if (yield == NULL) +if (!(yield = malloc((size_t)size))) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to malloc %d bytes of memory: " "called from line %d of %s", size, linenumber, filename);