* [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning (-Wclobbered) and simplify the code
@ 2015-03-01 12:52 Stefan Weil
2015-03-02 12:19 ` Michael Tokarev
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2015-03-01 12:52 UTC (permalink / raw)
To: QEMU Trivial; +Cc: Paolo Bonzini, QEMU Developer, Stefan Weil
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>
---
util/oslib-posix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 16fcec2..37ffd96 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);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning (-Wclobbered) and simplify the code
2015-03-01 12:52 [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning (-Wclobbered) and simplify the code Stefan Weil
@ 2015-03-02 12:19 ` Michael Tokarev
0 siblings, 0 replies; 2+ messages in thread
From: Michael Tokarev @ 2015-03-02 12:19 UTC (permalink / raw)
To: Stefan Weil, QEMU Trivial; +Cc: Paolo Bonzini, QEMU Developer
Applied to trivial, thank you!
/mjt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-02 12:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-01 12:52 [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning (-Wclobbered) and simplify the code Stefan Weil
2015-03-02 12:19 ` Michael Tokarev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).