]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Use EXIT_FAILURE, not EXIT_FAIL, now that EXIT_FAILURE is always 1.
authorJim Meyering <jim@meyering.net>
Tue, 28 Aug 2007 22:13:16 +0000 (00:13 +0200)
committerJim Meyering <jim@meyering.net>
Tue, 28 Aug 2007 22:14:23 +0000 (00:14 +0200)
* src/system.h (EXIT_FAIL): Remove definition.
* src/chroot.c (main): EXIT_FAIL -> EXIT_FAILURE.
* src/env.c (main): Likewise.
* src/nice.c (main): Likewise.
* src/su.c (change_identity, main): Likewise.
* src/tty.c (main): Likewise.
Suggestion from Eric Blake.

ChangeLog
src/chroot.c
src/env.c
src/nice.c
src/su.c
src/system.h
src/tty.c

index 80d08a1d163597704cfd2823d5350ae8afc376db..015bad93151eda640a33cb8c580459bddcd11893 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-08-29  Jim Meyering  <jim@meyering.net>
+
+       Use EXIT_FAILURE, not EXIT_FAIL, now that EXIT_FAILURE is always 1.
+       * src/system.h (EXIT_FAIL): Remove definition.
+       * src/chroot.c (main): EXIT_FAIL -> EXIT_FAILURE.
+       * src/env.c (main): Likewise.
+       * src/nice.c (main): Likewise.
+       * src/su.c (change_identity, main): Likewise.
+       * src/tty.c (main): Likewise.
+       Suggestion from Eric Blake.
+
 2007-08-28  Jim Meyering  <jim@meyering.net>
 
        * src/test.c (usage): Note that [ honors --help and --version,
index 67bf07497716eb0bcd7bd3fed01e04606b22f79e..4d23fabccbcaab1a876e23ec1279795df7f2b63d 100644 (file)
@@ -70,25 +70,25 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  initialize_exit_failure (EXIT_FAIL);
+  initialize_exit_failure (EXIT_FAILURE);
   atexit (close_stdout);
 
   parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
-    usage (EXIT_FAIL);
+    usage (EXIT_FAILURE);
 
   if (argc <= optind)
     {
       error (0, 0, _("missing operand"));
-      usage (EXIT_FAIL);
+      usage (EXIT_FAILURE);
     }
 
   if (chroot (argv[optind]) != 0)
-    error (EXIT_FAIL, errno, _("cannot change root directory to %s"), argv[1]);
+    error (EXIT_FAILURE, errno, _("cannot change root directory to %s"), argv[1]);
 
   if (chdir ("/"))
-    error (EXIT_FAIL, errno, _("cannot chdir to root directory"));
+    error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
 
   if (argc == optind + 1)
     {
index 52e24aa9e49e158b76b4cfccb1f12806f0ea6aab..14a62d09342e105cae216e972bf93d6b6b24f0c9 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -146,7 +146,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  initialize_exit_failure (EXIT_FAIL);
+  initialize_exit_failure (EXIT_FAILURE);
   atexit (close_stdout);
 
   while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
@@ -161,7 +161,7 @@ main (int argc, char **argv)
        case_GETOPT_HELP_CHAR;
        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
        default:
-         usage (EXIT_FAIL);
+         usage (EXIT_FAILURE);
        }
     }
 
index 4624e48bb99ec82d8f2762acee6be9449421f077..7892fea4c8a9797b1034e42487e4b430a3bcb2ca 100644 (file)
@@ -104,7 +104,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  initialize_exit_failure (EXIT_FAIL);
+  initialize_exit_failure (EXIT_FAILURE);
   atexit (close_stdout);
 
   parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -135,7 +135,7 @@ main (int argc, char **argv)
          i += optind - 1;
 
          if (optc == '?')
-           usage (EXIT_FAIL);
+           usage (EXIT_FAILURE);
          else if (optc == 'n')
            adjustment_given = optarg;
          else /* optc == -1 */
@@ -151,7 +151,7 @@ main (int argc, char **argv)
       enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 };
       long int tmp;
       if (LONGINT_OVERFLOW < xstrtol (adjustment_given, NULL, 10, &tmp, ""))
-       error (EXIT_FAIL, 0, _("invalid adjustment %s"),
+       error (EXIT_FAILURE, 0, _("invalid adjustment %s"),
               quote (adjustment_given));
       adjustment = MAX (MIN_ADJUSTMENT, MIN (tmp, MAX_ADJUSTMENT));
     }
