Blame SOURCES/net-tools-correct-exit-code.patch

aff40f
diff --git a/netstat.c b/netstat.c
aff40f
index 847c0dc..8dd2f29 100644
aff40f
--- a/netstat.c
aff40f
+++ b/netstat.c
aff40f
@@ -2061,7 +2061,7 @@ static void version(void)
aff40f
 }
aff40f
 
aff40f
 
aff40f
-static void usage(void)
aff40f
+static void usage(int rc)
aff40f
 {
aff40f
     fprintf(stderr, _("usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}\n"));
aff40f
     fprintf(stderr, _("       netstat [-vWnNcaeol] [<Socket> ...]\n"));
aff40f
@@ -2100,7 +2100,7 @@ static void usage(void)
aff40f
     fprintf(stderr, _("  <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF);
aff40f
     fprintf(stderr, _("  List of possible address families (which support routing):\n"));
aff40f
     print_aflist(1); /* 1 = routeable */
aff40f
-    exit(E_USAGE);
aff40f
+    exit(rc);
aff40f
 }
aff40f
 
aff40f
 
aff40f
@@ -2292,20 +2292,21 @@ int main
aff40f
 
aff40f
 	    break;
aff40f
 	case '?':
aff40f
+	    usage(E_OPTERR);
aff40f
 	case 'h':
aff40f
-	    usage();
aff40f
+	    usage(E_USAGE);
aff40f
 	case 's':
aff40f
 	    flag_sta++;
aff40f
 	}
aff40f
 
aff40f
     if(argc == optind + 1) {
aff40f
       if((reptimer = atoi(argv[optind])) <= 0)
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
       flag_cnt++;
aff40f
     }
aff40f
     
aff40f
     if (flag_int + flag_rou + flag_mas + flag_sta > 1)
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
 
aff40f
     if ((flag_inet || flag_inet6 || flag_sta) &&
aff40f
         !(flag_tcp || flag_sctp || flag_udp || flag_udplite || flag_raw))
aff40f
diff --git a/arp.c b/arp.c
aff40f
index 5db71a7..30dd56d 100644
aff40f
--- a/arp.c
aff40f
+++ b/arp.c
aff40f
@@ -93,7 +93,7 @@ struct hwtype *hw;		/* current hardware type        */
aff40f
 int sockfd = 0;			/* active socket descriptor     */
aff40f
 int hw_set = 0;			/* flag if hw-type was set (-H) */
aff40f
 char device[16] = "";		/* current device               */
aff40f
-static void usage(void);
aff40f
+static void usage(int rc);
aff40f
 
aff40f
 /* Delete an entry from the ARP cache. */
aff40f
 static int arp_del(char **args)
aff40f
@@ -169,14 +169,14 @@ static int arp_del(char **args)
aff40f
 	}
aff40f
 	if (!strcmp(*args, "dev")) {
aff40f
 	    if (*++args == NULL)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	    safe_strncpy(device, *args, sizeof(device));
aff40f
 	    args++;
aff40f
 	    continue;
aff40f
 	}
aff40f
 	if (!strcmp(*args, "netmask")) {
aff40f
 	    if (*++args == NULL)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	    if (strcmp(*args, "255.255.255.255") != 0) {
aff40f
 		safe_strncpy(host, *args, (sizeof host));
aff40f
 		if (ap->input(0, host, sa) < 0) {
aff40f
@@ -190,7 +190,7 @@ static int arp_del(char **args)
aff40f
 	    args++;
aff40f
 	    continue;
aff40f
 	}
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
     }
aff40f
 
aff40f
     // if neighter priv nor pub is given, work on both
aff40f
@@ -346,14 +346,14 @@ static int arp_set(char **args)
aff40f
 	}
aff40f
 	if (!strcmp(*args, "dev")) {
aff40f
 	    if (*++args == NULL)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	    safe_strncpy(device, *args, sizeof(device));
aff40f
 	    args++;
aff40f
 	    continue;
aff40f
 	}
