From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 42546A0096 for ; Mon, 8 Apr 2019 11:47:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A08255589; Mon, 8 Apr 2019 11:47:10 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id DB46C54AE; Mon, 8 Apr 2019 11:47:07 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2019 02:47:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,324,1549958400"; d="scan'208";a="221512873" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga001.jf.intel.com with ESMTP; 08 Apr 2019 02:47:05 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , wei.dai@intel.com, stable@dpdk.org, Bernard Iremonger , Wenzhuo Lu , Rami Rosen Date: Mon, 8 Apr 2019 10:46:39 +0100 Message-Id: <20190408094640.46030-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190408094640.46030-1-bruce.richardson@intel.com> References: <20190405134511.49066-1-bruce.richardson@intel.com> <20190408094640.46030-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 4/5] app/testpmd: fix variable use before NULL check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190408094639.vHXmWgd-zSaBq_6cMsADfjRCP75-yLrCNNGULC13BCI@z> The value returned from rte_eth_dev_tx_offload_name() function is used for string comparison before being checked for NULL. Move the NULL check up to be done first. Coverity issue: 279438 Fixes: c73a9071877a ("app/testpmd: add commands to test new offload API") Cc: wei.dai@intel.com Cc: stable@dpdk.org Cc: Bernard Iremonger Cc: Wenzhuo Lu Signed-off-by: Bruce Richardson Acked-by: Rami Rosen --- app/test-pmd/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 2ab03c111..391bc8097 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -18311,13 +18311,13 @@ search_tx_offload(const char *name) single_offload = 1; for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { single_name = rte_eth_dev_tx_offload_name(single_offload); + if (single_name == NULL) + break; if (!strcasecmp(single_name, name)) { found = 1; break; } else if (!strcasecmp(single_name, "UNKNOWN")) break; - else if (single_name == NULL) - break; single_offload <<= 1; } -- 2.20.1