From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0874A0541; Fri, 7 Feb 2020 11:34:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 22F921C065; Fri, 7 Feb 2020 11:34:32 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 8B8361C044; Fri, 7 Feb 2020 11:34:29 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2020 02:34:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,413,1574150400"; d="scan'208";a="236315255" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga006.jf.intel.com with ESMTP; 07 Feb 2020 02:34:24 -0800 From: Ciara Power To: bruce.richardson@intel.com Cc: dev@dpdk.org, Ciara Power , pawelx.modrak@intel.com, stable@dpdk.org Date: Fri, 7 Feb 2020 10:24:02 +0000 Message-Id: <20200207102402.24396-1-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204160156.64773-1-ciara.power@intel.com> References: <20200204160156.64773-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH v2] examples/ioat: fix invalid link status 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 return value of the get link function call was not checked, and could return a negative value indicating a failure. This meant the link_status of the link being checked is invalid, because the link was not filled with data. The return value is now checked, and if the return value is not 0 for success, the loop continues with the next port. To avoid confusion between variable names, the existing retval variable is renamed to link_status, to better represent its use. Coverity issue: 350348 Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver") Cc: pawelx.modrak@intel.com Cc: stable@dpdk.org Signed-off-by: Ciara Power --- v2: - Changed commit log subject and description - Rebased onto master --- examples/ioat/ioatfwd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c index e9117718f..99ecc0fde 100644 --- a/examples/ioat/ioatfwd.c +++ b/examples/ioat/ioatfwd.c @@ -697,7 +697,7 @@ check_link_status(uint32_t port_mask) { uint16_t portid; struct rte_eth_link link; - int retval = 0; + int ret, link_status = 0; printf("\nChecking link status\n"); RTE_ETH_FOREACH_DEV(portid) { @@ -705,7 +705,12 @@ check_link_status(uint32_t port_mask) continue; memset(&link, 0, sizeof(link)); - rte_eth_link_get(portid, &link); + ret = rte_eth_link_get(portid, &link); + if (ret < 0) { + printf("Port %u link get failed: err=%d\n", + portid, ret); + continue; + } /* Print link status */ if (link.link_status) { @@ -714,11 +719,11 @@ check_link_status(uint32_t port_mask) portid, link.link_speed, (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex\n")); - retval = 1; + link_status = 1; } else printf("Port %d Link Down\n", portid); } - return retval; + return link_status; } static void -- 2.17.1