* [PATCH iproute2] ipstats: fix message reporting error
@ 2023-05-29 16:59 Andrea Claudi
2023-05-30 19:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Claudi @ 2023-05-29 16:59 UTC (permalink / raw)
To: netdev; +Cc: stephen, dsahern, me
strerror() accepts any integer as arguments, but returns meaningful
error descriptions only for positive integers.
ipstats code uses strerror on a code path where either err is 0 or
-ENOMEM, thus resulting in a useless error message.
Fix this using errno and moving the error printing closer to the only
function populating it in this code path.
Fixes: df0b2c6d0098 ("ipstats: Add a shell of "show" command")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
ip/ipstats.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ip/ipstats.c b/ip/ipstats.c
index dadded14..3f94ff1e 100644
--- a/ip/ipstats.c
+++ b/ip/ipstats.c
@@ -88,8 +88,11 @@ ipstats_stat_show_attrs_alloc_tb(struct ipstats_stat_show_attrs *attrs,
return 0;
attrs->tbs[group] = calloc(ifla_max + 1, sizeof(*attrs->tbs[group]));
- if (attrs->tbs[group] == NULL)
- return -ENOMEM;
+ if (attrs->tbs[group] == NULL) {
+ fprintf(stderr, "Error parsing netlink answer: %s\n",
+ strerror(errno));
+ return -errno;
+ }
if (group == 0)
err = parse_rtattr(attrs->tbs[group], ifla_max,
@@ -755,11 +758,8 @@ ipstats_process_ifsm(struct nlmsghdr *answer,
}
err = ipstats_stat_show_attrs_alloc_tb(&show_attrs, 0);
- if (err != 0) {
- fprintf(stderr, "Error parsing netlink answer: %s\n",
- strerror(err));
+ if (err)
return err;
- }
dev = ll_index_to_name(show_attrs.ifsm->ifindex);
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] ipstats: fix message reporting error
2023-05-29 16:59 [PATCH iproute2] ipstats: fix message reporting error Andrea Claudi
@ 2023-05-30 19:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-30 19:30 UTC (permalink / raw)
To: Andrea Claudi; +Cc: netdev, stephen, dsahern, me
Hello:
This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:
On Mon, 29 May 2023 18:59:15 +0200 you wrote:
> strerror() accepts any integer as arguments, but returns meaningful
> error descriptions only for positive integers.
>
> ipstats code uses strerror on a code path where either err is 0 or
> -ENOMEM, thus resulting in a useless error message.
>
> Fix this using errno and moving the error printing closer to the only
> function populating it in this code path.
>
> [...]
Here is the summary with links:
- [iproute2] ipstats: fix message reporting error
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=995096d946cb
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-30 19:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-29 16:59 [PATCH iproute2] ipstats: fix message reporting error Andrea Claudi
2023-05-30 19:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).