diff options
Diffstat (limited to 'toys/other')
-rw-r--r-- | toys/other/blockdev.c | 5 | ||||
-rw-r--r-- | toys/other/help.c | 4 | ||||
-rw-r--r-- | toys/other/ifconfig.c | 15 | ||||
-rw-r--r-- | toys/other/losetup.c | 6 | ||||
-rw-r--r-- | toys/other/lsattr.c | 19 | ||||
-rw-r--r-- | toys/other/netcat.c | 8 |
6 files changed, 17 insertions, 40 deletions
diff --git a/toys/other/blockdev.c b/toys/other/blockdev.c index 79b4d6f9..e5a504e6 100644 --- a/toys/other/blockdev.c +++ b/toys/other/blockdev.c @@ -43,10 +43,7 @@ void blockdev_main(void) char **ss; long long val = 0; - if (!toys.optflags) { - toys.exithelp = 1; - error_exit("need --option"); - } + if (!toys.optflags) help_exit("need --option"); for (ss = toys.optargs; *ss; ss++) { int fd = xopen(*ss, O_RDONLY), i; diff --git a/toys/other/help.c b/toys/other/help.c index 15f8271e..4722528c 100644 --- a/toys/other/help.c +++ b/toys/other/help.c @@ -37,12 +37,12 @@ static void do_help(struct toy_list *t) xprintf("<a name=\"%s\"><h1>%s</h1><blockquote><pre>\n", t->name, t->name); toys.which = t; - show_help(); + show_help(stdout); if (toys.optflags & FLAG_h) xprintf("</blockquote></pre>\n"); } -// The simple help is just toys.which = toy_find("name"); show_help(); +// The simple help is just toys.which = toy_find("name"); show_help(stdout); // But iterating through html output and all commands is a big more void help_main(void) diff --git a/toys/other/ifconfig.c b/toys/other/ifconfig.c index 948043e2..bfd9a306 100644 --- a/toys/other/ifconfig.c +++ b/toys/other/ifconfig.c @@ -403,10 +403,7 @@ void ifconfig_main(void) p = ptr = toybuf; } } - if (!sock->sa_family || !argv[1]) { - toys.exithelp++; - error_exit("bad hw '%s'", *argv); - } + if (!sock->sa_family || !argv[1]) help_exit("bad hw '%s'", *argv); hw_addr = *++argv; // Parse and verify address. @@ -447,10 +444,7 @@ void ifconfig_main(void) } ifre6; int plen, fd6 = xsocket(AF_INET6, SOCK_DGRAM, 0); - if (!argv[1]) { - toys.exithelp++; - error_exit("%s", *argv); - } + if (!argv[1]) help_exit("%s", *argv); plen = get_addrinfo(argv[1], AF_INET6, &ifre6.addr); if (plen < 0) plen = 128; @@ -517,10 +511,7 @@ void ifconfig_main(void) break; } - if (i == sizeof(try)/sizeof(*try)) { - toys.exithelp++; - error_exit("bad argument '%s'", *argv); - } + if (i == sizeof(try)/sizeof(*try)) help_exit("bad argument '%s'", *argv); } close(TT.sockfd); } diff --git a/toys/other/losetup.c b/toys/other/losetup.c index 9568627e..a40d9e42 100644 --- a/toys/other/losetup.c +++ b/toys/other/losetup.c @@ -180,10 +180,8 @@ void losetup_main(void) } else { char *file = (toys.optflags & (FLAG_d|FLAG_c)) ? NULL : toys.optargs[1]; - if (!toys.optc || (file && toys.optc != 2)) { - toys.exithelp++; - perror_exit("needs %d arg%s", 1+!!file, file ? "s" : ""); - } + if (!toys.optc || (file && toys.optc != 2)) + help_exit("needs %d arg%s", 1+!!file, file ? "s" : ""); for (s = toys.optargs; *s; s++) { loopback_setup(*s, file); if (file) break; diff --git a/toys/other/lsattr.c b/toys/other/lsattr.c index 39945ef0..ceb14bdf 100644 --- a/toys/other/lsattr.c +++ b/toys/other/lsattr.c @@ -186,12 +186,6 @@ static struct _chattr { unsigned char vflag, recursive; } chattr; -static inline void chattr_help(void) -{ - toys.exithelp++; - error_exit("Invalid Argument"); -} - // Set file flags on a Linux second extended file system. static inline int ext2_setflag(int fd, struct stat *sb, unsigned long flag) { @@ -208,8 +202,7 @@ static unsigned long get_flag_val(char ch) for (; ptr->name; ptr++) if (ptr->opt == ch) return ptr->flag; - chattr_help(); // if no match found then Show help - return 0; // silent warning. + help_exit("bad '%c'", ch); } // Parse command line argument and fill the chattr structure. @@ -229,7 +222,7 @@ static void parse_cmdline_arg(char ***argv) errno = 0; arg = *(*argv += 1); - if (!arg) chattr_help(); + if (!arg) help_exit("bad -v"); if (*arg == '-') perror_exit("Invalid Number '%s'", arg); chattr.version = strtoul(arg, &endptr, 0); if (errno || *endptr) perror_exit("bad version '%s'", arg); @@ -309,12 +302,12 @@ void chattr_main(void) memset(&chattr, 0, sizeof(struct _chattr)); parse_cmdline_arg(&argv); - if (!*argv) chattr_help(); + if (!*argv) help_exit("no file"); if (chattr.set && (chattr.add || chattr.rm)) - error_exit("'=' is incompatible with '-' and '+'"); - if (chattr.rm & chattr.add) error_exit("Can't set and unset same flag."); + error_exit("no '=' with '-' or '+'"); + if (chattr.rm & chattr.add) error_exit("set/unset same flag"); if (!(chattr.add || chattr.rm || chattr.set || chattr.vflag)) - error_exit(("Must use '-v', '=', '-' or '+'")); + error_exit("need '-v', '=', '-' or '+'"); for (; *argv; argv++) dirtree_read(*argv, update_attr); toys.exitval = 0; //always set success at this point. } diff --git a/toys/other/netcat.c b/toys/other/netcat.c index 9d0c3cf3..3cc3f0a0 100644 --- a/toys/other/netcat.c +++ b/toys/other/netcat.c @@ -91,11 +91,9 @@ void netcat_main(void) // The argument parsing logic can't make "<2" conditional on other // arguments like -f and -l, so we do it by hand here. - if (toys.optflags&FLAG_f) { - if (toys.optc) toys.exithelp++; - } else if (!(toys.optflags&(FLAG_l|FLAG_L)) && toys.optc!=2) toys.exithelp++; - - if (toys.exithelp) error_exit("Argument count wrong"); + if ((toys.optflags&FLAG_f) ? toys.optc : + (!(toys.optflags&(FLAG_l|FLAG_L)) && toys.optc!=2)) + help_exit("Argument count wrong"); if (TT.filename) pollfds[0].fd = xopen(TT.filename, O_RDWR); else { |