From nobody Sun May 19 03:38:13 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=1587349588; cv=none; d=zohomail.com; s=zohoarc; b=V80iuvjmiTsR0CI3bOJ0+8bBKT8Sh/8VwFN1Q1G5lkyWxgl3pS3PufosJwMI/6hIGe9XlcAnyaMr5pGpeSyBgzUH8scq07knBSJoKiIS09RUfg2+WGqaKwGdLHeQ7Pu+CZHqFfGgRmdoz5SNnjCE/IXQtdV2lLXN9Cd4HzmBXR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587349588; 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=BQ/+grdEOoUNdsU4XgTT+X/PujSsdmgv1AoR8MJw7+A=; b=gEEA3lMJnpbwNltCMAxSCMwP4p+wljO/LuB+ccAp6/uOZOnfKnVhuHUH8AkFS6fztTD9s4k1gEGkkPEabbcfoFoMVxhwCb+yM7LP4OC0HAKIM7Z0V1GU41HA255lql+bS24nwqbDZOxRWUjTOgluin3YLA7kEVGd8BaR0hFq4rg= 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 1587349588298720.9355438423241; Sun, 19 Apr 2020 19:26:28 -0700 (PDT) Received: from localhost ([::1]:56272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQM8g-0005LN-EG for importer@patchew.org; Sun, 19 Apr 2020 22:26:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46680 helo=eggs1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jQM80-0004wI-3n for qemu-devel@nongnu.org; Sun, 19 Apr 2020 22:25:44 -0400 Received: from Debian-exim by eggs1p.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jQM7z-0000gI-AW for qemu-devel@nongnu.org; Sun, 19 Apr 2020 22:25:43 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:35512 helo=huawei.com) by eggs1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jQM7y-0000Me-Gn for qemu-devel@nongnu.org; Sun, 19 Apr 2020 22:25:42 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E464268657D295F85E8B for ; Mon, 20 Apr 2020 10:25:29 +0800 (CST) Received: from opensource.huawei.com (10.175.104.212) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 20 Apr 2020 10:25:20 +0800 From: Pan Nengyuan To: Subject: [PATCH] op_helper: fix some compile warnings Date: Mon, 20 Apr 2020 01:49:59 -0400 Message-ID: <20200420054959.8082-1-pannengyuan@huawei.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.212] X-CFilter-Loop: Reflected 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: pass client-ip=45.249.212.35; envelope-from=pannengyuan@huawei.com; helo=huawei.com X-detected-operating-system: by eggs1p.gnu.org: First seen = 2020/04/19 22:25:30 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Received-From: 45.249.212.35 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: euler.robot@huawei.com, Pan Nengyuan , qemu-devel@nongnu.org, zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" We got the following compile-time warnings(gcc7.3): /mnt/sdb//qemu/target/rx/op_helper.c: In function =E2=80=98helper_scmpu=E2= =80=99: /mnt/sdb/qemu/target/rx/op_helper.c:213:24: error: =E2=80=98tmp1=E2=80=99 m= ay be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] env->psw_c =3D (tmp0 >=3D tmp1); ~~~~~~^~~~~~~~ /mnt/sdb/qemu/target/rx/op_helper.c:213:24: error: =E2=80=98tmp0=E2=80=99 m= ay be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] /mnt/sdb/qemu/target/rx/op_helper.c: In function =E2=80=98helper_suntil=E2= =80=99: /mnt/sdb/qemu/target/rx/op_helper.c:299:23: error: =E2=80=98tmp=E2=80=99 ma= y be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] env->psw_c =3D (tmp <=3D env->regs[2]); ~~~~~^~~~~~~~~~~~~~~~ /mnt/sdb/qemu/target/rx/op_helper.c: In function =E2=80=98helper_swhile=E2= =80=99: /mnt/sdb/qemu/target/rx/op_helper.c:318:23: error: =E2=80=98tmp=E2=80=99 ma= y be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] env->psw_c =3D (tmp <=3D env->regs[2]); Actually, it looks like a false-positive because it will enter the body of = while loop and init it for the first time. Let's change 'while' to 'do .. while' to avoid it. Reported-by: Euler Robot Signed-off-by: Pan Nengyuan --- 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 f89d294f2b..b612ab1da8 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.18.2