aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
Diffstat (limited to 'toys')
-rw-r--r--toys/lsb/killall.c5
-rw-r--r--toys/other/blockdev.c5
-rw-r--r--toys/other/help.c4
-rw-r--r--toys/other/ifconfig.c15
-rw-r--r--toys/other/losetup.c6
-rw-r--r--toys/other/lsattr.c19
-rw-r--r--toys/other/netcat.c8
-rw-r--r--toys/pending/brctl.c10
-rw-r--r--toys/pending/crontab.c11
-rw-r--r--toys/pending/dd.c5
-rw-r--r--toys/pending/fdisk.c12
-rw-r--r--toys/pending/groupadd.c6
-rw-r--r--toys/pending/ip.c36
-rw-r--r--toys/pending/ipcrm.c5
-rw-r--r--toys/pending/ipcs.c5
-rw-r--r--toys/pending/modprobe.c3
-rw-r--r--toys/pending/pgrep.c12
-rw-r--r--toys/pending/route.c29
-rw-r--r--toys/pending/tftpd.c5
-rw-r--r--toys/pending/useradd.c5
-rw-r--r--toys/posix/kill.c5
21 files changed, 67 insertions, 144 deletions
diff --git a/toys/lsb/killall.c b/toys/lsb/killall.c
index e8927559..3b316ecc 100644
--- a/toys/lsb/killall.c
+++ b/toys/lsb/killall.c
@@ -83,10 +83,7 @@ void killall_main(void)
}
}
- if (!(toys.optflags & FLAG_l) && !toys.optc) {
- toys.exithelp++;
- error_exit("no name");
- }
+ if (!(toys.optflags & FLAG_l) && !toys.optc) help_exit("no name");
TT.cur_pid = getpid();
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 {
diff --git a/toys/pending/brctl.c b/toys/pending/brctl.c
index e3b1526c..60178518 100644
--- a/toys/pending/brctl.c
+++ b/toys/pending/brctl.c
@@ -320,20 +320,14 @@ void brctl_main(void)
if (strcmp(t->cmd, *toys.optargs)) continue;
toys.optargs++, toys.optc--;
- if (toys.optc < t->nargs) {
- toys.exithelp++;
- error_exit("check args");
- }
+ if (toys.optc < t->nargs) help_exit("check args");
t->f(toys.optargs);
toys.optargs += t->nargs;
toys.optc -= t->nargs;
break;
}
- if (i == ARRAY_LEN(cc)) {
- toys.exithelp++;
- error_exit("invalid option '%s'", *toys.optargs);
- }
+ if (i == ARRAY_LEN(cc)) help_exit("invalid option '%s'", *toys.optargs);
}
xclose(TT.sockfd);
}
diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c
index 05c98f2b..67c8a543 100644
--- a/toys/pending/crontab.c
+++ b/toys/pending/crontab.c
@@ -346,20 +346,15 @@ void crontab_main(void)
if (!toys.optc) {
if (!FLAG_elr) {
- if (toys.optflags & FLAG_u) {
- toys.exithelp++;
- error_exit("file name must be specified for replace");
- }
+ if (toys.optflags & FLAG_u)
+ help_exit("file name must be specified for replace");
do_replace(pwd->pw_name);
}
else if (toys.optflags & FLAG_e) do_edit(pwd);
else if (toys.optflags & FLAG_l) do_list(pwd->pw_name);
else if (toys.optflags & FLAG_r) do_remove(pwd->pw_name);
} else {
- if (FLAG_elr) {
- toys.exithelp++;
- error_exit("no arguments permitted after this option");
- }
+ if (FLAG_elr) help_exit("no arguments permitted after this option");
do_replace(pwd->pw_name);
}
if (!(toys.optflags & FLAG_c)) free(TT.cdir);
diff --git a/toys/pending/dd.c b/toys/pending/dd.c
index 366d3c54..24d95657 100644
--- a/toys/pending/dd.c
+++ b/toys/pending/dd.c
@@ -297,10 +297,7 @@ void dd_main()
while (*toys.optargs) {
if (!(arg = strchr(*toys.optargs, '='))) error_exit("unknown arg %s", *toys.optargs);
*arg++ = '\0';
- if (!*arg) {
- toys.exithelp = 1;
- error_exit("");
- }
+ if (!*arg) help_exit(0);
key.name = *toys.optargs;
if (!(res = bsearch(&key, operands, ARRAY_LEN(operands), sizeof(struct pair),
comp))) error_exit("unknown arg %s", key.name);
diff --git a/toys/pending/fdisk.c b/toys/pending/fdisk.c
index 3ee9f598..d000c055 100644
--- a/toys/pending/fdisk.c
+++ b/toys/pending/fdisk.c
@@ -151,9 +151,9 @@ static void read_sec_sz()
if (ioctl(dev_fd, BLKSSZGET, &arg) == 0) g_sect_size = arg;
if (toys.optflags & FLAG_b) {
if (TT.sect_sz != 512 && TT.sect_sz != 1024 && TT.sect_sz != 2048 &&
- TT.sect_sz != 4096) {
- toys.exithelp++;
- error_exit("bad sector size");
+ TT.sect_sz != 4096)
+ {
+ help_exit("bad sector size");
}
g_sect_size = TT.sect_sz;
}
@@ -1486,11 +1486,7 @@ void fdisk_main(void)
toys.exitval = 0;
return;
} else {
- if (!toys.optc || toys.optc > 1 ) {
- toys.exitval = toys.exithelp = 1;
- show_help();
- return;
- }
+ if (toys.optc != 1) help_exit(stdout);
if (read_mbr(toys.optargs[0], 1)) return;
while (1) {
xputc('\n');
diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c
index 615c12f8..30468c94 100644
--- a/toys/pending/groupadd.c
+++ b/toys/pending/groupadd.c
@@ -62,10 +62,8 @@ void groupadd_main(void)
struct group *grp = NULL;
char *entry = NULL;
- if (toys.optflags && toys.optc == 2) {
- toys.exithelp = 1;
- error_exit("options, user and group can't be together");
- }
+ if (toys.optflags && toys.optc == 2)
+ help_exit("options, user and group can't be together");
if (toys.optc == 2) { //add user to group
//toys.optargs[0]- user, toys.optargs[1] - group
diff --git a/toys/pending/ip.c b/toys/pending/ip.c
index 9a01d953..90f73308 100644
--- a/toys/pending/ip.c
+++ b/toys/pending/ip.c
@@ -137,12 +137,6 @@ static char *idx_to_string(int idx, struct arglist *list)
return NULL;
}
-static void iphelp(void)
-{
- toys.exithelp = 1;
- error_exit(NULL);
-}
-
static void send_nlmesg(int type, int flags, int family,
void *buf, int blen)
{
@@ -519,16 +513,16 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size)
for (; *argv; argv++) {
int param, proto;
- if ((idx = substring_to_idx(*argv++, vlan_optlist)) == -1) iphelp();
+ if ((idx = substring_to_idx(*argv++, vlan_optlist)) == -1) help_exit(0);
switch (idx) {
case 0: // ARG_id
- if (!*argv) iphelp();
+ if (!*argv) help_exit(0);
param = atolx(*argv);
add_string_to_rtattr(n, size, IFLA_VLAN_ID, &param, sizeof(param));
break;
case 1: // ARG_protocol
if (!*argv) error_exit("Invalid vlan id.");
- if ((idx = substring_to_idx(*argv, vlan_protolist)) == -1) iphelp();
+ if ((idx = substring_to_idx(*argv, vlan_protolist)) == -1) help_exit(0);
if (!idx) proto = ETH_P_8021Q; // PROTO_8021Q - 0
else if (idx == 1) proto = 0x88A8; // ETH Protocol - 8021AD
// IFLA VLAN PROTOCOL - 5
@@ -536,7 +530,7 @@ static void vlan_parse_opt(char **argv, struct nlmsghdr *n, unsigned int size)
break;
case 2: // ARG_reorder_hdr
case 3: // ARG_gvrp
- if ((param = substring_to_idx(*argv, on_off)) == -1) iphelp();
+ if ((param = substring_to_idx(*argv, on_off)) == -1) help_exit(0);
flags.mask |= (idx -1); // VLAN FLAG REORDER Header
flags.flags &= ~(idx -1); // VLAN FLAG REORDER Header
@@ -650,7 +644,7 @@ static int link_set(char **argv)
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
xioctl(fd, SIOCGIFINDEX, &req);
for (++argv; *argv;) {
- if ((idx = substring_to_idx(*argv++, cmd_objectlist)) == -1) iphelp();
+ if ((idx = substring_to_idx(*argv++, cmd_objectlist)) == -1) help_exit(0);
switch(idx) {
case 0:
flags |= IFF_UP; break;
@@ -659,7 +653,7 @@ static int link_set(char **argv)
case 2:
case 3:
case 4:
- if (!*argv) iphelp();
+ if (!*argv) help_exit(0);
else if (!strcmp(*argv, "on")) {
if (idx == 2) {
masks &= ~case_flags[idx-2];
@@ -670,7 +664,7 @@ static int link_set(char **argv)
masks |= case_flags[idx-2];
flags |= case_flags[idx-2];
} else masks &= ~case_flags[idx-2];
- } else iphelp();
+ } else help_exit(0);
++argv;
break;
case 5:
@@ -941,7 +935,8 @@ static int iplink(char **argv)
{"set", 1}, {"show", 2}, {"list", 2}, {"lst", 2}, {NULL,-1}};
if (!*argv) idx = 2;
- else if ((idx = substring_to_idx(*argv++, cmd_objectlist)) == -1) iphelp();
+ else if ((idx = substring_to_idx(*argv++, cmd_objectlist)) == -1)
+ help_exit(0);
ipcmd = cmdobjlist[idx];
return ipcmd(argv);
}
@@ -1431,7 +1426,8 @@ static int ipaddr(char **argv)
TT.is_addr++;
if (!*argv) idx = 1;
- else if ((idx = substring_to_idx(*argv++, cmd_objectlist)) == -1) iphelp();
+ else if ((idx = substring_to_idx(*argv++, cmd_objectlist)) == -1)
+ help_exit(0);
ipcmd = cmdobjlist[idx];
return ipcmd(argv);
@@ -2757,7 +2753,7 @@ void ip_main(void)
struct arglist ip_aflist[] = {{"inet", AF_INET},
{"inet6", AF_INET6}, {"link", AF_PACKET}, {NULL, -1}};
- if (!*++optargv) iphelp();
+ if (!*++optargv) help_exit(0);
if ((TT.addressfamily = string_to_idx(*optargv, ip_aflist)) == -1)
error_exit("wrong family '%s'", *optargv);
}
@@ -2766,7 +2762,7 @@ void ip_main(void)
case 2:
TT.stats++;
break;
- default: iphelp();
+ default: help_exit(0);
break; // unreachable code.
}
}
@@ -2778,15 +2774,15 @@ void ip_main(void)
struct arglist ip_objectlist[] = { {"address", 0}, {"link", 1},
{"route", 2}, {"rule", 3}, {"tunnel", 4}, {"tunl", 4}, {NULL, -1}};
- if ((idx = substring_to_idx(*optargv, ip_objectlist)) == -1) iphelp();
+ if ((idx = substring_to_idx(*optargv, ip_objectlist)) == -1) help_exit(0);
ipcmd = cmdobjlist[idx];
toys.exitval = ipcmd(++optargv);
- } else iphelp();
+ } else help_exit(0);
} else {
struct arglist ip_objectlist[] = { {"ipaddr", 0}, {"iplink", 1},
{"iproute", 2}, {"iprule", 3}, {"iptunnel", 4}, {NULL, -1}};
if ((idx = string_to_idx(toys.which->name, ip_objectlist)) == -1)
- iphelp();
+ help_exit(0);
ipcmd = cmdobjlist[idx];
toys.exitval = ipcmd(optargv);
}
diff --git a/toys/pending/ipcrm.c b/toys/pending/ipcrm.c
index 21f436d3..cec1b12f 100644
--- a/toys/pending/ipcrm.c
+++ b/toys/pending/ipcrm.c
@@ -83,9 +83,6 @@ void ipcrm_main(void)
for (tmp = TT.qid; tmp; tmp = tmp->next) do_ipcrm(0, 2, tmp->arg);
for (tmp = TT.skey; tmp; tmp = tmp->next) do_ipcrm(1, 3, tmp->arg);
for (tmp = TT.sid; tmp; tmp = tmp->next) do_ipcrm(0, 3, tmp->arg);
- if (toys.optc) {
- toys.exithelp++;
- error_exit("unknown argument: %s", *toys.optargs);
- }
+ if (toys.optc) help_exit("unknown argument: %s", *toys.optargs);
}
}
diff --git a/toys/pending/ipcs.c b/toys/pending/ipcs.c
index d974a519..b5986af7 100644
--- a/toys/pending/ipcs.c
+++ b/toys/pending/ipcs.c
@@ -425,10 +425,7 @@ void ipcs_main(void)
if (flag(m)) show_shm_id();
else if (flag(s)) show_sem_id();
else if (flag(q)) show_msg_id();
- else {
- toys.exithelp++;
- error_exit(NULL);
- }
+ else help_exit(0);
return;
}
diff --git a/toys/pending/modprobe.c b/toys/pending/modprobe.c
index 07c53fc2..6813dec3 100644
--- a/toys/pending/modprobe.c
+++ b/toys/pending/modprobe.c
@@ -495,8 +495,7 @@ void modprobe_main(void)
if ((toys.optc < 1) && (((flags & FLAG_r) && (flags & FLAG_l))
||(!((flags & FLAG_r)||(flags & FLAG_l)))))
{
- toys.exithelp++;
- error_exit("bad syntax");
+ help_exit("bad syntax");
}
// Check for -r flag without arg if yes then do auto remove.
if ((flags & FLAG_r) && !toys.optc) {
diff --git a/toys/pending/pgrep.c b/toys/pending/pgrep.c
index 59767b9f..9117a6d5 100644
--- a/toys/pending/pgrep.c
+++ b/toys/pending/pgrep.c
@@ -91,14 +91,10 @@ void pgrep_main(void)
error_exit("Unknown signal '%s'", arg);
} else signum = SIGTERM;
}
- if (!(flag_chk(FLAG_s) || flag_chk(FLAG_P)) && !*toys.optargs) {
- toys.exithelp++;
- error_exit("missing argument");
- }
- if (*(toys.optargs+1) && !(flag_chk(FLAG_s) || flag_chk(FLAG_P))) {
- toys.exithelp++;
- error_exit("max argument > 1");
- }
+ if (!(flag_chk(FLAG_s) || flag_chk(FLAG_P)) && !*toys.optargs)
+ help_exit("missing argument");
+ if (*(toys.optargs+1) && !(flag_chk(FLAG_s) || flag_chk(FLAG_P)))
+ help_exit("max argument > 1");
if (*toys.optargs) { /* compile regular expression(PATTERN) */
if ((eval = regcomp(&rp, *toys.optargs, REG_EXTENDED | REG_NOSUB)) != 0) {
char errbuf[256];
diff --git a/toys/pending/route.c b/toys/pending/route.c
index ac1bbef5..02b59cfb 100644
--- a/toys/pending/route.c
+++ b/toys/pending/route.c
@@ -32,7 +32,7 @@ GLOBALS(
#define INVALID_ADDR 0xffffffffUL
#define IPV6_ADDR_LEN 40 //32 + 7 (':') + 1 ('\0')
-#define TEST_ARGV(argv) if (!*argv) show_route_help()
+#define TEST_ARGV(argv) if (!*argv) help_exit(0)
struct _arglist {
char *arg;
@@ -49,13 +49,6 @@ static struct _arglist arglist2[] = {
{ NULL, 0 }
};
-// display help info and exit.
-static void show_route_help(void)
-{
- toys.exithelp = 1;
- error_exit("Invalid Argument");
-}
-
// to get the host name from the given ip.
static int get_hostname(char *ipstr, struct sockaddr_in *sockin)
{
@@ -205,7 +198,7 @@ static void get_next_params(char **argv, struct rtentry *rt, char **netmask)
//when adding a network route, the netmask to be used.
struct sockaddr sock;
unsigned int addr_mask = (((struct sockaddr_in *)&((rt)->rt_genmask))->sin_addr.s_addr);
- if (addr_mask) show_route_help();
+ if (addr_mask) help_exit("dup netmask");
argv++;
TEST_ARGV(argv);
*netmask = *argv;
@@ -224,7 +217,7 @@ static void get_next_params(char **argv, struct rtentry *rt, char **netmask)
argv++;
} else if (ishost < 0) perror_exit("resolving '%s'", *argv);
else perror_exit("gateway '%s' is a NETWORK", *argv);
- } else show_route_help();
+ } else help_exit("dup gw");
} else if (!strcmp(*argv, "mss")) {
//set the TCP Maximum Segment Size for connections over this route.
argv++;
@@ -265,7 +258,7 @@ static void get_next_params(char **argv, struct rtentry *rt, char **netmask)
} else if (!strcmp(*argv, "reinstate")) {
rt->rt_flags |= RTF_REINSTATE;
argv++;
- } else show_route_help(); //No match found; exit form the application.
+ } else help_exit("no '%s'", *argv); //No match found; exit form the application.
}//end of while loop.
if (!rt->rt_dev && (rt->rt_flags & RTF_REJECT)) rt->rt_dev = (char *)"lo";
@@ -295,10 +288,10 @@ static void setroute(char **argv)
int is_net_or_host = 0, sokfd, arg2_action;
int action = get_action(&argv, arglist1); //verify the arg for add/del.
- if (!action || !*argv) show_route_help();
+ if (!action || !*argv) help_exit("setroute");
arg2_action = get_action(&argv, arglist2); //verify the arg for -net or -host
- if (!*argv) show_route_help();
+ if (!*argv) help_exit("setroute");
memset(&rt, 0, sizeof(struct rtentry));
targetip = *argv++;
@@ -364,7 +357,7 @@ static void get_next_params_inet6(char **argv, struct sockaddr_in6 *sock_in6, st
rt->rtmsg_flags |= RTF_GATEWAY;
argv++;
} else perror_exit("resolving '%s'", *argv);
- } else show_route_help();
+ } else help_exit(0);
} else if (!strcmp(*argv, "dev")) {
argv++;
TEST_ARGV(argv);
@@ -376,7 +369,7 @@ static void get_next_params_inet6(char **argv, struct sockaddr_in6 *sock_in6, st
} else if (!strcmp(*argv, "dyn")) {
rt->rtmsg_flags |= RTF_DYNAMIC;
argv++;
- } else show_route_help();
+ } else help_exit(0);
}//end of while loop.
}
@@ -388,7 +381,7 @@ static void setroute_inet6(char **argv)
char *targetip;
int sockfd, action = get_action(&argv, arglist1);
- if (!action || !*argv) show_route_help();
+ if (!action || !*argv) help_exit(0);
memset(&sock_in6, 0, sizeof(struct sockaddr_in6));
memset(&rt, 0, sizeof(struct in6_rtmsg));
targetip = *argv++;
@@ -418,7 +411,7 @@ static void setroute_inet6(char **argv)
if (action == 1) xioctl(sockfd, SIOCADDRT, &rt);
else xioctl(sockfd, SIOCDELRT, &rt);
xclose(sockfd);
- } else show_route_help();
+ } else help_exit(0);
}
/*
@@ -489,7 +482,7 @@ void route_main(void)
if (!*toys.optargs) {
if (!strcmp(TT.family, "inet")) display_routes();
else if (!strcmp(TT.family, "inet6")) display_routes6();
- else show_route_help();
+ else help_exit(0);
return;
}//End of if statement.
diff --git a/toys/pending/tftpd.c b/toys/pending/tftpd.c
index 31af44be..806326eb 100644
--- a/toys/pending/tftpd.c
+++ b/toys/pending/tftpd.c
@@ -242,10 +242,7 @@ void tftpd_main(void)
char *buf = toybuf;
memset(&srcaddr, 0, sizeof(srcaddr));
- if (getsockname(0, (struct sockaddr *)&srcaddr, &socklen)) {
- toys.exithelp = 1;
- error_exit(NULL);
- }
+ if (getsockname(0, (struct sockaddr *)&srcaddr, &socklen)) help_exit(0);
if (TT.user) TT.pw = xgetpwnam(TT.user);
if (*toys.optargs) xchroot(*toys.optargs);
diff --git a/toys/pending/useradd.c b/toys/pending/useradd.c
index 4d4c671e..d0ad03ab 100644
--- a/toys/pending/useradd.c
+++ b/toys/pending/useradd.c
@@ -46,10 +46,7 @@ void useradd_main(void)
// Act like groupadd?
if (toys.optc == 2) {
- if (toys.optflags) {
- toys.exithelp = 1;
- error_exit("options with USER GROUP");
- }
+ if (toys.optflags) help_exit("options with USER GROUP");
xexec((char *[]){"groupadd", toys.optargs[0], toys.optargs[1], 0});
}
diff --git a/toys/posix/kill.c b/toys/posix/kill.c
index 72113878..3fcd36a1 100644
--- a/toys/posix/kill.c
+++ b/toys/posix/kill.c
@@ -136,10 +136,7 @@ void kill_main(void)
} else {
// "<1" in optstr wouldn't cover this because "-SIGNAL"
- if (!*args) {
- toys.exithelp++;
- error_exit("missing argument");
- }
+ if (!*args) help_exit("missing argument");
while (*args) {
char *arg = *(args++);