[PATCH] wall: add usage function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Davidlohr Bueso <dave@xxxxxxx>

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@xxxxxxx>
---
 login-utils/wall.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/login-utils/wall.c b/login-utils/wall.c
index 2ecce12..650bcf4 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);
 
-- 
1.7.1



--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux