[1/2] app/test-eventdev: fix possible divide by zero
Checks
Commit Message
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
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 <pbhagavatula@marvell.com>
---
app/test-eventdev/test_perf_common.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
--
2.17.1
Comments
On Fri, Nov 22, 2019 at 4:22 AM <pbhagavatula@marvell.com> wrote:
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> 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 <pbhagavatula@marvell.com>
Applied to dpdk-next-eventdev/master. Thanks.
> ---
> 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
>
@@ -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;
}