]> err.no Git - util-linux/commitdiff
wall: add usage function
authorDavidlohr Bueso <dave@gnu.org>
Thu, 6 Jan 2011 12:08:43 +0000 (09:08 -0300)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Jan 2011 14:30:44 +0000 (15:30 +0100)
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 <dave@gnu.org>
login-utils/wall.c

index 2ecce126b5fc291bf2f3d398fc7abec68fd284c0..650bcf48685ab16989fd48196e1822e6ebd29a7c 100644 (file)
@@ -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);