From: Davidlohr Bueso Date: Thu, 6 Jan 2011 12:08:43 +0000 (-0300) Subject: wall: add usage function X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfdf2081eb40c5c595dda3cc5ba37211aee570ff;p=util-linux wall: add usage function Instead of using an ugly goto statement, we can add a proper usage function. This also adds the undocumented '-n' option to the output string. Signed-off-by: Davidlohr Bueso --- diff --git a/login-utils/wall.c b/login-utils/wall.c index 2ecce126..650bcf48 100644 --- a/login-utils/wall.c +++ b/login-utils/wall.c @@ -82,6 +82,12 @@ int nobanner; int mbufsize; char *mbuf; +static void __attribute__((__noreturn__)) usage() +{ + errx(EXIT_FAILURE, _("usage: %s [-n] [file]\n"), + program_invocation_short_name); +} + int main(int argc, char **argv) { extern int optind; @@ -104,16 +110,13 @@ main(int argc, char **argv) { break; case '?': default: -usage: - fprintf(stderr, _("usage: %s [file]\n"), - program_invocation_short_name); - exit(EXIT_FAILURE); + usage(); } } argc -= optind; argv += optind; if (argc > 1) - goto usage; + usage(); makemsg(*argv);