@@ -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]);
@@ -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) {
@@ -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;
@@ -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");
@@ -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();
@@ -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();
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(-)