DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/test_acl: fix division by float zero
@ 2016-04-22 16:00 Daniel Mrzyglod
  2016-04-22 15:15 ` Ananyev, Konstantin
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Mrzyglod @ 2016-04-22 16:00 UTC (permalink / raw)
  To: konstantin.ananyev; +Cc: dev, Daniel Mrzyglod

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 <danielx.t.mrzyglod@intel.com>
---
 app/test-acl/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-acl/main.c b/app/test-acl/main.c
index 0b0c093..d366981 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;
 }
-- 
2.5.5

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-27 14:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-22 16:00 [dpdk-dev] [PATCH] app/test_acl: fix division by float zero Daniel Mrzyglod
2016-04-22 15:15 ` Ananyev, Konstantin
2016-04-27 14:14   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).