diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/chroot.c | 10 | ||||
-rw-r--r-- | src/env.c | 4 | ||||
-rw-r--r-- | src/nice.c | 14 | ||||
-rw-r--r-- | src/su.c | 14 | ||||
-rw-r--r-- | src/system.h | 4 | ||||
-rw-r--r-- | src/tty.c | 2 |
7 files changed, 34 insertions, 25 deletions
@@ -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, diff --git a/src/chroot.c b/src/chroot.c index 67bf07497..4d23fabcc 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -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) { @@ -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); } } diff --git a/src/nice.c b/src/nice.c index 4624e48bb..7892fea4c 100644 --- a/src/nice.c +++ b/src/nice.c @@ -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]); @@ -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 diff --git a/src/system.h b/src/system.h index a0a4942b5..d840ed505 100644 --- a/src/system.h +++ b/src/system.h @@ -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 }; @@ -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); } |