提交 2a0457bb 编写于 作者: S Stefan Weil 提交者: Michael Tokarev

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: NStefan Weil <sw@weilnetz.de>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 52b831de
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册