summaryrefslogtreecommitdiff
path: root/util/oslib-posix.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2015-03-01 13:52:06 +0100
committerMichael Tokarev <mjt@tls.msk.ru>2015-03-10 08:15:34 +0300
commit2a0457bbba10c208358e4e52642abeadd5f10c33 (patch)
tree82ca2b75a71b4d0ca825eeff2fb83f484daa83a0 /util/oslib-posix.c
parent52b831de0099e627ee3505cb1c0c3d8eeefd3d65 (diff)
downloadqemu-2a0457bbba10c208358e4e52642abeadd5f10c33.tar.gz
qemu-2a0457bbba10c208358e4e52642abeadd5f10c33.tar.bz2
qemu-2a0457bbba10c208358e4e52642abeadd5f10c33.zip
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>
Diffstat (limited to 'util/oslib-posix.c')
-rw-r--r--util/oslib-posix.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 16fcec2f37..37ffd96245 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -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);
}