From nobody Sat Apr 27 17:25:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508185852266815.6896457077759; Mon, 16 Oct 2017 13:30:52 -0700 (PDT) Received: from localhost ([::1]:35099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4C26-0007Dc-K7 for importer@patchew.org; Mon, 16 Oct 2017 16:30:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4C0q-0006Eu-9M for qemu-devel@nongnu.org; Mon, 16 Oct 2017 16:29:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4C0m-0008FH-QW for qemu-devel@nongnu.org; Mon, 16 Oct 2017 16:29:24 -0400 Received: from mail.weilnetz.de ([37.120.169.71]:40400 helo=v2201612906741603.powersrv.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4C0m-0008Eh-Ic; Mon, 16 Oct 2017 16:29:20 -0400 Received: from localhost (localhost [127.0.0.1]) by v2201612906741603.powersrv.de (Postfix) with ESMTP id BB539DA8480; Mon, 16 Oct 2017 22:29:18 +0200 (CEST) Received: from v2201612906741603.powersrv.de ([127.0.0.1]) by localhost (v2201612906741603.powersrv.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6lF5EbTd5BXM; Mon, 16 Oct 2017 22:29:18 +0200 (CEST) Received: from qemu.weilnetz.de (qemu.weilnetz.de [188.68.58.204]) by v2201612906741603.powersrv.de (Postfix) with ESMTP id 3BF0FDA8424; Mon, 16 Oct 2017 22:29:18 +0200 (CEST) Received: by qemu.weilnetz.de (Postfix, from userid 1000) id 245F6462248; Mon, 16 Oct 2017 22:29:18 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at v2201612906741603.powersrv.de From: Stefan Weil To: Richard Henderson , qemu-devel@nongnu.org, qemu-trivial@nongnu.org Date: Mon, 16 Oct 2017 22:29:12 +0200 Message-Id: <20171016202912.1117-1-sw@weilnetz.de> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 37.120.169.71 Subject: [Qemu-devel] [PATCH] oslib-posix: Fix compiler warning and some data types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Stefan Hajnoczi , Stefan Weil Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" gcc warning: /qemu/util/oslib-posix.c:304:11: error: variable =E2=80=98addr=E2=80=99 might be clobbered by =E2=80=98longjmp=E2= =80=99 or =E2=80=98vfork=E2=80=99 [-Werror=3Dclobbered] 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=C3=A9 Signed-off-by: Stefan Weil --- 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 @@ =20 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 =3D (MemsetThread *)arg; - char *addr =3D memset_args->addr; - uint64_t numpages =3D memset_args->numpages; - uint64_t hpagesize =3D memset_args->hpagesize; sigset_t set, oldset; - int i =3D 0; =20 /* unblock SIGBUS */ sigemptyset(&set); @@ -315,6 +311,10 @@ static void *do_touch_pages(void *arg) if (sigsetjmp(memset_args->env, 1)) { memset_thread_failed =3D true; } else { + char *addr =3D memset_args->addr; + size_t numpages =3D memset_args->numpages; + size_t hpagesize =3D memset_args->hpagesize; + size_t i; for (i =3D 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 =3D area; int i =3D 0; =20 --=20 2.11.0