Skip to content

Commit

Permalink
app/eventdev: fix divide by zero
Browse files Browse the repository at this point in the history
Fix possible divide by zero condition when calculating percentages.

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

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
  • Loading branch information
PavanNikhilesh authored and jerinjacobk committed Nov 26, 2019
1 parent 997d5d0 commit 93b7794
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/test-eventdev/test_perf_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 93b7794

Please sign in to comment.