From 5fd722308ef21819931d25e7a140ff5a292b19d9 Mon Sep 17 00:00:00 2001 From: "Wei Hu (Xavier)" Date: Sat, 6 Jun 2020 11:46:37 +0800 Subject: [PATCH] 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 --- app/test-pmd/config.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; -- 2.20.1