From: Wei Hu (Xavier) Date: Sat, 6 Jun 2020 03:46:37 +0000 (+0800) Subject: app/testpmd: fix stats error message X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5fd722308ef21819931d25e7a140ff5a292b19d9;p=dpdk.git app/testpmd: fix stats error message There are coverity defects related "Argument cannot be negative" This patch fixes them by passing '-ret' to the function strerror() when ret is negative. Coverity issue: 349913, 358437, 358449, 358450 Fixes: da328f7f115a ("ethdev: change xstats reset function to return int") Fixes: 9eb974221f44 ("app/testpmd: fix statistics after reset") Cc: stable@dpdk.org Signed-off-by: Wei Hu (Xavier) Reviewed-by: Ferruh Yigit --- diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 5381207cc2..016bcb09c4 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -244,12 +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) { + if (ret < 0) + ret = -ret; printf("%s: Error: failed to get stats (port %u): %s", __func__, port_id, strerror(ret)); return; @@ -333,12 +335,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) { + if (ret < 0) + ret = -ret; printf("%s: Error: failed to get stats (port %u): %s", __func__, port_id, strerror(ret)); return;