diff options
author | Lawrence Teo <lteo@cvs.openbsd.org> | 2015-01-13 03:43:19 +0000 |
---|---|---|
committer | Lawrence Teo <lteo@cvs.openbsd.org> | 2015-01-13 03:43:19 +0000 |
commit | 7afc2cb71feaa7eb87e3e694ca8b956097c3ef86 (patch) | |
tree | 2dcd2a5c8cde4cc5213d0200316a00e5ba83165d /usr.sbin/tcpdrop | |
parent | 3fb55d47e2464946da81fce1bef86f21ec26712b (diff) |
Give tcpdrop a proper usage() like other programs in the tree.
ok bluhm@
Diffstat (limited to 'usr.sbin/tcpdrop')
-rw-r--r-- | usr.sbin/tcpdrop/tcpdrop.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/usr.sbin/tcpdrop/tcpdrop.c b/usr.sbin/tcpdrop/tcpdrop.c index 6b1fb7414a9..0520ea34d62 100644 --- a/usr.sbin/tcpdrop/tcpdrop.c +++ b/usr.sbin/tcpdrop/tcpdrop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcpdrop.c,v 1.15 2015/01/01 03:27:56 lteo Exp $ */ +/* $OpenBSD: tcpdrop.c,v 1.16 2015/01/13 03:43:18 lteo Exp $ */ /* * Copyright (c) 2004 Markus Friedl <markus@openbsd.org> @@ -33,7 +33,21 @@ #include <stdlib.h> #include <netdb.h> -extern char *__progname; +__dead void usage(void); + +__dead void +usage(void) +{ + extern char *__progname; + + fprintf(stderr, + "usage: %s local-addr local-port remote-addr remote-port\n", + __progname); + fprintf(stderr, + " %s local-addr:local-port remote-addr:remote-port\n", + __progname); + exit(1); +} /* * Drop a tcp connection. @@ -61,7 +75,7 @@ main(int argc, char **argv) if (port1) *port1++ = '\0'; else - goto fail; + usage(); faddr2 = addr2 = strdup(argv[2]); if (!addr2) @@ -70,22 +84,14 @@ main(int argc, char **argv) if (port2) *port2++ = '\0'; else - goto fail; + usage(); } else if (argc == 5) { laddr1 = addr1 = argv[1]; port1 = argv[2]; faddr2 = addr2 = argv[3]; port2 = argv[4]; - } else { -fail: - fprintf(stderr, - "usage: %s local-addr local-port remote-addr remote-port\n", - __progname); - fprintf(stderr, - " %s local-addr:local-port remote-addr:remote-port\n", - __progname); - exit(1); - } + } else + usage(); if (addr1[0] == '[' && addr1[strlen(addr1) - 1] == ']') { laddr1 = strdup(addr1); |