oslib-posix: Fix compiler warning (-Wclobbered) and simplify the code

gcc reports this warning with -Wclobbered:

util/oslib-posix.c: In function ‘os_mem_prealloc’:
util/oslib-posix.c:374:49: error: argument ‘memory’ might be clobbered by
 ‘longjmp’ or ‘vfork’ [-Werror=clobbered]

Fix this and simplify the code by using an existing macro.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Stefan Weil 2015-03-01 13:52:06 +01:00 committed by Michael Tokarev
parent 52b831de00
commit 2a0457bbba

View File

@ -399,10 +399,10 @@ void os_mem_prealloc(int fd, char *area, size_t memory)
} else {
int i;
size_t hpagesize = fd_getpagesize(fd);
size_t numpages = DIV_ROUND_UP(memory, hpagesize);
/* MAP_POPULATE silently ignores failures */
memory = (memory + hpagesize - 1) & -hpagesize;
for (i = 0; i < (memory / hpagesize); i++) {
for (i = 0; i < numpages; i++) {
memset(area + (hpagesize * i), 0, 1);
}