From dfdf2081eb40c5c595dda3cc5ba37211aee570ff Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Thu, 6 Jan 2011 09:08:43 -0300 Subject: [PATCH] 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 --- login-utils/wall.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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); -- 2.39.5