aff40f
 	if (!strcmp(*args, "netmask")) {
aff40f
 	    if (*++args == NULL)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	    if (strcmp(*args, "255.255.255.255") != 0) {
aff40f
 		safe_strncpy(host, *args, (sizeof host));
aff40f
 		if (ap->input(0, host, sa) < 0) {
aff40f
@@ -367,7 +367,7 @@ static int arp_set(char **args)
aff40f
 	    args++;
aff40f
 	    continue;
aff40f
 	}
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
     }
aff40f
 
aff40f
     /* Fill in the remainder of the request. */
aff40f
@@ -621,7 +621,7 @@ static void version(void)
aff40f
     exit(E_VERSION);
aff40f
 }
aff40f
 
aff40f
-static void usage(void)
aff40f
+static void usage(int rc)
aff40f
 {
aff40f
     fprintf(stderr, _("Usage:\n  arp [-vn]  [<HW>] [-i <if>] [-a] [<hostname>]             <-Display ARP cache\n"));
aff40f
     fprintf(stderr, _("  arp [-v]          [-i <if>] -d  <host> [pub]               <-Delete ARP entry\n"));
aff40f
@@ -643,7 +643,7 @@ static void usage(void)
aff40f
     fprintf(stderr, _("  <HW>=Use '-H <hw>' to specify hardware address type. Default: %s\n"), DFLT_HW);
aff40f
     fprintf(stderr, _("  List of possible hardware types (which support ARP):\n"));
aff40f
     print_hwlist(1); /* 1 = ARPable */
aff40f
-    exit(E_USAGE);
aff40f
+    exit(rc);
aff40f
 }
aff40f
 
aff40f
 int main(int argc, char **argv)
aff40f
@@ -745,10 +745,11 @@ int main(int argc, char **argv)
aff40f
 
aff40f
 	case 'V':
aff40f
 	    version();
aff40f
-	case '?':
aff40f
 	case 'h':
aff40f
+	    usage(E_USAGE);
aff40f
+	case '?':
aff40f
 	default:
aff40f
-	    usage();
aff40f
+	    usage(E_OPTERR);
aff40f
 	}
aff40f
 
aff40f
     if (ap->af != AF_INET) {
aff40f
@@ -797,7 +798,7 @@ int main(int argc, char **argv)
aff40f
 	break;
aff40f
 
aff40f
     default:
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
     }
aff40f
 
aff40f
     exit(what);
aff40f
diff --git a/ipmaddr.c b/ipmaddr.c
aff40f
index e4ed41d..c45b62a 100644
aff40f
--- a/ipmaddr.c
aff40f
+++ b/ipmaddr.c
aff40f
@@ -53,14 +53,14 @@ static void version(void)
aff40f
 	exit(E_VERSION);
aff40f
 }
aff40f
 
aff40f
-static void usage(void) __attribute__((noreturn));
aff40f
+static void usage(int rc) __attribute__((noreturn));
aff40f
 
aff40f
-static void usage(void)
aff40f
+static void usage(int rc)
aff40f
 {
aff40f
 	fprintf(stderr, _("Usage: ipmaddr [ add | del ] MULTIADDR dev STRING\n"));
aff40f
 	fprintf(stderr, _("       ipmaddr show [ dev STRING ] [ ipv4 | ipv6 | link | all ]\n"));
aff40f
 	fprintf(stderr, _("       ipmaddr -V | -version\n"));
aff40f
-	exit(E_USAGE);
aff40f
+	exit(rc);
aff40f
 }
aff40f
 
aff40f
 static void print_lla(FILE *fp, int len, unsigned char *addr)
aff40f
@@ -294,7 +294,7 @@ static int multiaddr_list(int argc, char **argv)
aff40f
 			NEXT_ARG();
aff40f
 			l = strlen(*argv);
aff40f
 			if (l <= 0 || l >= sizeof(filter_dev))
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			strncpy(filter_dev, *argv, sizeof (filter_dev));
aff40f
 		} else if (strcmp(*argv, "all") == 0) {
aff40f
 			filter_family = AF_UNSPEC;
aff40f
@@ -307,7 +307,7 @@ static int multiaddr_list(int argc, char **argv)
aff40f
 		} else {
aff40f
 			l = strlen(*argv);
aff40f
 			if (l <= 0 || l >= sizeof(filter_dev))
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			strncpy(filter_dev, *argv, sizeof (filter_dev));
aff40f
 		}
