app/eventdev: fix divide by zero

Fix possible divide by zero condition when calculating percentages.

Coverity issue: 277205
Coverity issue: 277234
Fixes: d008f20bce ("app/eventdev: add event timer adapter as a producer")
Cc: stable@dpdk.org

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
This commit is contained in:
Pavan Nikhilesh 2019-11-22 00:52:38 +05:30 committed by Jerin Jacob
parent 997d5d0d0e
commit 93b7794b83

View File

@ -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;
}