From: Pavan Nikhilesh Date: Thu, 21 Nov 2019 19:22:38 +0000 (+0530) Subject: app/eventdev: fix divide by zero X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=93b7794b83524b322d03634969f77d767dec13f1;p=dpdk.git app/eventdev: fix divide by zero 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 --- diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index e7cf75a7d8..b3af4bfeca 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; }