aff40f
 		argv++; argc--;
aff40f
@@ -339,18 +339,18 @@ int multiaddr_modify(int cmd, int argc, char **argv)
aff40f
 		if (strcmp(*argv, "dev") == 0) {
aff40f
 			NEXT_ARG();
aff40f
 			if (ifr.ifr_name[0])
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
aff40f
 		} else {
aff40f
 			if (ifr.ifr_hwaddr.sa_data[0])
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			if (parse_lla(*argv, ifr.ifr_hwaddr.sa_data) < 0)
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 		}
aff40f
 		argc--; argv++;
aff40f
 	}
aff40f
 	if (ifr.ifr_name[0] == 0)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 
aff40f
 	fd = socket(AF_INET, SOCK_DGRAM, 0);
aff40f
 	if (fd < 0) {
aff40f
@@ -378,7 +378,7 @@ int do_multiaddr(int argc, char **argv)
aff40f
 	if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0
aff40f
 	    || matches(*argv, "lst") == 0)
aff40f
 		return multiaddr_list(argc-1, argv+1);
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
 }
aff40f
 
aff40f
 int preferred_family = AF_UNSPEC;
aff40f
@@ -408,13 +408,13 @@ int main(int argc, char **argv)
aff40f
 			argc--;
aff40f
 			argv++;
aff40f
 			if (argc <= 1)
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			if (strcmp(argv[1], "inet") == 0)
aff40f
 				preferred_family = AF_INET;
aff40f
 			else if (strcmp(argv[1], "inet6") == 0)
aff40f
 				preferred_family = AF_INET6;
aff40f
 			else
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 		} else if (matches(argv[1], "-stats") == 0 ||
aff40f
 			   matches(argv[1], "-statistics") == 0) {
aff40f
 			++show_stats;
aff40f
@@ -423,7 +423,7 @@ int main(int argc, char **argv)
aff40f
 		} else if ((matches(argv[1], "-V") == 0) || matches(argv[1], "--version") == 0) {
aff40f
 			version();
aff40f
 		} else
aff40f
-			usage();
aff40f
+			usage(E_OPTERR);
aff40f
 		argc--;	argv++;
aff40f
 	}
aff40f
 
aff40f
diff --git a/include/util-ank.h b/include/util-ank.h
aff40f
index c8fcd08..c78604a 100644
aff40f
--- a/include/util-ank.h
aff40f
+++ b/include/util-ank.h
aff40f
@@ -23,7 +23,7 @@ extern int resolve_hosts;
aff40f
 #define NEXT_ARG() \
aff40f
 argv++; \
aff40f
 if (--argc <= 0) \
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
 
aff40f
 typedef struct
aff40f
 {
aff40f
diff --git a/iptunnel.c b/iptunnel.c
aff40f
index 2215d68..42b2a9e 100644
aff40f
--- a/iptunnel.c
aff40f
+++ b/iptunnel.c
aff40f
@@ -76,9 +76,9 @@ static void version(void)
aff40f
 	exit(E_VERSION);
aff40f
 }
aff40f
 
aff40f
-static void usage(void) __attribute__((noreturn));
aff40f
+static void usage(int rc) __attribute__((noreturn));
aff40f
 
