use missing argument helper
Subsystems (2)
PATCH 1/1 use missing argument helper
There is a helper in utilities to handle missing argument, but it was not being used consistently.
Signed-off-by Stephen Hemminger <[email protected]>
--- 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(-)
ip/ip.c +5 -5
@@ -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 ]);
ip/iproute_lwtunnel.c +2 -5
@@ -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) {
ip/rtmon.c +2 -2
@@ -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 ;
tc/f_u32.c +1 -1
@@ -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" );
tc/m_sample.c +2 -5
@@ -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 ();
tc/tc.c +1 -1
@@ -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 ();
Signature · 1 line
2.43.0
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Hello:
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Quoted 4 lines · 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 <[email protected]>
Quoted 8 lines
--- 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html