app/dumpcap: don't pass negative value to strerror() on error

Message ID 20230207170050.1093917-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series app/dumpcap: don't pass negative value to strerror() on error |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Stephen Hemminger Feb. 7, 2023, 5 p.m. UTC
  If eth_stats_get fails (for example with -ENOTSUPP) then
dumpcap would pass that to strerror which is incorrect.

Fixes: 8744f84bb255 ("app/dumpcap: add statistics mode")
Coverity issue: 383136
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/dumpcap/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Stephen Hemminger Feb. 19, 2023, 5:50 p.m. UTC | #1
On Tue,  7 Feb 2023 09:00:50 -0800
Stephen Hemminger <stephen@networkplumber.org> wrote:

> If eth_stats_get fails (for example with -ENOTSUPP) then
> dumpcap would pass that to strerror which is incorrect.
> 
> Fixes: 8744f84bb255 ("app/dumpcap: add statistics mode")
> Coverity issue: 383136
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Small bug fix, please apply
  
Thomas Monjalon March 12, 2023, 2:16 p.m. UTC | #2
07/02/2023 18:00, Stephen Hemminger:
> If eth_stats_get fails (for example with -ENOTSUPP) then
> dumpcap would pass that to strerror which is incorrect.
> 
> Fixes: 8744f84bb255 ("app/dumpcap: add statistics mode")
> Coverity issue: 383136
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Changed the title to highlight the user facing change:
app/dumpcap: fix error message when getting statistics

Applied, thanks.
  

Patch

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 904eb5a7d7d9..64294bbfb3e6 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -500,7 +500,7 @@  static void statistics_loop(void)
 			if (r < 0) {
 				fprintf(stderr,
 					"stats_get for port %u failed: %d (%s)\n",
-					p, r, strerror(r));
+					p, r, strerror(-r));
 				return;
 			}