Use EXIT_SUCCESS and EXIT_FAILURE more consistently.

This commit is contained in:
Todd C. Miller
2020-02-08 12:43:00 -07:00
parent c5afbf00fc
commit ac61b5655d
29 changed files with 58 additions and 58 deletions

View File

@@ -54,7 +54,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s datafile\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
static void

View File

@@ -56,5 +56,5 @@ main(int argc, char *argv[])
}
printf("};\n");
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -56,5 +56,5 @@ main(int argc, char *argv[])
}
printf("};\n");
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -39,7 +39,7 @@ main(int argc, char *argv[])
if (argc > 1) {
if ((fp = fopen(argv[1], "r")) == NULL) {
perror(argv[1]);
exit(1);
exit(EXIT_FAILURE);
}
}

View File

@@ -87,7 +87,7 @@ runtests(char **buf, size_t *buflen)
sudo_warn_nodebug("send");
_exit(127);
}
_exit(0);
_exit(EXIT_SUCCESS);
break;
default:
/* parent */

View File

@@ -51,7 +51,7 @@ main(int argc, char **argv)
if (argc > 1) {
if ((fp = fopen(argv[1], "r")) == NULL) {
perror(argv[1]);
exit(1);
exit(EXIT_FAILURE);
}
}
@@ -74,7 +74,7 @@ main(int argc, char **argv)
if (buf[len - 1] != '\n') {
fprintf(stderr,
"globtest: missing newline at EOF\n");
exit(1);
exit(EXIT_FAILURE);
}
buf[--len] = '\0';
}
@@ -93,14 +93,14 @@ main(int argc, char **argv)
fprintf(stderr,
"globtest: invalid entry on line %d\n",
lineno);
exit(1);
exit(EXIT_FAILURE);
}
len = cp - buf - 1;
if (len >= sizeof(entry.pattern)) {
fprintf(stderr,
"globtest: pattern too big on line %d\n",
lineno);
exit(1);
exit(EXIT_FAILURE);
}
memcpy(entry.pattern, buf + 1, len);
entry.pattern[len] = '\0';
@@ -110,14 +110,14 @@ main(int argc, char **argv)
fprintf(stderr,
"globtest: invalid entry on line %d\n",
lineno);
exit(1);
exit(EXIT_FAILURE);
}
ep = strchr(cp, '>');
if (ep == NULL) {
fprintf(stderr,
"globtest: invalid entry on line %d\n",
lineno);
exit(1);
exit(EXIT_FAILURE);
}
*ep = '\0';
entry.flags = 0;
@@ -144,7 +144,7 @@ main(int argc, char **argv)
fprintf(stderr,
"globtest: invalid flags on line %d\n",
lineno);
exit(1);
exit(EXIT_FAILURE);
}
}
entry.nresults = 0;
@@ -153,14 +153,14 @@ main(int argc, char **argv)
if (!entry.pattern[0]) {
fprintf(stderr, "globtest: missing entry on line %d\n",
lineno);
exit(1);
exit(EXIT_FAILURE);
}
if (entry.nresults + 1 > MAX_RESULTS) {
fprintf(stderr,
"globtest: too many results for %s, max %d\n",
entry.pattern, MAX_RESULTS);
exit(1);
exit(EXIT_FAILURE);
}
entry.results[entry.nresults++] = strdup(buf);
}
@@ -185,7 +185,7 @@ int test_glob(struct gl_entry *entry)
if (glob(entry->pattern, entry->flags, NULL, &gl) != 0) {
fprintf(stderr, "glob failed: %s: %s\n", entry->pattern,
strerror(errno));
exit(1);
exit(EXIT_FAILURE);
}
for (ap = gl.gl_pathv; *ap != NULL; ap++)

View File

@@ -87,7 +87,7 @@ main(int argc, char *argv[])
free(gidlist);
ngids = sudo_parse_gids(test_data[i].gids, test_data[i].baseptr, &gidlist);
if (ngids == -1)
exit(1); /* out of memory? */
exit(EXIT_FAILURE); /* out of memory? */
ntests++;
if (ngids != test_data[i].ngids) {
sudo_warnx_nodebug("test #%d: expected %d gids, got %d",

View File

@@ -60,8 +60,8 @@ main(int argc, char *argv[])
if (strcmp(getprogname(), progbase) != 0) {
printf("%s: FAIL: incorrect program name \"%s\"\n",
progbase, getprogname());
exit(1);
exit(EXIT_FAILURE);
}
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -56,5 +56,5 @@ main(int argc, char *argv[])
while (sudo_parseln(&line, &linesize, &lineno, stdin, 0) != -1)
printf("%6u\t%s\n", lineno, line);
free(line);
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -1604,7 +1604,7 @@ daemonize(bool nofork)
break;
default:
/* parent, exit */
_exit(0);
_exit(EXIT_SUCCESS);
}
}
@@ -1627,7 +1627,7 @@ usage(bool fatal)
fprintf(stderr, "usage: %s [-n] [-f conf_file] [-R percentage]\n",
getprogname());
if (fatal)
exit(1);
exit(EXIT_FAILURE);
}
static void
@@ -1642,7 +1642,7 @@ help(void)
" -n, --no-fork do not fork, run in the foreground\n"
" -R, --random-drop percent chance connections will drop\n"
" -V, --version display version information and exit\n"));
exit(0);
exit(EXIT_SUCCESS);
}
static const char short_opts[] = "f:hnR:V";

