From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A80B2C4360F for ; Fri, 5 Apr 2019 14:37:57 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 64DC521852 for ; Fri, 5 Apr 2019 14:37:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64DC521852 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A05E1B54F; Fri, 5 Apr 2019 16:37:41 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id D28861B53B; Fri, 5 Apr 2019 16:37:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2019 07:37:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,313,1549958400"; d="scan'208";a="140280854" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga003.jf.intel.com with ESMTP; 05 Apr 2019 07:37:29 -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: Fri, 5 Apr 2019 15:37:08 +0100 Message-Id: <20190405143709.50352-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190405143709.50352-1-bruce.richardson@intel.com> References: <20190405134511.49066-1-bruce.richardson@intel.com> <20190405143709.50352-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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" 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 ee50e4566..2155ff241 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -18306,13 +18306,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