aff40f
-static void usage(void)
aff40f
+static void usage(int rc)
aff40f
 {
aff40f
 	fprintf(stderr, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n"));
aff40f
 	fprintf(stderr, _("          [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n"));
aff40f
@@ -90,7 +90,7 @@ static void usage(void)
aff40f
 	fprintf(stderr, _("       TOS  := { NUMBER | inherit }\n"));
aff40f
 	fprintf(stderr, _("       TTL  := { 1..255 | inherit }\n"));
aff40f
 	fprintf(stderr, _("       KEY  := { DOTTED_QUAD | NUMBER }\n"));
aff40f
-	exit(E_USAGE);
aff40f
+	exit(rc);
aff40f
 }
aff40f
 
aff40f
 static int do_ioctl_get_ifindex(char *dev)
aff40f
@@ -217,18 +217,18 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
aff40f
 			NEXT_ARG();
aff40f
 			if (strcmp(*argv, "ipip") == 0) {
aff40f
 				if (p->iph.protocol)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->iph.protocol = IPPROTO_IPIP;
aff40f
 			} else if (strcmp(*argv, "gre") == 0) {
aff40f
 				if (p->iph.protocol)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->iph.protocol = IPPROTO_GRE;
aff40f
 			} else if (strcmp(*argv, "sit") == 0) {
aff40f
 				if (p->iph.protocol)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->iph.protocol = IPPROTO_IPV6;
aff40f
 			} else
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 		} else if (strcmp(*argv, "key") == 0) {
aff40f
 			unsigned uval;
aff40f
 			NEXT_ARG();
aff40f
@@ -238,7 +238,7 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
aff40f
 				p->i_key = p->o_key = get_addr32(*argv);
aff40f
 			else {
aff40f
 				if (scan_number(*argv, &uval)<0)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->i_key = p->o_key = htonl(uval);
aff40f
 			}
aff40f
 		} else if (strcmp(*argv, "ikey") == 0) {
aff40f
@@ -249,7 +249,7 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
aff40f
 				p->o_key = get_addr32(*argv);
aff40f
 			else {
aff40f
 				if (scan_number(*argv, &uval)<0)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->i_key = htonl(uval);
aff40f
 			}
aff40f
 		} else if (strcmp(*argv, "okey") == 0) {
aff40f
@@ -260,7 +260,7 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
aff40f
 				p->o_key = get_addr32(*argv);
aff40f
 			else {
aff40f
 				if (scan_number(*argv, &uval)<0)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->o_key = htonl(uval);
aff40f
 			}
aff40f
 		} else if (strcmp(*argv, "seq") == 0) {
aff40f
@@ -295,9 +295,9 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
aff40f
 			NEXT_ARG();
aff40f
 			if (strcmp(*argv, "inherit") != 0) {
aff40f
 				if (scan_number(*argv, &uval)<0)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				if (uval > 255)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->iph.ttl = uval;
aff40f
 			}
aff40f
 		} else if (strcmp(*argv, "tos") == 0) {
aff40f
@@ -305,15 +305,15 @@ static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
aff40f
 			NEXT_ARG();
aff40f
 			if (strcmp(*argv, "inherit") != 0) {
aff40f
 				if (scan_number(*argv, &uval)<0)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				if (uval > 255)
aff40f
-					usage();
aff40f
+					usage(E_OPTERR);
aff40f
 				p->iph.tos = uval;
aff40f
 			} else
aff40f
 				p->iph.tos = 1;
aff40f
 		} else {
aff40f
 			if (p->name[0])
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			safe_strncpy(p->name, *argv, IFNAMSIZ);
aff40f
 		}
aff40f
 		argc--; argv++;
aff40f
@@ -574,7 +574,7 @@ int do_iptunnel(int argc, char **argv)
aff40f
 	} else
aff40f
 		return do_show(0, NULL);
aff40f
 
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
 }
aff40f
 
aff40f
 
aff40f
@@ -605,13 +605,13 @@ int main(int argc, char **argv)
aff40f
 			argc--;
aff40f
 			argv++;
aff40f
 			if (argc <= 1)
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 			if (strcmp(argv[1], "inet") == 0)
aff40f
 				preferred_family = AF_INET;
aff40f
 			else if (strcmp(argv[1], "inet6") == 0)
aff40f
 				preferred_family = AF_INET6;
aff40f
 			else
aff40f
-				usage();
aff40f
+				usage(E_OPTERR);
aff40f
 		} else if (matches(argv[1], "-stats") == 0 ||
aff40f
 			   matches(argv[1], "-statistics") == 0) {
aff40f
 			++show_stats;
aff40f
@@ -620,7 +620,7 @@ int main(int argc, char **argv)
aff40f
 		} else if ((matches(argv[1], "-V") == 0) || (matches(argv[1], "--version") == 0)) {
aff40f
 			version();
aff40f
 		} else
aff40f
-			usage();
aff40f
+			usage(E_OPTERR);
aff40f
 		argc--;	argv++;
aff40f
 	}
aff40f
 
aff40f
diff --git a/nameif.c b/nameif.c
aff40f
index b280e59..13e3033 100644
aff40f
--- a/nameif.c
aff40f
+++ b/nameif.c
aff40f
@@ -192,10 +192,10 @@ struct option lopt[] = {
aff40f
 	{NULL},
aff40f
 };
