From 2b4a53e2763b2a8fa3527c16dc0ee6db1ef71334 Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Thu, 4 Jul 2024 08:32:42 +0300 Subject: [PATCH] test: icache_perf: fix potential divide by zero Fix DIVIDE_BY_ZERO warning from Coverity. Signed-off-by: Matias Elo Reviewed-by: Petri Savolainen --- test/performance/odp_icache_perf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/performance/odp_icache_perf.c b/test/performance/odp_icache_perf.c index 3faf93fbb5..581bfff125 100644 --- a/test/performance/odp_icache_perf.c +++ b/test/performance/odp_icache_perf.c @@ -15398,7 +15398,8 @@ static void print_stat(test_global_t *global) printf("TOTAL (%i workers)\n", num_cpu); printf(" ave loops per sec: %.1f k/sec\n", ave_loops / kilo); printf(" ave test run time: %.3f msec\n", 1000 * (sum_sec / num_cpu)); - printf(" ave CPU cycles per loop: %.1f\n", sum_cycles / (double)sum_loops); + printf(" ave CPU cycles per loop: %.1f\n", + sum_loops > 0 ? sum_cycles / (double)sum_loops : 0); printf("\n"); }