From: Daniel Mrzyglod Date: Fri, 22 Apr 2016 16:00:50 +0000 (+0200) Subject: acl: fix division by float zero in test app X-Git-Tag: spdx-start~6990 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1ef6012ec1dde4fec58353ffdeb7a79e34b8a4c0;p=dpdk.git acl: fix division by float zero in test app Fix issue reported by Coverity. Coverity ID 13240 This could cause an immediate crash or incorrect computation. In search_ip5tuples: An expression which may be zero is used as a divisor in floating-point arithmetic. divide_by_zero: In expression (long double)tm / pkt, division by expression pkt which may be zero has undefined behavior. Fixes: 26c057ab6c45 ("acl: new test-acl application") Signed-off-by: Daniel Mrzyglod Acked-by: Konstantin Ananyev --- diff --git a/app/test-acl/main.c b/app/test-acl/main.c index 0b0c093c42..d36698148c 100644 --- a/app/test-acl/main.c +++ b/app/test-acl/main.c @@ -901,7 +901,7 @@ search_ip5tuples(__attribute__((unused)) void *arg) "%s @lcore %u: %" PRIu32 " iterations, %" PRIu64 " pkts, %" PRIu32 " categories, %" PRIu64 " cycles, %#Lf cycles/pkt\n", __func__, lcore, i, pkt, config.run_categories, - tm, (long double)tm / pkt); + tm, (pkt == 0) ? 0 : (long double)tm / pkt); return 0; }