From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 83BC12BA8 for ; Fri, 22 Apr 2016 16:58:22 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 22 Apr 2016 07:58:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,517,1455004800"; d="scan'208";a="960645276" Received: from gklab-246-025.igk.intel.com (HELO Sent) ([10.217.246.25]) by orsmga002.jf.intel.com with SMTP; 22 Apr 2016 07:58:19 -0700 Received: by Sent (sSMTP sendmail emulation); Fri, 22 Apr 2016 18:00:52 +0200 From: Daniel Mrzyglod To: konstantin.ananyev@intel.com Cc: dev@dpdk.org, Daniel Mrzyglod Date: Fri, 22 Apr 2016 18:00:50 +0200 Message-Id: <1461340850-202703-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] app/test_acl: fix division by float zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2016 14:58:22 -0000 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 --- 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