From: Yedaya Katsman <yedaya.ka@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
David Ahern <dsahern@kernel.org>
Cc: Petr Machata <petrm@nvidia.com>,
netdev@vger.kernel.org, Yedaya Katsman <yedaya.ka@gmail.com>
Subject: [PATCH] ip: Make 'ip stats help' exit with -1
Date: Sun, 01 Mar 2026 16:12:03 +0200 [thread overview]
Message-ID: <20260301-ip-stats-exit-code-v1-1-2b59f0704f2c@gmail.com> (raw)
ip <subcommand> help exits with -1 for all commands except for stats, make
it match.
This removes a goto err, which is redundant since "enabled" gets
allocated only if we find a level, but we enter do_help only if we didn't.
Fixes: df0b2c6d0098 ("ipstats: Add a shell of "show" command")
Signed-off-by: Yedaya Katsman <yedaya.ka@gmail.com>
---
ip/ipstats.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/ip/ipstats.c b/ip/ipstats.c
index f0f8dcdcbd2a9e1c83eed6ca54df28b91c058d9c..812a11dacb2f5851ea5d16644b82e8a7a0428e5a 100644
--- a/ip/ipstats.c
+++ b/ip/ipstats.c
@@ -1085,7 +1085,9 @@ static int ipstats_enable_check(struct ipstats_sel *sel,
return err;
}
-static int do_help(void)
+static void do_help(void) __attribute__((noreturn));
+
+static void do_help(void)
{
const struct ipstats_stat_desc *toplev = &ipstats_stat_desc_toplev_group;
int i;
@@ -1135,8 +1137,7 @@ static int do_help(void)
if (opened)
fprintf(stderr, " }\n");
}
-
- return 0;
+ exit(-1);
}
static int ipstats_select(struct ipstats_sel *old_sel,
@@ -1190,7 +1191,6 @@ static int ipstats_show(int argc, char **argv)
dev = *argv;
} else if (strcmp(*argv, "help") == 0) {
do_help();
- return 0;
} else {
bool found_level = false;
@@ -1209,8 +1209,6 @@ static int ipstats_show(int argc, char **argv)
if (!found_level) {
fprintf(stderr, "What is \"%s\"?\n", *argv);
do_help();
- err = -EINVAL;
- goto err;
}
}
@@ -1286,11 +1284,9 @@ static int ipstats_set(int argc, char **argv)
return err;
} else if (strcmp(*argv, "help") == 0) {
do_help();
- return 0;
} else {
fprintf(stderr, "What is \"%s\"?\n", *argv);
do_help();
- return -EINVAL;
}
NEXT_ARG_FWD();
@@ -1321,7 +1317,6 @@ int do_ipstats(int argc, char **argv)
rc = ipstats_show(0, NULL);
} else if (strcmp(*argv, "help") == 0) {
do_help();
- rc = 0;
} else if (strcmp(*argv, "show") == 0) {
/* Invoking "stats show" implies one -s. Passing -d adds one
* more -s.
---
base-commit: 218757a8b8bb431b382d7a104edb6ed4336d3b43
change-id: 20260301-ip-stats-exit-code-ce417579bcb6
Best regards,
--
Yedaya Katsman <yedaya.ka@gmail.com>
next reply other threads:[~2026-03-01 14:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 14:12 Yedaya Katsman [this message]
2026-03-01 18:36 ` [PATCH] ip: Make 'ip stats help' exit with -1 Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260301-ip-stats-exit-code-v1-1-2b59f0704f2c@gmail.com \
--to=yedaya.ka@gmail.com \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox