diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2022-12-02 22:21:36 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2022-12-02 22:21:36 +0000 |
commit | deae90b98f6e12a8199ca866dc381e872252c759 (patch) | |
tree | a353a667b6e1823e488662994097dff6697ceea4 /usr.bin/midicat | |
parent | 15a5e1994854c2dc16dfe097f7177306bddbefb9 (diff) |
midicat(1): add a usage() function
Tweaked by millert@.
Link: https://marc.info/?l=openbsd-tech&m=166982129428027&w=2
ok millert@ kn@ ratchov@
Diffstat (limited to 'usr.bin/midicat')
-rw-r--r-- | usr.bin/midicat/midicat.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/usr.bin/midicat/midicat.c b/usr.bin/midicat/midicat.c index d6e8079226b..21bb05ac78a 100644 --- a/usr.bin/midicat/midicat.c +++ b/usr.bin/midicat/midicat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midicat.c,v 1.4 2022/11/30 14:56:45 cheloha Exp $ */ +/* $OpenBSD: midicat.c,v 1.5 2022/12/02 22:21:35 cheloha Exp $ */ /* * Copyright (c) 2015 Alexandre Ratchov <alex@caoua.org> * @@ -22,8 +22,7 @@ #include <unistd.h> #include <string.h> -char usagestr[] = "usage: midicat [-d] [-i in-file] [-o out-file] " - "[-q in-port] [-q out-port]\n"; +void __dead usage(void); int main(int argc, char **argv) @@ -62,16 +61,14 @@ main(int argc, char **argv) ofile = optarg; break; default: - goto bad_usage; + usage(); } } argc -= optind; argv += optind; - if (argc != 0) { - bad_usage: - fputs(usagestr, stderr); - return 1; - } + + if (argc != 0) + usage(); /* we don't support more than one data flow */ if (ifile != NULL && ofile != NULL) { @@ -87,7 +84,7 @@ main(int argc, char **argv) /* if there're neither files nor ports, then we've nothing to do */ if (port0 == NULL && ifile == NULL && ofile == NULL) - goto bad_usage; + usage(); /* if no port specified, use default one */ if (port0 == NULL) @@ -195,3 +192,11 @@ main(int argc, char **argv) close(ofd); return 0; } + +void __dead +usage(void) +{ + fprintf(stderr, "usage: midicat [-d] [-i in-file] [-o out-file] " + "[-q in-port] [-q out-port]\n"); + exit(1); +} |