From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 978ACA04E6;
	Wed, 18 Nov 2020 12:46:20 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id ED466C8CC;
	Wed, 18 Nov 2020 12:45:43 +0100 (CET)
Received: from mga18.intel.com (mga18.intel.com [134.134.136.126])
 by dpdk.org (Postfix) with ESMTP id 9D4DE5947;
 Wed, 18 Nov 2020 12:45:40 +0100 (CET)
IronPort-SDR: T7E4skyl+jt0CoGqkguLPXOabcx2EHExI+1cgk0RUKFI1/sbEM+tGRhWv477uPzwk6wb0qTRMD
 XeCmp3Fmxydw==
X-IronPort-AV: E=McAfee;i="6000,8403,9808"; a="158876061"
X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="158876061"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga004.jf.intel.com ([10.7.209.38])
 by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 18 Nov 2020 03:45:40 -0800
IronPort-SDR: 61IvArz9KogZDohY+K2KEotiwo/uxZoFbErGa9Q0oxQsaCv/ucChd9GBePIkbXO83OPVbXOaTL
 40lRxENHhwmA==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.77,486,1596524400"; d="scan'208";a="476313123"
Received: from silpixa00399752.ir.intel.com (HELO
 silpixa00399752.ger.corp.intel.com) ([10.237.222.180])
 by orsmga004.jf.intel.com with ESMTP; 18 Nov 2020 03:45:38 -0800
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Maryam Tahhan <maryam.tahhan@intel.com>,
 Reshma Pattan <reshma.pattan@intel.com>, Kuba Kozak <kubax.kozak@intel.com>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	dev@dpdk.org,
	stable@dpdk.org
Date: Wed, 18 Nov 2020 11:45:20 +0000
Message-Id: <20201118114525.99053-3-ferruh.yigit@intel.com>
X-Mailer: git-send-email 2.26.2
In-Reply-To: <20201118114525.99053-1-ferruh.yigit@intel.com>
References: <20201117171435.2303641-1-ferruh.yigit@intel.com>
 <20201118114525.99053-1-ferruh.yigit@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v2 2/7] 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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

'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 <ferruh.yigit@intel.com>
---
 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..c11fe25af4 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 = (uint32_t)ret;
 			}
 			break;
 		default:
-- 
2.26.2