From: Stefan Weil <sw@weilnetz.de>
To: Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
"Daniel P . Berrange" <berrange@redhat.com>,
Stefan Weil <sw@weilnetz.de>
Subject: [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning and some data types
Date: Mon, 16 Oct 2017 22:29:12 +0200 [thread overview]
Message-ID: <20171016202912.1117-1-sw@weilnetz.de> (raw)
gcc warning:
/qemu/util/oslib-posix.c:304:11: error:
variable ‘addr’ might be clobbered by ‘longjmp’ or ‘vfork’
[-Werror=clobbered]
Fix also some related data types:
numpages, hpagesize are used as pointer offset.
Always use size_t for them and also for the derived
numpages_per_thread and size_per_thread.
Avoid a type cast by declaring addr volatile.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
v2: Fix more data types (partially as discussed with Richard)
v3: Keep volatile type cast (suggested by Philippe and Paolo)
Regards
Stefan
util/oslib-posix.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 80086c549f..382bd4a231 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -59,8 +59,8 @@
struct MemsetThread {
char *addr;
- uint64_t numpages;
- uint64_t hpagesize;
+ size_t numpages;
+ size_t hpagesize;
QemuThread pgthread;
sigjmp_buf env;
};
@@ -301,11 +301,7 @@ static void sigbus_handler(int signal)
static void *do_touch_pages(void *arg)
{
MemsetThread *memset_args = (MemsetThread *)arg;
- char *addr = memset_args->addr;
- uint64_t numpages = memset_args->numpages;
- uint64_t hpagesize = memset_args->hpagesize;
sigset_t set, oldset;
- int i = 0;
/* unblock SIGBUS */
sigemptyset(&set);
@@ -315,6 +311,10 @@ static void *do_touch_pages(void *arg)
if (sigsetjmp(memset_args->env, 1)) {
memset_thread_failed = true;
} else {
+ char *addr = memset_args->addr;
+ size_t numpages = memset_args->numpages;
+ size_t hpagesize = memset_args->hpagesize;
+ size_t i;
for (i = 0; i < numpages; i++) {
/*
* Read & write back the same value, so we don't
@@ -351,7 +351,8 @@ static inline int get_memset_num_threads(int smp_cpus)
static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages,
int smp_cpus)
{
- uint64_t numpages_per_thread, size_per_thread;
+ size_t numpages_per_thread;
+ size_t size_per_thread;
char *addr = area;
int i = 0;
--
2.11.0
next reply other threads:[~2017-10-16 20:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 20:29 Stefan Weil [this message]
2017-10-16 20:35 ` [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning and some data types Stefan Weil
2017-10-18 15:15 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171016202912.1117-1-sw@weilnetz.de \
--to=sw@weilnetz.de \
--cc=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).