diff mbox series

[iproute2] use missing argument helper

Message ID 20240423160652.68304-1-stephen@networkplumber.org (mailing list archive)
State Accepted
Commit 911c62bf9de61da7aa03e1cd5e5db26322d12aa9
Delegated to: David Ahern
Headers show
Series [iproute2] use missing argument helper | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stephen Hemminger April 23, 2024, 4:05 p.m. UTC
There is a helper in utilities to handle missing argument,
but it was not being used consistently.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 ip/ip.c               | 10 +++++-----
 ip/iproute_lwtunnel.c |  7 ++-----
 ip/rtmon.c            |  4 ++--
 tc/f_u32.c            |  2 +-
 tc/m_sample.c         |  7 ++-----
 tc/tc.c               |  2 +-
 6 files changed, 13 insertions(+), 19 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 25, 2024, 7:10 p.m. UTC | #1
Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Tue, 23 Apr 2024 09:05:43 -0700 you wrote:
> There is a helper in utilities to handle missing argument,
> but it was not being used consistently.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  ip/ip.c               | 10 +++++-----
>  ip/iproute_lwtunnel.c |  7 ++-----
>  ip/rtmon.c            |  4 ++--
>  tc/f_u32.c            |  2 +-
>  tc/m_sample.c         |  7 ++-----
>  tc/tc.c               |  2 +-
>  6 files changed, 13 insertions(+), 19 deletions(-)

Here is the summary with links:
  - [iproute2] use missing argument helper
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=911c62bf9de6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/ip/ip.c b/ip/ip.c
index e51fa206..eb492139 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -203,15 +203,15 @@  int main(int argc, char **argv)
 			argc--;
 			argv++;
 			if (argc <= 1)
-				usage();
+				missarg("loop count");
 			max_flush_loops = atoi(argv[1]);
 		} else if (matches(opt, "-family") == 0) {
 			argc--;
 			argv++;
 			if (argc <= 1)
-				usage();
+				missarg("family type");
 			if (strcmp(argv[1], "help") == 0)
-				usage();
+				do_help(argc, argv);
 			else
 				preferred_family = read_family(argv[1]);
 			if (preferred_family == AF_UNSPEC)
@@ -258,7 +258,7 @@  int main(int argc, char **argv)
 			argc--;
 			argv++;
 			if (argc <= 1)
-				usage();
+				missarg("batch file");
 			batch_file = argv[1];
 		} else if (matches(opt, "-brief") == 0) {
 			++brief;
@@ -272,7 +272,7 @@  int main(int argc, char **argv)
 			argc--;
 			argv++;
 			if (argc <= 1)
-				usage();
+				missarg("rcvbuf size");
 			if (get_unsigned(&size, argv[1], 0)) {
 				fprintf(stderr, "Invalid rcvbuf size '%s'\n",
 					argv[1]);
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 94985972..b4df4348 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -2228,11 +2228,8 @@  int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp,
 		invarg("\"encap type\" value is invalid\n", *argv);
 
 	NEXT_ARG();
-	if (argc <= 1) {
-		fprintf(stderr,
-			"Error: unexpected end of line after \"encap\"\n");
-		exit(-1);
-	}
+	if (argc <= 1)
+		missarg("encap type");
 
 	nest = rta_nest(rta, len, encap_attr);
 	switch (type) {
diff --git a/ip/rtmon.c b/ip/rtmon.c
index aad9968f..08105d68 100644
--- a/ip/rtmon.c
+++ b/ip/rtmon.c
@@ -82,7 +82,7 @@  main(int argc, char **argv)
 			argc--;
 			argv++;
 			if (argc <= 1)
-				usage();
+				missarg("family type");
 			if (strcmp(argv[1], "inet") == 0)
 				family = AF_INET;
 			else if (strcmp(argv[1], "inet6") == 0)
@@ -108,7 +108,7 @@  main(int argc, char **argv)
 			argc--;
 			argv++;
 			if (argc <= 1)
-				usage();
+				missarg("file");
 			file = argv[1];
 		} else if (matches(argv[1], "link") == 0) {
 			llink = 1;
diff --git a/tc/f_u32.c b/tc/f_u32.c
index a0699636..d7679e7a 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c
@@ -663,7 +663,7 @@  static int parse_mark(int *argc_p, char ***argv_p, struct nlmsghdr *n)
 	struct tc_u32_mark mark;
 
 	if (argc <= 1)
-		return -1;
+		missarg("mark");
 
 	if (get_u32(&mark.val, *argv, 0)) {
 		fprintf(stderr, "Illegal \"mark\" value\n");
diff --git a/tc/m_sample.c b/tc/m_sample.c
index 642ec3a6..3baf1d55 100644
--- a/tc/m_sample.c
+++ b/tc/m_sample.c
@@ -45,11 +45,8 @@  static int parse_sample(const struct action_util *a, int *argc_p, char ***argv_p
 	__u32 group;
 	__u32 rate;
 
-	if (argc <= 1) {
-		fprintf(stderr, "sample bad argument count %d\n", argc);
-		usage();
-		return -1;
-	}
+	if (argc <= 1)
+		missarg("sample count");
 
 	if (matches(*argv, "sample") == 0) {
 		NEXT_ARG();
diff --git a/tc/tc.c b/tc/tc.c
index 7edff7e3..26e6f69c 100644
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -289,7 +289,7 @@  int main(int argc, char **argv)
 		} else if (matches(argv[1], "-batch") == 0) {
 			argc--;	argv++;
 			if (argc <= 1)
-				usage();
+				missarg("batch file");
 			batch_file = argv[1];
 		} else if (matches(argv[1], "-netns") == 0) {
 			NEXT_ARG();