From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 59825A034C;
	Wed, 21 Dec 2022 11:18:46 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 9DABE42D38;
	Wed, 21 Dec 2022 11:18:04 +0100 (CET)
Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com
 [67.231.156.173])
 by mails.dpdk.org (Postfix) with ESMTP id E92FF40695
 for <dev@dpdk.org>; Mon, 19 Dec 2022 09:35:04 +0100 (CET)
Received: from pps.filterd (m0045851.ppops.net [127.0.0.1])
 by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
 2BJ8FNk4020692; Mon, 19 Dec 2022 00:35:04 -0800
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0220;
 bh=+bbOlrERQThOHR6C/LYpWo0q9azFWKMLZ5y5gZ4tdpo=;
 b=DBr6GKbPyRDkggCX6RGlFb2bkmUfwpW1NrJP3gi3ZkxX+jyQs+j20ImVXHeB6CdJuFtx
 E2S1Z6KXtbCtOBDsNQycVYsjSHjIWEB3bqLqWOM0VoMNsFWqjXjxlInz/f5s8iQ7iNZQ
 SIqXbO84ORxQYm6H2BmnzPhD+XGLf6X+SUEoZBu9kTkT89ffhc5w9dMW5+ON5r3KDu4k
 qe2lxAJZVoBHiyKlB87iggl3r2rtUvyqs7UX+TOYJj30eB6yxMxx8b+ibkDwAAIzpg74
 L9fpoYGxYnZJcWO05jBMMajBkp7Fw0l/Tb/aouNJ4TsHynhA9+yTuCvCA57yloh6qDTP 6w== 
Received: from dc5-exch02.marvell.com ([199.233.59.182])
 by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3mhe5rk07f-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Mon, 19 Dec 2022 00:35:04 -0800
Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42;
 Mon, 19 Dec 2022 00:35:01 -0800
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend
 Transport; Mon, 19 Dec 2022 00:35:01 -0800
Received: from localhost.localdomain (unknown [10.28.34.23])
 by maili.marvell.com (Postfix) with ESMTP id 9ABD43F703F;
 Mon, 19 Dec 2022 00:34:57 -0800 (PST)
From: Mohammad Iqbal Ahmad <mahmad@marvell.com>
To: <dev@dpdk.org>, Wisam Jaddo <wisamm@nvidia.com>, Xiaoyu Min
 <jackmin@nvidia.com>
CC: <jerinj@marvell.com>, <skori@marvell.com>, <skoteshwar@marvell.com>,
 <pbhagavatula@marvell.com>, <kirankumark@marvell.com>,
 <psatheesh@marvell.com>, <asekhar@marvell.com>, <anoobj@marvell.com>,
 <gakhil@marvell.com>, <hkalra@marvell.com>, <ndabilpuram@marvell.com>,
 Mohammad Iqbal Ahmad <mahmad@marvell.com>
Subject: [PATCH v2 2/2] app/test-flow-perf: fix division or module by zero
Date: Mon, 19 Dec 2022 14:04:02 +0530
Message-ID: <20221219083402.1899934-2-mahmad@marvell.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20221219083402.1899934-1-mahmad@marvell.com>
References: <20221216073958.1645736-1-mahmad@marvell.com>
 <20221219083402.1899934-1-mahmad@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-GUID: 6m1AgfTaqi4Ko8N4ozygoURoxGuFCO2V
X-Proofpoint-ORIG-GUID: 6m1AgfTaqi4Ko8N4ozygoURoxGuFCO2V
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1
 definitions=2022-12-18_13,2022-12-15_02,2022-06-22_01
X-Mailman-Approved-At: Wed, 21 Dec 2022 11:17:53 +0100
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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

Fix division or module by zero reported by coverity scan.

Coverity issue: 373870
Fixes: bf3688f1e816 ("app/flow-perf: add insertion rate calculation")

Signed-off-by: Mohammad Iqbal Ahmad <mahmad@marvell.com>
---
 app/test-flow-perf/main.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/test-flow-perf/main.c b/app/test-flow-perf/main.c
index 4a9206803a..0a542b0d87 100644
--- a/app/test-flow-perf/main.c
+++ b/app/test-flow-perf/main.c
@@ -848,7 +848,12 @@ args_parse(int argc, char **argv)
 			/* Control */
 			if (strcmp(lgopts[opt_idx].name,
 					"rules-batch") == 0) {
-				rules_batch = atoi(optarg);
+				n = atoi(optarg);
+				if (n > 0)
+					rules_batch = n;
+				else
+					rte_exit(EXIT_FAILURE,
+							"flow rules_batch should be > 0\n");
 			}
 			if (strcmp(lgopts[opt_idx].name,
 					"rules-count") == 0) {
-- 
2.25.1