Skip to content

Commit

Permalink
app/eventdev: fix divide by zero
Browse files Browse the repository at this point in the history
[ upstream commit 93b7794 ]

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")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
  • Loading branch information
PavanNikhilesh authored and kevintraynor committed Dec 11, 2019
1 parent f35ffea commit e3edd01
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 @@ -128,8 +128,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 @@ -189,8 +190,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 e3edd01

Please sign in to comment.