From patchwork Thu Nov 19 11:58:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 84372 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BA350A04DD; Thu, 19 Nov 2020 12:59:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D581AC884; Thu, 19 Nov 2020 12:59:15 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id E5C273B5; Thu, 19 Nov 2020 12:59:10 +0100 (CET) IronPort-SDR: xPljFI0i97cTPcmqIoY+mzMh1pBGwecZRvr8E5V1QGQvuKi/8ysJlns6/Q4EuPQMl+yaAQWoaX AnFqqMtR8L5w== X-IronPort-AV: E=McAfee;i="6000,8403,9809"; a="170494384" X-IronPort-AV: E=Sophos;i="5.77,490,1596524400"; d="scan'208";a="170494384" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2020 03:59:10 -0800 IronPort-SDR: hrZDBqMOx5gqF6QI4nRLWy8fdZoXV8Dz46B8XzC9AHr/QUNXxWTkbqI4YDPb244YQo92r5VRQx HvivAYz2C+Ew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,490,1596524400"; d="scan'208";a="341665147" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga002.jf.intel.com with ESMTP; 19 Nov 2020 03:59:08 -0800 From: Ferruh Yigit To: dev@dpdk.org, Maryam Tahhan , Reshma Pattan , Kuba Kozak Cc: Ferruh Yigit , stable@dpdk.org, David Marchand Date: Thu, 19 Nov 2020 11:58:52 +0000 Message-Id: <20201119115900.4095566-3-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201119115900.4095566-1-ferruh.yigit@intel.com> References: <20200824094021.2323605-1-ferruh.yigit@intel.com> <20201119115900.4095566-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [v21.02 v3 02/10] app/procinfo: fix negative check on unsigned variable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 'parse_xstats_ids()' return 'int'. The return value is assigned to 'nb_xstats_ids' unsigned value, later negative check on this variable is wrong. Adding interim 'int' variable for negative check. Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit Reviewed-by: David Marchand --- v3: * Removed casting --- app/proc-info/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 35e5b596eb..8ee30ddb71 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -301,14 +301,13 @@ proc_info_parse_args(int argc, char **argv) } else if (!strncmp(long_option[option_index].name, "xstats-ids", MAX_LONG_OPT_SZ)) { - nb_xstats_ids = parse_xstats_ids(optarg, + int ret = parse_xstats_ids(optarg, xstats_ids, MAX_NB_XSTATS_IDS); - - if (nb_xstats_ids <= 0) { + if (ret <= 0) { printf("xstats-id list parse error.\n"); return -1; } - + nb_xstats_ids = ret; } break; default: