From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A2FDCA04C1; Thu, 21 Nov 2019 20:22:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 70F6D2BA3; Thu, 21 Nov 2019 20:22:48 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 91F34237; Thu, 21 Nov 2019 20:22:46 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xALJKaLE019956; Thu, 21 Nov 2019 11:22:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=y48vZYiv6s/EqEmpXPrMpZFx16QOreckeT2PAWMpGw0=; b=dhZv0PKuNOP3JNfOyHR5z8WYemuEn+njRPgIlYxplVLr+JksE5h18leBlVuD8Wo/3aQ+ CH90JCq5nG8+nkLX1u+2Rnq0tvOciAqfeUmATKsY3DYO0w/HtfWnX539RTMBrH95US1w TI5BJCOouFFuQ04Rp27T5ju3ZwBW+C3yKxh/ImgaTifqPdqIx0DE+V6GHVcWXyOUoBCi MyJfc6KGz/NhDU0ftdMEFQ27To/27L1AQ2eP4/8OkxBMt/wVhHVM/in8+eHJkQcHVlgh d9TT6J8REMC3vTa7TkmvnhmGqTSygXRnNfJaT7TCgGcnbbNioSZ57pIRmLXf7B1Hpmvy wg== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2wc842fbhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 21 Nov 2019 11:22:44 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 21 Nov 2019 11:22:43 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 21 Nov 2019 11:22:43 -0800 Received: from BG-LT7430.marvell.com (unknown [10.28.17.72]) by maili.marvell.com (Postfix) with ESMTP id CA1F03F7040; Thu, 21 Nov 2019 11:22:41 -0800 (PST) From: To: CC: , Pavan Nikhilesh , Date: Fri, 22 Nov 2019 00:52:38 +0530 Message-ID: <20191121192240.12326-1-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-21_05:2019-11-21,2019-11-21 signatures=0 Subject: [dpdk-dev] [PATCH 1/2] app/test-eventdev: fix possible divide by zero 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" From: Pavan Nikhilesh Fix possible divide by zero condition when calculating percentages. Coverity Issue: 277205 Coverity Issue: 277234 Fixes: d008f20bce23 ("app/eventdev: add event timer adapter as a producer") Cc: stable@dpdk.org Signed-off-by: Pavan Nikhilesh --- app/test-eventdev/test_perf_common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index e7cf75a7d..b3af4bfec 100644 --- a/app/test-eventdev/test_perf_common.c +++ b/app/test-eventdev/test_perf_common.c @@ -133,8 +133,9 @@ perf_event_timer_producer(void *arg) fflush(stdout); rte_delay_ms(1000); printf("%s(): lcore %d Average event timer arm latency = %.3f us\n", - __func__, rte_lcore_id(), (float)(arm_latency / count) / - (rte_get_timer_hz() / 1000000)); + __func__, rte_lcore_id(), + count ? (float)(arm_latency / count) / + (rte_get_timer_hz() / 1000000) : 0); return 0; } @@ -194,8 +195,9 @@ perf_event_timer_producer_burst(void *arg) fflush(stdout); rte_delay_ms(1000); printf("%s(): lcore %d Average event timer arm latency = %.3f us\n", - __func__, rte_lcore_id(), (float)(arm_latency / count) / - (rte_get_timer_hz() / 1000000)); + __func__, rte_lcore_id(), + count ? (float)(arm_latency / count) / + (rte_get_timer_hz() / 1000000) : 0); return 0; } -- 2.17.1