aff40f
 
aff40f
-void usage(void)
aff40f
+void usage(int rc)
aff40f
 {
aff40f
 	fprintf(stderr, _("usage: nameif [-c configurationfile] [-s] {ifname macaddress}\n"));
aff40f
-	exit(E_USAGE);
aff40f
+	exit(rc);
aff40f
 }
aff40f
 
aff40f
 int main(int ac, char **av)
aff40f
@@ -214,7 +214,7 @@ int main(int ac, char **av)
aff40f
 		switch (c) {
aff40f
 		default:
aff40f
 		case '?':
aff40f
-			usage();
aff40f
+			usage(E_OPTERR);
aff40f
 		case 'c':
aff40f
 			fname = optarg;
aff40f
 			break;
aff40f
@@ -232,7 +232,7 @@ int main(int ac, char **av)
aff40f
 		char pos[30];
aff40f
 
aff40f
 		if ((ac-optind) & 1)
aff40f
-			usage();
aff40f
+			usage(E_OPTERR);
aff40f
 		if (strlen(av[optind])+1>IFNAMSIZ)
aff40f
 			complain(_("interface name `%s' too long"), av[optind]);
aff40f
 		safe_strncpy(ch->ifname, av[optind], sizeof(ch->ifname));
aff40f
diff --git a/plipconfig.c b/plipconfig.c
aff40f
index 86fa890..1caeed3 100644
aff40f
--- a/plipconfig.c
aff40f
+++ b/plipconfig.c
aff40f
@@ -57,12 +57,12 @@ static void version(void)
aff40f
     exit(E_VERSION);
aff40f
 }
aff40f
 
aff40f
-void usage(void)
aff40f
+void usage(int rc)
aff40f
 {
aff40f
     fprintf(stderr, _("Usage: plipconfig interface [nibble NN] [trigger NN]\n"));
aff40f
     fprintf(stderr, _("       plipconfig -V | --version\n"));
aff40f
     fprintf(stderr, _("       plipconfig -h | --help\n"));
aff40f
-    exit(E_USAGE);
aff40f
+    exit(rc);
aff40f
 }
aff40f
 
aff40f
 void print_plip(void)
aff40f
@@ -89,16 +89,18 @@ int main(int argc, char **argv)
aff40f
     argc--;
aff40f
     argv++;
aff40f
     while (argv[0] && *argv[0] == '-') {
aff40f
-	if (!strcmp(*argv, "-V") || !strcmp(*argv, "--version"))
aff40f
+	if ((!strcmp(*argv, "-V") || !strcmp(*argv, "--version")) && argc==1)
aff40f
 	    version();
aff40f
+	if ((!strcmp(*argv, "-h") || !strcmp(*argv, "--help")) && argc==1)
aff40f
+	    usage(E_USAGE);
aff40f
 	else
aff40f
-            usage();
aff40f
+            usage(E_OPTERR);
aff40f
 	argv++;
aff40f
 	argc--;
aff40f
     }
aff40f
 
aff40f
     if (argc == 0)
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
 
aff40f
     spp = argv;
aff40f
     safe_strncpy(ifr.ifr_name, *spp++, IFNAMSIZ);
aff40f
@@ -117,19 +119,19 @@ int main(int argc, char **argv)
aff40f
     while (*spp != (char *) NULL) {
aff40f
 	if (!strcmp(*spp, "nibble")) {
aff40f
 	    if (*++spp == NULL)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	    plip->nibble = atoi(*spp);
aff40f
 	    spp++;
aff40f
 	    continue;
aff40f
 	}
aff40f
 	if (!strcmp(*spp, "trigger")) {
aff40f
 	    if (*++spp == NULL)
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	    plip->trigger = atoi(*spp);
aff40f
 	    spp++;
aff40f
 	    continue;
aff40f
 	}
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
     }
aff40f
 
aff40f
     plip->pcmd = PLIP_SET_TIMEOUT;
