From patchwork Thu Jan 18 18:27:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 863062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oBqSm6So"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zMssM5J4rz9s71 for ; Fri, 19 Jan 2018 05:28:23 +1100 (AEDT) Received: from localhost ([::1]:46569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecEvF-0004oV-Rh for incoming@patchwork.ozlabs.org; Thu, 18 Jan 2018 13:28:21 -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) 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) 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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 = g_malloc(1); int status = info->read_memory_func(memaddr, buffer, 1, info); xtensa_format fmt; - unsigned slot, slots; + int slot, slots; unsigned len; if (status) { @@ -79,7 +79,7 @@ int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info) for (slot = 0; slot < slots; ++slot) { xtensa_opcode opc; - unsigned opnd, vopnd, opnds; + int opnd, vopnd, opnds; 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, DisasContext *dc) unsigned char b[MAX_INSN_LENGTH] = {cpu_ldub_code(env, dc->pc)}; unsigned len = xtensa_op0_insn_len(dc, b[0]); xtensa_format fmt; - unsigned slot, slots; + int slot, slots; unsigned i; if (len == XTENSA_UNDEFINED) { @@ -969,7 +969,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc) slots = xtensa_format_num_slots(isa, fmt); for (slot = 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;