From patchwork Thu Jun 4 06:22:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70848 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB546A034E; Thu, 4 Jun 2020 08:23:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A355F1D59A; Thu, 4 Jun 2020 08:23:52 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 48EDC1D57F for ; Thu, 4 Jun 2020 08:23:50 +0200 (CEST) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 8E4EC669EBA79B55B77E for ; Thu, 4 Jun 2020 14:23:48 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Thu, 4 Jun 2020 14:23:40 +0800 From: "Wei Hu (Xavier)" To: CC: Date: Thu, 4 Jun 2020 14:22:17 +0800 Message-ID: <1591251737-64598-1-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] app/testpmd: fix passing negative parameter to strerror 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" Currently, there are coverity defect warnings as blow: Coverity issue: In nic_stats_clear function: CID 290021 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS) 5. negative_returns: ret is passed to a parameter that cannot be negative. CID 289974 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS) 6. negative_returns: ret is passed to a parameter that cannot be negative. In nic_xstats_clear function: CID 289985 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS) 5. negative_returns: ret is passed to a parameter that cannot be negative. CID 289850 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS) 6. negative_returns: ret is passed to a parameter that cannot be negative. This patch fixes them by passing '-ret' to the function strerror() when ret is negative. Fixes: af75078fece3 ("first public release") Fixes: 9eb974221f44 ("app/testpmd: fix statistics after reset") Cc: stable@dpdk.org Signed-off-by: Wei Hu (Xavier) --- app/test-pmd/config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 5381207..356d0d2 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -244,14 +244,14 @@ nic_stats_clear(portid_t port_id) ret = rte_eth_stats_reset(port_id); if (ret != 0) { printf("%s: Error: failed to reset stats (port %u): %s", - __func__, port_id, strerror(ret)); + __func__, port_id, strerror(-ret)); return; } ret = rte_eth_stats_get(port_id, &ports[port_id].stats); if (ret != 0) { printf("%s: Error: failed to get stats (port %u): %s", - __func__, port_id, strerror(ret)); + __func__, port_id, strerror(-ret)); return; } printf("\n NIC statistics for port %d cleared\n", port_id); @@ -333,14 +333,14 @@ nic_xstats_clear(portid_t port_id) ret = rte_eth_xstats_reset(port_id); if (ret != 0) { printf("%s: Error: failed to reset xstats (port %u): %s", - __func__, port_id, strerror(ret)); + __func__, port_id, strerror(-ret)); return; } ret = rte_eth_stats_get(port_id, &ports[port_id].stats); if (ret != 0) { printf("%s: Error: failed to get stats (port %u): %s", - __func__, port_id, strerror(ret)); + __func__, port_id, strerror(-ret)); return; } }