[PATCH 1/11] mesg: Use EXIT_* and discard K&R style declaration.

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

 



Signed-off-by: Marek Polacek <mmpolacek@xxxxxxxxx>
---
 login-utils/mesg.c |   47 +++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/login-utils/mesg.c b/login-utils/mesg.c
index e0015bd..0c574a5 100644
--- a/login-utils/mesg.c
+++ b/login-utils/mesg.c
@@ -42,24 +42,21 @@
  * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@xxxxxxxxxx>
  * - added Native Language Support
  *
- *
+ * 2010-12-01 Marek Polacek <mmpolacek@xxxxxxxxx>
+ * - cleanups
  */

-#include <sys/types.h>
-#include <sys/stat.h>
-
+#include <err.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <err.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include "nls.h"

-int
-main(argc, argv)
-	int argc;
-	char *argv[];
+int main(int argc, char *argv[])
 {
 	struct stat sb;
 	char *tty;
@@ -69,46 +66,48 @@ main(argc, argv)
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);

-
 	while ((ch = getopt(argc, argv, "")) != -1)
 		switch (ch) {
 		case '?':
 		default:
 			goto usage;
 		}
+
 	argc -= optind;
 	argv += optind;

 	if ((tty = ttyname(STDERR_FILENO)) == NULL)
-		err(1, "ttyname");
+		err(EXIT_FAILURE, _("ttyname failed"));
+
 	if (stat(tty, &sb) < 0)
-		err(1, "%s", tty);
+		err(EXIT_FAILURE, "%s", tty);

-	if (*argv == NULL) {
+	if (!*argv) {
 		if (sb.st_mode & (S_IWGRP | S_IWOTH)) {
-			(void)fprintf(stdout, _("is y\n"));
-			exit(0);
+			puts(_("is y"));
+			exit(EXIT_SUCCESS);
 		}
-		(void)fprintf(stdout, _("is n\n"));
-		exit(1);
+		puts(_("is n"));
+		exit(EXIT_FAILURE);
 	}

 	switch (*argv[0]) {
 	case 'y':
 #ifdef USE_TTY_GROUP
 		if (chmod(tty, sb.st_mode | S_IWGRP) < 0)
-			err(1, "%s", tty);
+			err(EXIT_FAILURE, "%s", tty);
 #else
 		if (chmod(tty, sb.st_mode | S_IWGRP | S_IWOTH) < 0)
-			err(1, "%s", tty);
+			err(EXIT_FAILURE, "%s", tty);
 #endif
-		exit(0);
+		exit(EXIT_SUCCESS);
 	case 'n':
 		if (chmod(tty, sb.st_mode & ~(S_IWGRP|S_IWOTH)) < 0)
-			err(1, "%s", tty);
-		exit(1);
+			err(EXIT_FAILURE, "%s", tty);
+
+		exit(EXIT_FAILURE);
 	}

-usage:	(void)fprintf(stderr, _("usage: mesg [y | n]\n"));
-	exit(2);
+usage:
+	errx(EXIT_FAILURE, _("usage: mesg [y | n]"));
 }
-- 
1.7.3.2


--
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