View File

@@ -104,7 +104,7 @@ usage(bool fatal)
fprintf(stderr, "usage: %s [-h host] [-i iolog-id] [-p port] "
#endif
"[-r restart-point] /path/to/iolog\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
static void
@@ -126,7 +126,7 @@ help(void)
" -k, --key private key file\n"
#endif
" -V, --version display version information and exit\n"));
exit(0);
exit(EXIT_SUCCESS);
}
#if defined(HAVE_OPENSSL)

View File

@@ -175,7 +175,7 @@ usage(void)
{
fprintf(stderr,
"usage: plugin_test [-p \"plugin.so plugin_args ...\"] user:group ...\n");
exit(1);
exit(EXIT_FAILURE);
}
int
@@ -203,7 +203,7 @@ main(int argc, char *argv[])
if (group_plugin_load(plugin) != 1) {
fprintf(stderr, "unable to load plugin: %s\n", plugin);
exit(1);
exit(EXIT_FAILURE);
}
for (i = 0; argv[i] != NULL; i++) {
@@ -218,6 +218,6 @@ main(int argc, char *argv[])
}
group_plugin_unload();
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -1310,7 +1310,7 @@ usage(int fatal)
"[-I increment] [-m filter] [-o output_file] [-O start_point] "
"[-P padding] [-s sections] [input_file]\n", getprogname());
if (fatal)
exit(1);
exit(EXIT_FAILURE);
}
static void
@@ -1335,5 +1335,5 @@ help(void)
" -P, --padding=num base padding for sudoOrder increment\n"
" -s, --suppress=sections suppress output of certain sections\n"
" -V, --version display version information and exit"));
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -801,14 +801,14 @@ send_mail(const char *fmt, ...)
sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to fork: %s",
strerror(errno));
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(1);
_exit(EXIT_FAILURE);
case 0:
/* Grandchild continues below. */
sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys);
break;
default:
/* Parent will wait for us. */
_exit(0);
_exit(EXIT_SUCCESS);
}
break;
default:
@@ -847,7 +847,7 @@ send_mail(const char *fmt, ...)
sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to open pipe: %s",
strerror(errno));
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(1);
_exit(EXIT_FAILURE);
}
switch (pid = sudo_debug_fork()) {
@@ -857,7 +857,7 @@ send_mail(const char *fmt, ...)
sudo_debug_printf(SUDO_DEBUG_ERROR, "unable to fork: %s",
strerror(errno));
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(1);
_exit(EXIT_FAILURE);
break;
case 0:
/* Child. */
@@ -913,7 +913,7 @@ send_mail(const char *fmt, ...)
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"child (%d) exit value %d", (int)rv, status);
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(0);
_exit(EXIT_SUCCESS);
}
/*

View File

@@ -41,7 +41,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s plugin.so symbols_file\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
int

View File

@@ -46,7 +46,7 @@ main(int argc, char *argv[])
if (argc > 1) {
if ((fp = fopen(argv[1], "r")) == NULL) {
perror(argv[1]);
exit(1);
exit(EXIT_FAILURE);
}
}

View File

@@ -52,7 +52,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s pathname\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
static int

View File

@@ -44,7 +44,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s inputfile\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
int

View File

@@ -77,7 +77,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s datafile\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
int

View File

@@ -1572,7 +1572,7 @@ usage(int fatal)
_("usage: %s [-h] [-d dir] -l [search expression]\n"),
getprogname());
if (fatal)
exit(1);
exit(EXIT_FAILURE);
}
static void
@@ -1591,7 +1591,7 @@ help(void)
" -S, --suspend-wait wait while the command was suspended\n"
" -s, --speed=num speed up or slow down output\n"
" -V, --version display version information and exit"));
exit(0);
exit(EXIT_SUCCESS);
}
/*

View File

@@ -606,5 +606,5 @@ static void
usage(void)
{
(void) fprintf(stderr, "usage: %s [-dt] [-G sudoers_gid] [-g group] [-h host] [-i input_format] [-P grfile] [-p pwfile] [-U sudoers_uid] [-u user] <user> <command> [args]\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}

View File

@@ -314,5 +314,5 @@ usage(void)
{
fprintf(stderr, "usage: %s [-f timestamp_file] | [-u username]\n",
getprogname());
exit(1);
exit(EXIT_FAILURE);
}

View File

@@ -263,7 +263,7 @@ main(int argc, char *argv[])
* errors and to pull in editor and env_editor conf values.
*/
if ((sudoersin = open_sudoers(sudoers_file, true, NULL)) == NULL)
exit(1);
exit(EXIT_FAILURE);
init_parser(sudoers_file, quiet, true);
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
(void) sudoersparse();
@@ -1283,7 +1283,7 @@ usage(int fatal)
(void) fprintf(fatal ? stderr : stdout,
"usage: %s [-chqsV] [[-f] sudoers ]\n", getprogname());
if (fatal)
exit(1);
exit(EXIT_FAILURE);
}
static void
@@ -1298,5 +1298,5 @@ help(void)
" -q, --quiet less verbose (quiet) syntax error messages\n"
" -s, --strict strict syntax checking\n"
" -V, --version display version information and exit\n"));
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -363,7 +363,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
/* parent exits (but does not flush buffers) */
sudo_debug_exit_int(__func__, __FILE__, __LINE__,
sudo_debug_subsys, 0);
_exit(0);
_exit(EXIT_SUCCESS);
}
}

