From nobody Wed May 22 01:08:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611854931; cv=none; d=zohomail.com; s=zohoarc; b=gBkZ7+ufU5Sj4zBA+c2KQ3gM810cx8F7a0IlzUc0qS0XA+/EOH0EXWuQq6Vipfewgfd8vzlAv8wo2/2okWnVoMRWhU9/zlmZ532Pi/l2qgr36JcFv6x6pvhuA0QQbIj4j1wEoIeO7Z6I9/SH0BgSRmAv06KP7+N8mDGCgPHmEew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611854931; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tsCyEaTWbtUHj6nL3rVr0h75jODg894xUDvQTduS9XI=; b=Ph8mdz0EDRTTI3STp4MtYRDZLPea0OP6HPBNUO792Geueh7daxcK3Nb6qH43Ug+pZ6sZj4TzXzS8aDhPNGHF9ydbNSvbsd3TVZon/mip4PV/Gtq3EuYei1/om68z9D5PzzpDliHDs7vp/SMo6lJ1muYpeSTMpfC6Z5YGOgqKFHA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611854931805272.70303122884536; Thu, 28 Jan 2021 09:28:51 -0800 (PST) Received: from localhost ([::1]:59760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5B6A-0003pT-Lq for importer@patchew.org; Thu, 28 Jan 2021 12:28:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5Az7-0006N3-LD for qemu-devel@nongnu.org; Thu, 28 Jan 2021 12:21:33 -0500 Received: from p200300c3873ab300042f31d82bb10f72.dip0.t-ipconnect.de ([2003:c3:873a:b300:42f:31d8:2bb1:f72]:51066 helo=mini.fritz.box) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5Az5-0000Yy-9X for qemu-devel@nongnu.org; Thu, 28 Jan 2021 12:21:33 -0500 Received: by mini.fritz.box (Postfix, from userid 502) id 37DBC92CB3B; Thu, 28 Jan 2021 18:21:28 +0100 (CET) From: Stefan Weil To: Yoshinori Sato Subject: [PATCH] target/rx: Fix compiler errors for build with sanitizers Date: Thu, 28 Jan 2021 18:21:27 +0100 Message-Id: <20210128172127.46041-1-sw@weilnetz.de> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2003:c3:873a:b300:42f:31d8:2bb1:f72; envelope-from=stefan@mini.fritz.box; helo=mini.fritz.box X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, KHOP_HELO_FCRDNS=0.399, NO_DNS_FOR_FROM=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , qemu-devel@nongnu.org, Stefan Weil Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" gcc (Debian 10.2.1-6) 10.2.1 20210110 aborts builds with enabled sanitizers: ../../../target/rx/op_helper.c: In function =E2=80=98helper_scmpu=E2=80=99: ../../../target/rx/op_helper.c:213:24: error: =E2=80=98tmp1=E2=80=99 may be= used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 213 | env->psw_c =3D (tmp0 >=3D tmp1); | ~~~~~~^~~~~~~~ ../../../target/rx/op_helper.c:213:24: error: =E2=80=98tmp0=E2=80=99 may be= used uninitialized in this function [-Werror=3Dmaybe-uninitialized] ../../../target/rx/op_helper.c: In function =E2=80=98helper_suntil=E2=80=99: ../../../target/rx/op_helper.c:299:23: error: =E2=80=98tmp=E2=80=99 may be = used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 299 | env->psw_c =3D (tmp <=3D env->regs[2]); | ~~~~~^~~~~~~~~~~~~~~~ ../../../target/rx/op_helper.c: In function =E2=80=98helper_swhile=E2=80=99: ../../../target/rx/op_helper.c:318:23: error: =E2=80=98tmp=E2=80=99 may be = used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 318 | env->psw_c =3D (tmp <=3D env->regs[2]); | ~~~~~^~~~~~~~~~~~~~~~ Rewriting the code fixes those errors. Signed-off-by: Stefan Weil Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth --- Those error are false positives, but simple code changes help the compiler (and perhaps reviewers) to understand it better. Stefan target/rx/op_helper.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/rx/op_helper.c b/target/rx/op_helper.c index 59389f4992..4d315b4449 100644 --- a/target/rx/op_helper.c +++ b/target/rx/op_helper.c @@ -201,14 +201,14 @@ void helper_scmpu(CPURXState *env) if (env->regs[3] =3D=3D 0) { return; } - while (env->regs[3] !=3D 0) { + do { tmp0 =3D cpu_ldub_data_ra(env, env->regs[1]++, GETPC()); tmp1 =3D cpu_ldub_data_ra(env, env->regs[2]++, GETPC()); env->regs[3]--; if (tmp0 !=3D tmp1 || tmp0 =3D=3D '\0') { break; } - } + } while (env->regs[3] !=3D 0); env->psw_z =3D tmp0 - tmp1; env->psw_c =3D (tmp0 >=3D tmp1); } @@ -287,14 +287,14 @@ void helper_suntil(CPURXState *env, uint32_t sz) if (env->regs[3] =3D=3D 0) { return ; } - while (env->regs[3] !=3D 0) { + do { tmp =3D cpu_ldufn[sz](env, env->regs[1], GETPC()); env->regs[1] +=3D 1 << sz; env->regs[3]--; if (tmp =3D=3D env->regs[2]) { break; } - } + } while (env->regs[3] !=3D 0); env->psw_z =3D tmp - env->regs[2]; env->psw_c =3D (tmp <=3D env->regs[2]); } @@ -306,14 +306,14 @@ void helper_swhile(CPURXState *env, uint32_t sz) if (env->regs[3] =3D=3D 0) { return ; } - while (env->regs[3] !=3D 0) { + do { tmp =3D cpu_ldufn[sz](env, env->regs[1], GETPC()); env->regs[1] +=3D 1 << sz; env->regs[3]--; if (tmp !=3D env->regs[2]) { break; } - } + } while (env->regs[3] !=3D 0); env->psw_z =3D env->regs[3]; env->psw_c =3D (tmp <=3D env->regs[2]); } --=20 2.24.3 (Apple Git-128)