From nobody Sun Apr 28 22:49:52 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; dkim=fail; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516300141924761.0927071091769; Thu, 18 Jan 2018 10:29:01 -0800 (PST) Received: from localhost ([::1]:46586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecEvk-0005BY-Vr for importer@patchew.org; Thu, 18 Jan 2018 13:28:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecEuv-0004nZ-Mx for qemu-devel@nongnu.org; Thu, 18 Jan 2018 13:28:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecEuu-0000mp-S1 for qemu-devel@nongnu.org; Thu, 18 Jan 2018 13:28:01 -0500 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:44083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecEuu-0000kz-Ke for qemu-devel@nongnu.org; Thu, 18 Jan 2018 13:28:00 -0500 Received: by mail-lf0-x242.google.com with SMTP id w23so27848708lfd.11 for ; Thu, 18 Jan 2018 10:28:00 -0800 (PST) Received: from octofox.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id s65sm1305045lfi.76.2018.01.18.10.27.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jan 2018 10:27:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cj2GodsuDabW/z2A7sfx7cUr1G4kiLrrH8UXf/JnmDw=; b=oBqSm6So2tgySCWsXagBRH3ZSDjQq8N78DJCGRR4gGBaywhBR56pAdxBFevJUPYVsf x0x6A4IMIhP6ftuUglaBg0SSX/aKzDc3+YfCncOOLhJ7h2WAkJZLGpRMyctL1qYDQ1Q2 ALRdcHo6h6vmfsDNsew24Yq2jBAi2HtmONu2lJEPbpEP3HtKoixxpsZCh0oR5brFuoeS M0EINPkBUT1byZUgueuiKNmv2n5/OPATzn+4AuyeNUQByI1xgttljcXtE2BBZNvpnkVg tDfYc/3LcY0RDrSX6sOlIyi02RVLL0RYH7qsSI8l4GzVNZSe7WzLBRVaNBBIwujkLJjq xnWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cj2GodsuDabW/z2A7sfx7cUr1G4kiLrrH8UXf/JnmDw=; b=hvbLEJVs9USLJmU4bjobTK89Anw1dVKvEVZJiQnOTkgM0Jr/B7fGuFvRfWubVegVwl TEYxA/7Vi0/NgpMXuejSxsS6CQYbbeygu0J/Ht4r5Q56BWpS6wcas9EnI3y5DwA/hSsC SV0W0baoesEZDMkVNAJy1oqqo1jWqGA9/rmCfUhK0M5xo8FrdR0cE5/cfUDcfdnHNrFo sAFO/Copv18HCYplBhIdpnQtuh8uGLoedUVqZ3dHdMXXBixXv891n/Ia9kl4Bz7JG7vk QqXRu6ZBbIFK16S/seTEpgzLNM0w1HnXtFwyrKxvIlBT8L8vNmU6t73etTtgDAM8dhvI vE+w== X-Gm-Message-State: AKwxytcAb+iEz0BWAF7lrRtraDHJqhYoTAlofMWMpVGeORDzAdaNo8lS F3bfaWI4DCfPfmehiMQbwvD57Q== X-Google-Smtp-Source: ACJfBotlAc1F/939Scv4CapSAniM2w1HK5J4POjwLFJVo22aZJcE1vM2j7MZdd/kVw4hz/hxJMXjuw== X-Received: by 10.46.93.210 with SMTP id v79mr9449995lje.80.1516300079130; Thu, 18 Jan 2018 10:27:59 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 18 Jan 2018 10:27:46 -0800 Message-Id: <1516300066-18600-1-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.1.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::242 Subject: [Qemu-devel] [PATCH] target/xtensa: disas/xtensa: fix coverity warnings 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: Max Filippov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Coverity warnings CID 1385146, 1385148 1385149 and 1385150 point that xtensa_opcode_num_operands and xtensa_format_num_slots may return -1 even when xtensa_opcode_decode and xtensa_format_decode succeed. In that case unsigned counters used to iterate through operands/slots will not do the right thing. Make counters and loop bounds signed to fix the warnings. Signed-off-by: Max Filippov --- disas/xtensa.c | 4 ++-- target/xtensa/translate.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/disas/xtensa.c b/disas/xtensa.c index 114326a4fc2e..5e3870b9ad23 100644 --- a/disas/xtensa.c +++ b/disas/xtensa.c @@ -37,7 +37,7 @@ int print_insn_xtensa(bfd_vma memaddr, struct disassemble= _info *info) bfd_byte *buffer =3D g_malloc(1); int status =3D info->read_memory_func(memaddr, buffer, 1, info); xtensa_format fmt; - unsigned slot, slots; + int slot, slots; unsigned len; =20 if (status) { @@ -79,7 +79,7 @@ int print_insn_xtensa(bfd_vma memaddr, struct disassemble= _info *info) =20 for (slot =3D 0; slot < slots; ++slot) { xtensa_opcode opc; - unsigned opnd, vopnd, opnds; + int opnd, vopnd, opnds; =20 if (slot) { info->fprintf_func(info->stream, "; "); diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 4bdfcd24d09b..3f439203acf3 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -942,7 +942,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, Disa= sContext *dc) unsigned char b[MAX_INSN_LENGTH] =3D {cpu_ldub_code(env, dc->pc)}; unsigned len =3D xtensa_op0_insn_len(dc, b[0]); xtensa_format fmt; - unsigned slot, slots; + int slot, slots; unsigned i; =20 if (len =3D=3D XTENSA_UNDEFINED) { @@ -969,7 +969,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, Disa= sContext *dc) slots =3D xtensa_format_num_slots(isa, fmt); for (slot =3D 0; slot < slots; ++slot) { xtensa_opcode opc; - unsigned opnd, vopnd, opnds; + int opnd, vopnd, opnds; uint32_t raw_arg[MAX_OPCODE_ARGS]; uint32_t arg[MAX_OPCODE_ARGS]; XtensaOpcodeOps *ops; --=20 2.1.4