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 931CFA0548; Fri, 23 Apr 2021 09:35:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F3DA4067E; Fri, 23 Apr 2021 09:35:27 +0200 (CEST) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id A5F1B4014F for ; Fri, 23 Apr 2021 09:35:25 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FRQwg6xmLzpbLk; Fri, 23 Apr 2021 15:32:19 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Fri, 23 Apr 2021 15:35:17 +0800 From: "Min Hu (Connor)" To: CC: , , Date: Fri, 23 Apr 2021 15:35:30 +0800 Message-ID: <1619163330-25960-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] test: 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 i is used as a denominator which may be zero, and this may result in segmentation fault. This patch fixed it. Fixes: 948bc3d6d095 ("test: add reciprocal based division") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) --- app/test/test_reciprocal_division_perf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/test/test_reciprocal_division_perf.c b/app/test/test_reciprocal_division_perf.c index a7be8aa..2647308 100644 --- a/app/test/test_reciprocal_division_perf.c +++ b/app/test/test_reciprocal_division_perf.c @@ -143,7 +143,7 @@ test_reciprocal_division_perf(void) "result %"PRIu64"", nresult_u64, rresult_u64); result = 1; - break; + goto err; } } @@ -182,7 +182,7 @@ test_reciprocal_division_perf(void) dividend_u64, divisor_u64, nresult_u64, rresult_u64); result = 1; - break; + goto err; } } printf("64bit Division results:\n"); @@ -195,6 +195,7 @@ test_reciprocal_division_perf(void) printf("Cycles per division(reciprocal) : %3.2f\n", ((double)tot_cyc_r)/i); +err: return result; } -- 2.7.4