From patchwork Fri Apr 22 16:00:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mrzyglod X-Patchwork-Id: 12215 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B86D22BBE; Fri, 22 Apr 2016 16:58:23 +0200 (CEST) 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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; }