aff40f
diff --git a/route.c b/route.c
aff40f
index 4eaed49..d5a3039 100644
aff40f
--- a/route.c
aff40f
+++ b/route.c
aff40f
@@ -76,7 +76,7 @@ int opt_fc = 0;    // routing cache/FIB
aff40f
 int opt_h = 0;     // help selected
aff40f
 struct aftype *ap; // selected address family
aff40f
 
aff40f
-static void usage(void)
aff40f
+static void usage(int rc)
aff40f
 {
aff40f
     fprintf(stderr, _("Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables\n"));
aff40f
     fprintf(stderr, _("       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.\n\n"));
aff40f
@@ -93,7 +93,7 @@ static void usage(void)
aff40f
     fprintf(stderr, _("  <AF>=Use -4, -6, '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF);
aff40f
     fprintf(stderr, _("  List of possible address families (which support routing):\n"));
aff40f
     print_aflist(1); /* 1 = routeable */
aff40f
-    exit(E_USAGE);
aff40f
+    exit(rc);
aff40f
 }
aff40f
 
aff40f
 
aff40f
@@ -186,11 +186,12 @@ int main(int argc, char **argv)
aff40f
 	case 'V':
aff40f
 	    version();
aff40f
 	case 'h':
aff40f
+	    usage(E_USAGE);
aff40f
 	case '?':
aff40f
 	    opt_h++;
aff40f
 	    break;
aff40f
 	default:
aff40f
-	    usage();
aff40f
+	    usage(E_OPTERR);
aff40f
 	}
aff40f
 
aff40f
     argv += optind;
aff40f
@@ -198,7 +199,7 @@ int main(int argc, char **argv)
aff40f
 
aff40f
     if (opt_h) {
aff40f
 	if (!afname[0])
aff40f
-	    usage();
aff40f
+	    usage(E_OPTERR);
aff40f
 	else
aff40f
 	    what = RTACTION_HELP;
aff40f
     } else {
aff40f
@@ -217,7 +218,7 @@ int main(int argc, char **argv)
aff40f
 	    else if (!strcmp(*argv, "flush"))
aff40f
 		what = RTACTION_FLUSH;
aff40f
 	    else
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 	}
aff40f
     }
aff40f
 
aff40f
@@ -231,7 +232,7 @@ int main(int argc, char **argv)
aff40f
 	i = route_edit(what, afname, options, ++argv);
aff40f
 
aff40f
     if (i == E_OPTERR)
aff40f
-	usage();
aff40f
+	usage(E_OPTERR);
aff40f
 
aff40f
     return (i);
aff40f
 }
aff40f
diff --git a/slattach.c b/slattach.c
aff40f
index 5c81584..dbb2658 100644
aff40f
--- a/slattach.c
aff40f
+++ b/slattach.c
aff40f
@@ -581,7 +581,7 @@ sig_catch(int sig)
aff40f
 
aff40f
 
aff40f
 static void
aff40f
-usage(void)
aff40f
+usage(int rc)
aff40f
 {
aff40f
   char *usage_msg = "Usage: slattach [-ehlLmnqv] "
aff40f
 #ifdef SIOCSKEEPALIVE
aff40f
@@ -594,7 +594,7 @@ usage(void)
aff40f
 	  "       slattach -V | --version\n";
aff40f
 
aff40f
   fputs(usage_msg, stderr);
aff40f
-  exit(E_USAGE);
aff40f
+  exit(rc);
aff40f
 }
aff40f
 
aff40f
 
aff40f
@@ -691,7 +691,7 @@ main(int argc, char *argv[])
aff40f
 		/*NOTREACHED*/
aff40f
 
aff40f
 	default:
aff40f
-		usage();
aff40f
+		usage(E_OPTERR);
aff40f
 		/*NOTREACHED*/
aff40f
   }
aff40f
 
aff40f
@@ -707,7 +707,7 @@ main(int argc, char *argv[])
aff40f
        opt_m++;
aff40f
 
aff40f
   /* Is a terminal given? */
aff40f
-  if (optind != (argc - 1)) usage();
aff40f
+  if (optind != (argc - 1)) usage(E_OPTERR);
aff40f
   safe_strncpy(path_buf, argv[optind], sizeof(path_buf));
aff40f
   if (!strcmp(path_buf, "-")) {
aff40f
 	opt_e = 1;