View File

@@ -124,7 +124,7 @@ deliver_signal(struct monitor_closure *mc, int signo, bool from_parent)
killpg(mc->cmnd_pid, SIGCONT);
break;
case SIGKILL:
_exit(1); /* XXX */
_exit(EXIT_FAILURE); /* XXX */
/* NOTREACHED */
default:
/* Relay signal to command. */
@@ -635,7 +635,7 @@ exec_monitor(struct command_details *details, sigset_t *oset,
exec_cmnd_pty(details, foreground, errpipe[1]);
if (write(errpipe[1], &errno, sizeof(int)) == -1)
sudo_warn(U_("unable to execute %s"), details->command);
_exit(1);
_exit(EXIT_FAILURE);
}
close(errpipe[1]);
@@ -721,7 +721,7 @@ exec_monitor(struct command_details *details, sigset_t *oset,
}
#endif
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, 1);
_exit(1);
_exit(EXIT_FAILURE);
bad:
debug_return_int(-1);

View File

@@ -402,7 +402,7 @@ exec_nopty(struct command_details *details, struct command_status *cstat)
break;
}
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, 1);
_exit(1);
_exit(EXIT_FAILURE);
}
sudo_debug_printf(SUDO_DEBUG_INFO, "executed %s, pid %d", details->command,
(int)ec.cmnd_pid);

View File

@@ -1553,7 +1553,7 @@ exec_pty(struct command_details *details, struct command_status *cstat)
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO,
"%s: unable to send status to parent", __func__);
}
_exit(1);
_exit(EXIT_FAILURE);
}
/*

View File

@@ -583,7 +583,7 @@ parse_args(int argc, char **argv, int *old_optind, int *nargc, char ***nargv,
if (cmnd == NULL)
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (!gc_add(GC_PTR, cmnd))
exit(1);
exit(EXIT_FAILURE);
for (av = argv; *av != NULL; av++) {
for (src = *av; *src != '\0'; src++) {
@@ -605,7 +605,7 @@ parse_args(int argc, char **argv, int *old_optind, int *nargc, char ***nargv,
if (av == NULL)
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (!gc_add(GC_PTR, av))
exit(1);
exit(EXIT_FAILURE);
av[0] = (char *)user_details.shell; /* plugin may override shell */
if (cmnd != NULL) {
@@ -630,7 +630,7 @@ parse_args(int argc, char **argv, int *old_optind, int *nargc, char ***nargv,
if (av == NULL)
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (!gc_add(GC_PTR, av))
exit(1);
exit(EXIT_FAILURE);
/* Must have the command in argv[0]. */
av[0] = "sudoedit";
@@ -712,7 +712,7 @@ void
usage(void)
{
display_usage(usage_err);
exit(1);
exit(EXIT_FAILURE);
}
/*
@@ -816,5 +816,5 @@ help(void)
sudo_lbuf_print(&lbuf);
sudo_lbuf_destroy(&lbuf);
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, 0);
exit(0);
exit(EXIT_SUCCESS);
}

View File

@@ -184,7 +184,7 @@ main(int argc, char *argv[], char *envp[])
if (argc != 2) {
fprintf(stderr, "usage: %s regress | /path/to/sudo_noexec.so\n", getprogname());
exit(1);
exit(EXIT_FAILURE);
}
/* Disable execution for post-exec and re-exec ourself. */