From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0E48FA0524; Mon, 19 Apr 2021 15:35:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1A5FA412FB; Mon, 19 Apr 2021 15:34:54 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mails.dpdk.org (Postfix) with ESMTP id 0C87D412EB for ; Mon, 19 Apr 2021 15:34:49 +0200 (CEST) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FP762385XzqTjs; Mon, 19 Apr 2021 21:32:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Mon, 19 Apr 2021 21:34:38 +0800 From: "Min Hu (Connor)" To: CC: , , , , , , , , Date: Mon, 19 Apr 2021 21:34:43 +0800 Message-ID: <1618839289-33224-5-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618839289-33224-1-git-send-email-humin29@huawei.com> References: <1618839289-33224-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 04/10] app/regex: fix division by zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Variable nb_jobs, which may be zero, is used as a denominator. This patch fixed it. Fixes: f5cffb7eb7fb ("app/regex: read data file once at startup") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) --- app/test-regex/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/test-regex/main.c b/app/test-regex/main.c index 8e665df..b49fa88 100644 --- a/app/test-regex/main.c +++ b/app/test-regex/main.c @@ -725,9 +725,11 @@ main(int argc, char **argv) if (data_len <= 0) rte_exit(EXIT_FAILURE, "Error, can't read file, or file is empty.\n"); - job_len = data_len / nb_jobs; - if (job_len == 0) - rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given input.\n"); + if (!nb_jobs) { + job_len = data_len / nb_jobs; + if (job_len == 0) + rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given input.\n"); + } if (job_len > nb_max_payload) rte_exit(EXIT_FAILURE, "Error, not enough jobs to cover input.\n"); -- 2.7.4