@@ -161,13 +161,13 @@ main (int argc, char **argv)
       if (adjustment_given)
        {
          error (0, 0, _("a command must be given with an adjustment"));
-         usage (EXIT_FAIL);
+         usage (EXIT_FAILURE);
        }
       /* No command given; print the niceness.  */
       errno = 0;
       current_niceness = GET_NICENESS ();
       if (current_niceness == -1 && errno != 0)
-       error (EXIT_FAIL, errno, _("cannot get niceness"));
+       error (EXIT_FAILURE, errno, _("cannot get niceness"));
       printf ("%d\n", current_niceness);
       exit (EXIT_SUCCESS);
     }
@@ -178,11 +178,11 @@ main (int argc, char **argv)
 #else
   current_niceness = GET_NICENESS ();
   if (current_niceness == -1 && errno != 0)
-    error (EXIT_FAIL, errno, _("cannot get niceness"));
+    error (EXIT_FAILURE, errno, _("cannot get niceness"));
   ok = (setpriority (PRIO_PROCESS, 0, current_niceness + adjustment) == 0);
 #endif
   if (!ok)
-    error (errno == EPERM ? 0 : EXIT_FAIL, errno, _("cannot set niceness"));
+    error (errno == EPERM ? 0 : EXIT_FAILURE, errno, _("cannot set niceness"));
 
   execvp (argv[i], &argv[i]);
 
index 51eed60eb8780f80e8aa29b714d89a764069aa00..7778002f84d2e305144e579e01109ac237c87d78 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -299,13 +299,13 @@ change_identity (const struct passwd *pw)
 #ifdef HAVE_INITGROUPS
   errno = 0;
   if (initgroups (pw->pw_name, pw->pw_gid) == -1)
-    error (EXIT_FAIL, errno, _("cannot set groups"));
+    error (EXIT_FAILURE, errno, _("cannot set groups"));
   endgrent ();
 #endif
   if (setgid (pw->pw_gid))
-    error (EXIT_FAIL, errno, _("cannot set group id"));
+    error (EXIT_FAILURE, errno, _("cannot set group id"));
   if (setuid (pw->pw_uid))
-    error (EXIT_FAIL, errno, _("cannot set user id"));
+    error (EXIT_FAILURE, errno, _("cannot set user id"));
 }
 
 /* Run SHELL, or DEFAULT_SHELL if SHELL is empty.
@@ -419,7 +419,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  initialize_exit_failure (EXIT_FAIL);
+  initialize_exit_failure (EXIT_FAILURE);
   atexit (close_stdout);
 
   fast_startup = false;
@@ -456,7 +456,7 @@ main (int argc, char **argv)
        case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
 
        default:
-         usage (EXIT_FAIL);
+         usage (EXIT_FAILURE);
        }
     }
 
@@ -471,7 +471,7 @@ main (int argc, char **argv)
   pw = getpwnam (new_user);
   if (! (pw && pw->pw_name && pw->pw_name[0] && pw->pw_dir && pw->pw_dir[0]
         && pw->pw_passwd))
-    error (EXIT_FAIL, 0, _("user %s does not exist"), new_user);
+    error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user);
 
   /* Make a copy of the password information and point pw at the local
      copy instead.  Otherwise, some systems (e.g. Linux) would clobber
@@ -494,7 +494,7 @@ main (int argc, char **argv)
 #ifdef SYSLOG_FAILURE
       log_su (pw, false);
 #endif
-      error (EXIT_FAIL, 0, _("incorrect password"));
+      error (EXIT_FAILURE, 0, _("incorrect password"));
     }
 #ifdef SYSLOG_SUCCESS
   else
index a0a4942b58539d854c71f3754e01130a1faa05a7..d840ed505b3ed72451ec41b20f05d09a2fc6b6ba 100644 (file)
@@ -113,11 +113,9 @@ you must include <sys/types.h> before including this file
 #include <stdbool.h>
 #include <stdlib.h>
 
-/* Exit statuses for programs like 'env' that exec other programs.
-   EXIT_FAILURE might not be 1, so use EXIT_FAIL in such programs.  */
+/* Exit statuses for programs like 'env' that exec other programs.  */
 enum
 {
-  EXIT_FAIL = 1,
   EXIT_CANNOT_INVOKE = 126,
   EXIT_ENOENT = 127
 };
index c7bdb77c1996788162b0383c823d6f869644f205..0a38093377ef7973bd72de135b259ef27a092243 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -124,5 +124,5 @@ main (int argc, char **argv)
        puts (_("not a tty"));
     }
 
-  exit (isatty (STDIN_FILENO) ? EXIT_SUCCESS : EXIT_FAIL);
+  exit (isatty (STDIN_FILENO) ? EXIT_SUCCESS : EXIT_FAILURE);
 }