mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
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:
parent
52b831de00
commit
2a0457bbba
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue