Blame SOURCES/quota-4.01-Correct-quotasync-exit-code.patch

370c56
From 0d5a11f41afe14f779908fbc366c492b818a0864 Mon Sep 17 00:00:00 2001
370c56
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
370c56
Date: Wed, 6 Mar 2013 11:32:32 +0100
370c56
Subject: [PATCH 3/4] Correct quotasync exit code
370c56
MIME-Version: 1.0
370c56
Content-Type: text/plain; charset=UTF-8
370c56
Content-Transfer-Encoding: 8bit
370c56
370c56
This fixes `quotasync -h' exit code as well as it uses more portable
370c56
EXIT_SUCCESS/EXIT_FAILURE values.
370c56
370c56
Signed-off-by: Petr Písař <ppisar@redhat.com>
370c56
Signed-off-by: Jan Kara <jack@suse.cz>
370c56
---
370c56
 quotasync.c | 23 +++++++++++++----------
370c56
 1 file changed, 13 insertions(+), 10 deletions(-)
370c56
370c56
diff --git a/quotasync.c b/quotasync.c
370c56
index cab9015..cfc3f2d 100644
370c56
--- a/quotasync.c
370c56
+++ b/quotasync.c
370c56
@@ -20,7 +20,7 @@ static char **mnt;
370c56
 static int mntcnt;
370c56
 char *progname;
370c56
 
370c56
-static void usage(void)
370c56
+static void usage(int status)
370c56
 {
370c56
 	printf(_(
370c56
 "%1$s: Utility for syncing quotas.\n"
370c56
@@ -39,7 +39,7 @@ static void usage(void)
370c56
 "\n"
370c56
 		));
370c56
 	printf(_("Report bugs to <%s>.\n"), MY_EMAIL);
370c56
-	exit(1);
370c56
+	exit(status);
370c56
 }
370c56
 
370c56
 static void parse_options(int argcnt, char **argstr)
370c56
@@ -57,11 +57,12 @@ static void parse_options(int argcnt, char **argstr)
370c56
 	while ((ret = getopt_long(argcnt, argstr, "ahugV", long_opts, NULL)) != -1) {
370c56
 		switch (ret) {
370c56
 			case '?':
370c56
+				usage(EXIT_FAILURE);
370c56
 			case 'h':
370c56
-				usage();
370c56
+				usage(EXIT_SUCCESS);
370c56
 			case 'V':
370c56
 				version();
370c56
-				exit(0);
370c56
+				exit(EXIT_SUCCESS);
370c56
 			case 'u':
370c56
 				flags |= FL_USER;
370c56
 				break;
370c56
@@ -77,7 +78,7 @@ static void parse_options(int argcnt, char **argstr)
370c56
 	if ((flags & FL_ALL && optind != argcnt) ||
370c56
 	    (!(flags & FL_ALL) && optind == argcnt)) {
370c56
 		fputs(_("Bad number of arguments.\n"), stderr);
370c56
-		usage();
370c56
+		usage(EXIT_FAILURE);
370c56
 	}
370c56
 	if (!(flags & FL_ALL)) {
370c56
 		mnt = argstr + optind;
370c56
@@ -100,10 +101,12 @@ static int syncquotas(int type)
370c56
 	int i, ret = 0;
370c56
 
370c56
 	if (flags & FL_ALL) {
370c56
-		if (sync_one(type, NULL) < 0)
370c56
+		if (sync_one(type, NULL) < 0) {
370c56
 			errstr(_("%s quota sync failed: %s\n"), _(type2name(type)),
370c56
 					strerror(errno));
370c56
-		return -1;
370c56
+			ret = -1;
370c56
+		}
370c56
+		return ret;
370c56
 	}
370c56
 
370c56
 	handles = create_handle_list(mntcnt, mnt, type, fmt,
370c56
@@ -124,7 +127,7 @@ static int syncquotas(int type)
370c56
 
370c56
 int main(int argc, char **argv)
370c56
 {
370c56
-	int ret = 0;
370c56
+	int ret = EXIT_SUCCESS;
370c56
 
370c56
 	gettexton();
370c56
 	progname = basename(argv[0]);
370c56
@@ -134,9 +137,9 @@ int main(int argc, char **argv)
370c56
 
370c56
 	if (flags & FL_USER)
370c56
 		if (syncquotas(USRQUOTA))
370c56
-			ret = 1;
370c56
+			ret = EXIT_FAILURE;
370c56
 	if (flags & FL_GROUP)
370c56
 		if (syncquotas(GRPQUOTA))
370c56
-			ret = 1;
370c56
+			ret = EXIT_FAILURE;
370c56
 	return ret;
370c56
 }
370c56
-- 
370c56
1.8.1.4
370c56