summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/base64.c2
-rw-r--r--src/basename.c2
-rw-r--r--src/cat.c2
-rw-r--r--src/chcon.c2
-rw-r--r--src/chgrp.c2
-rw-r--r--src/chmod.c2
-rw-r--r--src/chown.c2
-rw-r--r--src/chroot.c10
-rw-r--r--src/cksum.c4
-rw-r--r--src/comm.c4
-rw-r--r--src/coreutils-arch.c9
-rw-r--r--src/coreutils-dir.c9
-rw-r--r--src/coreutils-vdir.c9
-rw-r--r--src/coreutils.c13
-rw-r--r--src/cp.c2
-rw-r--r--src/csplit.c2
-rw-r--r--src/cut.c2
-rw-r--r--src/date.c2
-rw-r--r--src/dd.c13
-rw-r--r--src/df.c4
-rw-r--r--src/dircolors.c2
-rw-r--r--src/dirname.c2
-rw-r--r--src/du.c2
-rw-r--r--src/echo.c6
-rw-r--r--src/env.c10
-rw-r--r--src/expand.c2
-rw-r--r--src/expr.c2
-rw-r--r--src/factor.c2
-rw-r--r--src/fmt.c2
-rw-r--r--src/fold.c2
-rw-r--r--src/getlimits.c2
-rw-r--r--src/groups.c2
-rw-r--r--src/head.c2
-rw-r--r--src/hostid.c2
-rw-r--r--src/hostname.c2
-rw-r--r--src/id.c2
-rw-r--r--src/install.c2
-rw-r--r--src/join.c4
-rw-r--r--src/kill.c6
-rw-r--r--src/link.c2
-rw-r--r--src/ln.c2
-rw-r--r--src/logname.c15
-rw-r--r--src/ls.c2
-rw-r--r--src/make-prime-list.c2
-rw-r--r--src/md5sum.c2
-rw-r--r--src/mkdir.c4
-rw-r--r--src/mkfifo.c2
-rw-r--r--src/mknod.c2
-rw-r--r--src/mktemp.c2
-rw-r--r--src/mv.c2
-rw-r--r--src/nice.c12
-rw-r--r--src/nl.c2
-rw-r--r--src/nohup.c45
-rw-r--r--src/nproc.c2
-rw-r--r--src/numfmt.c2
-rw-r--r--src/od.c4
-rw-r--r--src/paste.c2
-rw-r--r--src/pathchk.c2
-rw-r--r--src/pinky.c2
-rw-r--r--src/pr.c4
-rw-r--r--src/printenv.c2
-rw-r--r--src/printf.c4
-rw-r--r--src/ptx.c2
-rw-r--r--src/pwd.c4
-rw-r--r--src/readlink.c2
-rw-r--r--src/realpath.c2
-rw-r--r--src/rm.c6
-rw-r--r--src/rmdir.c2
-rw-r--r--src/runcon.c10
-rw-r--r--src/seq.c6
-rw-r--r--src/shred.c2
-rw-r--r--src/shuf.c2
-rw-r--r--src/sleep.c2
-rw-r--r--src/sort.c4
-rw-r--r--src/split.c2
-rw-r--r--src/stat.c2
-rw-r--r--src/stdbuf.c8
-rw-r--r--src/stty.c4
-rw-r--r--src/sum.c2
-rw-r--r--src/sync.c2
-rw-r--r--src/tac.c2
-rw-r--r--src/tail.c6
-rw-r--r--src/tee.c2
-rw-r--r--src/test.c8
-rw-r--r--src/timeout.c13
-rw-r--r--src/touch.c2
-rw-r--r--src/tr.c6
-rw-r--r--src/true.c2
-rw-r--r--src/truncate.c2
-rw-r--r--src/tsort.c2
-rw-r--r--src/tty.c2
-rw-r--r--src/uname.c2
-rw-r--r--src/unexpand.c2
-rw-r--r--src/uniq.c2
-rw-r--r--src/unlink.c2
-rw-r--r--src/uptime.c2
-rw-r--r--src/users.c2
-rw-r--r--src/wc.c2
-rw-r--r--src/who.c2
-rw-r--r--src/whoami.c13
-rw-r--r--src/yes.c5
101 files changed, 202 insertions, 216 deletions
diff --git a/src/base64.c b/src/base64.c
index b06560438..7b4ffdaeb 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -321,5 +321,5 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, "%s", infile);
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/basename.c b/src/basename.c
index 952153994..9bd54d5f3 100644
--- a/src/basename.c
+++ b/src/basename.c
@@ -185,5 +185,5 @@ main (int argc, char **argv)
perform_basename (argv[optind],
optind + 2 == argc ? argv[optind + 1] : NULL, use_nuls);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/cat.c b/src/cat.c
index 8aef79fa0..026348c04 100644
--- a/src/cat.c
+++ b/src/cat.c
@@ -780,5 +780,5 @@ main (int argc, char **argv)
if (have_read_stdin && close (STDIN_FILENO) < 0)
error (EXIT_FAILURE, errno, _("closing standard input"));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/chcon.c b/src/chcon.c
index cda06612f..21375bc6f 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -582,5 +582,5 @@ main (int argc, char **argv)
ok = process_files (argv + optind, bit_flags | FTS_NOSTAT);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/chgrp.c b/src/chgrp.c
index c7297c81b..8da6a36da 100644
--- a/src/chgrp.c
+++ b/src/chgrp.c
@@ -313,5 +313,5 @@ main (int argc, char **argv)
chopt_free (&chopt);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/chmod.c b/src/chmod.c
index 756ec5a46..a37075cb6 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -566,5 +566,5 @@ main (int argc, char **argv)
ok = process_files (argv + optind,
FTS_COMFOLLOW | FTS_PHYSICAL | FTS_DEFER_STAT);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/chown.c b/src/chown.c
index 13a192330..8036d1a8c 100644
--- a/src/chown.c
+++ b/src/chown.c
@@ -326,5 +326,5 @@ main (int argc, char **argv)
chopt_free (&chopt);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/chroot.c b/src/chroot.c
index 418ea673f..757573a2e 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -388,7 +388,7 @@ main (int argc, char **argv)
if (parse_additional_groups (groups, &in_gids, &n_gids, !n_gids) != 0)
{
if (! n_gids)
- exit (EXIT_CANCELED);
+ return EXIT_CANCELED;
/* else look-up outside the chroot worked, then go with those. */
}
else
@@ -428,9 +428,7 @@ main (int argc, char **argv)
/* Execute the given command. */
execvp (argv[0], argv);
- {
- int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
- error (0, errno, _("failed to run command %s"), quote (argv[0]));
- exit (exit_status);
- }
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
+ error (0, errno, _("failed to run command %s"), quote (argv[0]));
+ return exit_status;
}
diff --git a/src/cksum.c b/src/cksum.c
index 8db39a485..baae55ac0 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -102,7 +102,7 @@ main (void)
crc_remainder (i * 5 + 5));
}
printf ("\n};\n");
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
#else /* !CRCTAB */
@@ -312,7 +312,7 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
#endif /* !CRCTAB */
diff --git a/src/comm.c b/src/comm.c
index 5a3eec68f..b5c6840af 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -443,7 +443,7 @@ main (int argc, char **argv)
compare_files (argv + optind);
if (issued_disorder_warning[0] || issued_disorder_warning[1])
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
else
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/coreutils-arch.c b/src/coreutils-arch.c
index 899cc937b..f55bef9d9 100644
--- a/src/coreutils-arch.c
+++ b/src/coreutils-arch.c
@@ -22,11 +22,12 @@
#include "uname.h"
/* Ensure that the main for uname is declared even if the tool is not being
built in this single-binary. */
-int _single_binary_main_uname (int argc, char** argv) ATTRIBUTE_NORETURN;
-int _single_binary_main_arch (int argc, char** argv) ATTRIBUTE_NORETURN;
+int _single_binary_main_uname (int argc, char **argv);
+int _single_binary_main_arch (int argc, char **argv);
-int _single_binary_main_arch (int argc, char** argv)
+int
+_single_binary_main_arch (int argc, char **argv)
{
uname_mode = UNAME_ARCH;
- _single_binary_main_uname (argc, argv);
+ return _single_binary_main_uname (argc, argv);
}
diff --git a/src/coreutils-dir.c b/src/coreutils-dir.c
index 4b488f415..afbe39a50 100644
--- a/src/coreutils-dir.c
+++ b/src/coreutils-dir.c
@@ -22,11 +22,12 @@
#include "ls.h"
/* Ensure that the main for ls is declared even if the tool is not being built
in this single-binary. */
-int _single_binary_main_ls (int argc, char** argv) ATTRIBUTE_NORETURN;
-int _single_binary_main_dir (int argc, char** argv) ATTRIBUTE_NORETURN;
+int _single_binary_main_ls (int argc, char **argv);
+int _single_binary_main_dir (int argc, char **argv);
-int _single_binary_main_dir (int argc, char** argv)
+int
+_single_binary_main_dir (int argc, char **argv)
{
ls_mode = LS_MULTI_COL;
- _single_binary_main_ls (argc, argv);
+ return _single_binary_main_ls (argc, argv);
}
diff --git a/src/coreutils-vdir.c b/src/coreutils-vdir.c
index 036367f6d..b1b0194ee 100644
--- a/src/coreutils-vdir.c
+++ b/src/coreutils-vdir.c
@@ -22,11 +22,12 @@
#include "ls.h"
/* Ensure that the main for ls is declared even if the tool is not being built
in this single-binary. */
-int _single_binary_main_ls (int argc, char** argv) ATTRIBUTE_NORETURN;
-int _single_binary_main_vdir (int argc, char** argv) ATTRIBUTE_NORETURN;
+int _single_binary_main_ls (int argc, char **argv);
+int _single_binary_main_vdir (int argc, char **argv);
-int _single_binary_main_vdir (int argc, char** argv)
+int
+_single_binary_main_vdir (int argc, char** argv)
{
ls_mode = LS_LONG_FORMAT;
- _single_binary_main_ls (argc, argv);
+ return _single_binary_main_ls (argc, argv);
}
diff --git a/src/coreutils.c b/src/coreutils.c
index c459b1d62..898fe8413 100644
--- a/src/coreutils.c
+++ b/src/coreutils.c
@@ -35,7 +35,7 @@
needs to match the one passed as CFLAGS on single-binary.mk (generated
by gen-single-binary.sh). */
# define SINGLE_BINARY_PROGRAM(prog_name_str, main_name) \
- int _single_binary_main_##main_name (int, char**) ATTRIBUTE_NORETURN;
+ int _single_binary_main_##main_name (int, char **);
# include "coreutils.h"
# undef SINGLE_BINARY_PROGRAM
#endif
@@ -46,9 +46,6 @@
#define AUTHORS \
proper_name ("Alex Deymo")
-void
-launch_program (const char *prog_name, int prog_argc, char **prog_argv);
-
static struct option const long_options[] =
{
{GETOPT_HELP_OPTION_DECL},
@@ -92,10 +89,10 @@ Use: '%s --coreutils-prog=PROGRAM_NAME --help' for individual program help.\n"),
exit (status);
}
-void
+static void
launch_program (const char *prog_name, int prog_argc, char **prog_argv)
{
- int (*prog_main)(int, char **) = NULL;
+ int (*prog_main) (int, char **) = NULL;
/* Ensure that at least one parameter was passed. */
if (!prog_argc || !prog_argv || !prog_argv[0] || !prog_name)
@@ -103,7 +100,7 @@ launch_program (const char *prog_name, int prog_argc, char **prog_argv)
#ifdef SINGLE_BINARY
if (false);
- /* Lookup the right main program. */
+ /* Look up the right main program. */
# define SINGLE_BINARY_PROGRAM(prog_name_str, main_name) \
else if (STREQ (prog_name_str, prog_name)) \
prog_main = _single_binary_main_##main_name;
@@ -124,7 +121,7 @@ launch_program (const char *prog_name, int prog_argc, char **prog_argv)
prctl (PR_SET_MM_ARG_START, prog_argv[0]);
#endif
- exit ((*prog_main) (prog_argc, prog_argv));
+ exit (prog_main (prog_argc, prog_argv));
}
int
diff --git a/src/cp.c b/src/cp.c
index 6c7231a87..60be688b7 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -1218,5 +1218,5 @@ main (int argc, char **argv)
forget_all ();
#endif
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/csplit.c b/src/csplit.c
index a30f09b77..f8062ea55 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -1466,7 +1466,7 @@ main (int argc, char **argv)
cleanup_fatal ();
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
void
diff --git a/src/cut.c b/src/cut.c
index 312551f08..bdc723b61 100644
--- a/src/cut.c
+++ b/src/cut.c
@@ -827,5 +827,5 @@ main (int argc, char **argv)
ok = false;
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/date.c b/src/date.c
index ef04cb58c..ba1918f35 100644
--- a/src/date.c
+++ b/src/date.c
@@ -540,7 +540,7 @@ main (int argc, char **argv)
ok &= show_date (format, when);
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* Display the date and/or time in WHEN according to the format specified
diff --git a/src/dd.c b/src/dd.c
index 1e387f3d8..71c334cf8 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -917,12 +917,18 @@ process_signals (void)
}
}
-static void ATTRIBUTE_NORETURN
-quit (int code)
+static void
+finish_up (void)
{
cleanup ();
print_stats ();
process_signals ();
+}
+
+static void ATTRIBUTE_NORETURN
+quit (int code)
+{
+ finish_up ();
exit (code);
}
@@ -2340,5 +2346,6 @@ main (int argc, char **argv)
invalidate_cache (STDOUT_FILENO, 0);
}
- quit (exit_status);
+ finish_up ();
+ return exit_status;
}
diff --git a/src/df.c b/src/df.c
index e907b9409..a7776652b 100644
--- a/src/df.c
+++ b/src/df.c
@@ -1620,7 +1620,7 @@ main (int argc, char **argv)
}
}
if (match)
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (optind < argc)
@@ -1714,5 +1714,5 @@ main (int argc, char **argv)
IF_LINT (free (columns));
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/dircolors.c b/src/dircolors.c
index 996053678..5544419ac 100644
--- a/src/dircolors.c
+++ b/src/dircolors.c
@@ -503,5 +503,5 @@ main (int argc, char **argv)
}
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/dirname.c b/src/dirname.c
index e0599a36a..5a268e1c2 100644
--- a/src/dirname.c
+++ b/src/dirname.c
@@ -132,5 +132,5 @@ main (int argc, char **argv)
putchar (use_nuls ? '\0' :'\n');
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/du.c b/src/du.c
index 0966326b5..5466e17f4 100644
--- a/src/du.c
+++ b/src/du.c
@@ -1108,5 +1108,5 @@ main (int argc, char **argv)
if (print_grand_total)
print_size (&tot_dui, _("total"));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/echo.c b/src/echo.c
index 93f4a820e..63b263ed7 100644
--- a/src/echo.c
+++ b/src/echo.c
@@ -136,7 +136,7 @@ main (int argc, char **argv)
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
(char *) NULL);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
}
@@ -204,7 +204,7 @@ just_echo:
{
case 'a': c = '\a'; break;
case 'b': c = '\b'; break;
- case 'c': exit (EXIT_SUCCESS);
+ case 'c': return EXIT_SUCCESS;
case 'e': c = '\x1B'; break;
case 'f': c = '\f'; break;
case 'n': c = '\n'; break;
@@ -268,5 +268,5 @@ just_echo:
if (display_return)
putchar ('\n');
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/env.c b/src/env.c
index 2b37d986e..b776052c6 100644
--- a/src/env.c
+++ b/src/env.c
@@ -144,7 +144,7 @@ main (int argc, char **argv)
char *const *e = environ;
while (*e)
printf ("%s%c", *e++, opt_nul_terminate_output ? '\0' : '\n');
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
if (opt_nul_terminate_output)
@@ -155,9 +155,7 @@ main (int argc, char **argv)
execvp (argv[optind], &argv[optind]);
- {
- int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
- error (0, errno, "%s", argv[optind]);
- exit (exit_status);
- }
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
+ error (0, errno, "%s", argv[optind]);
+ return exit_status;
}
diff --git a/src/expand.c b/src/expand.c
index 082b5d4ef..bbaf0e7fd 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -426,5 +426,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/expr.c b/src/expr.c
index a97663a1d..bbf325196 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -326,7 +326,7 @@ main (int argc, char **argv)
syntax_error ();
printv (v);
- exit (null (v));
+ return null (v);
}
/* Return a VALUE for I. */
diff --git a/src/factor.c b/src/factor.c
index f7beaeb94..f636e36f1 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -2543,5 +2543,5 @@ main (int argc, char **argv)
}
#endif
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/fmt.c b/src/fmt.c
index dbd180b45..3ee04d99a 100644
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -456,7 +456,7 @@ main (int argc, char **argv)
}
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* Trim space from the front and back of the string P, yielding the prefix,
diff --git a/src/fold.c b/src/fold.c
index 444dc8b46..1f03c2ea6 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -311,5 +311,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/getlimits.c b/src/getlimits.c
index 597efd82b..3a7d7e150 100644
--- a/src/getlimits.c
+++ b/src/getlimits.c
@@ -167,4 +167,6 @@ main (int argc, char **argv)
print_float (FLT);
print_float (DBL);
print_float (LDBL);
+
+ return EXIT_SUCCESS;
}
diff --git a/src/groups.c b/src/groups.c
index f19ff0acc..c904f3250 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -136,5 +136,5 @@ main (int argc, char **argv)
}
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/head.c b/src/head.c
index 65bd52a1f..09bc33d0d 100644
--- a/src/head.c
+++ b/src/head.c
@@ -1066,5 +1066,5 @@ main (int argc, char **argv)
if (have_read_stdin && close (STDIN_FILENO) < 0)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/hostid.c b/src/hostid.c
index 5b40eb016..867181285 100644
--- a/src/hostid.c
+++ b/src/hostid.c
@@ -84,5 +84,5 @@ main (int argc, char **argv)
printf ("%08x\n", id);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/hostname.c b/src/hostname.c
index bab51ae4a..9ef759863 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -112,5 +112,5 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/id.c b/src/id.c
index ccd1e879a..33445a000 100644
--- a/src/id.c
+++ b/src/id.c
@@ -314,7 +314,7 @@ main (int argc, char **argv)
putchar (opt_zero ? '\0' : '\n');
IF_LINT (free (pw_name));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* Convert a gid_t to string. Do not use this function directly.
diff --git a/src/install.c b/src/install.c
index c3424227b..db4ee457d 100644
--- a/src/install.c
+++ b/src/install.c
@@ -1042,5 +1042,5 @@ main (int argc, char **argv)
}
}
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/join.c b/src/join.c
index 5c26e78aa..965ab4900 100644
--- a/src/join.c
+++ b/src/join.c
@@ -1191,7 +1191,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, "%s", g_names[1]);
if (issued_disorder_warning[0] || issued_disorder_warning[1])
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
else
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/kill.c b/src/kill.c
index 724667e0e..4ab86a48f 100644
--- a/src/kill.c
+++ b/src/kill.c
@@ -306,7 +306,7 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- exit (list
- ? list_signals (table, optind < argc ? argv + optind : NULL)
- : send_signals (signum, argv + optind));
+ return (list
+ ? list_signals (table, optind < argc ? argv + optind : NULL)
+ : send_signals (signum, argv + optind));
}
diff --git a/src/link.c b/src/link.c
index 9f18fe2e5..6f3a297a0 100644
--- a/src/link.c
+++ b/src/link.c
@@ -90,5 +90,5 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("cannot create link %s to %s"),
quote_n (0, argv[optind + 1]), quote_n (1, argv[optind]));
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/ln.c b/src/ln.c
index 42bccfce7..5140e92dc 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -647,5 +647,5 @@ main (int argc, char **argv)
else
ok = do_link (file[0], file[1]);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/logname.c b/src/logname.c
index 6afa1b50f..368c4c9e9 100644
--- a/src/logname.c
+++ b/src/logname.c
@@ -72,15 +72,12 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- /* POSIX requires using getlogin (or equivalent code). */
+ /* POSIX requires using getlogin (or equivalent code) and prohibits
+ using a fallback technique. */
cp = getlogin ();
- if (cp)
- {
- puts (cp);
- exit (EXIT_SUCCESS);
- }
- /* POSIX prohibits using a fallback technique. */
+ if (! cp)
+ error (EXIT_FAILURE, 0, _("no login name"));
- error (0, 0, _("no login name"));
- exit (EXIT_FAILURE);
+ puts (cp);
+ return EXIT_SUCCESS;
}
diff --git a/src/ls.c b/src/ls.c
index a45cfc174..94276b65b 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1513,7 +1513,7 @@ main (int argc, char **argv)
hash_free (active_dir_set);
}
- exit (exit_status);
+ return exit_status;
}
/* Set all the option flags according to the switches specified.
diff --git a/src/make-prime-list.c b/src/make-prime-list.c
index c01b12001..5c79acecb 100644
--- a/src/make-prime-list.c
+++ b/src/make-prime-list.c
@@ -187,7 +187,7 @@ main (int argc, char **argv)
}
limit = atoi (argv[1]);
if (limit < 3)
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
/* Make limit odd */
if ( !(limit & 1))
diff --git a/src/md5sum.c b/src/md5sum.c
index cc6dd49e9..cd27e8060 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -874,5 +874,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, _("standard input"));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/mkdir.c b/src/mkdir.c
index eb9693cc9..70bca07b5 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -301,6 +301,6 @@ main (int argc, char **argv)
options.mode = S_IRWXUGO;
}
- exit (savewd_process_files (argc - optind, argv + optind,
- process_dir, &options));
+ return savewd_process_files (argc - optind, argv + optind,
+ process_dir, &options);
}
diff --git a/src/mkfifo.c b/src/mkfifo.c
index 415ae562f..632472983 100644
--- a/src/mkfifo.c
+++ b/src/mkfifo.c
@@ -177,5 +177,5 @@ main (int argc, char **argv)
}
}
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/mknod.c b/src/mknod.c
index 8f547e9c6..797e6bbf1 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -269,5 +269,5 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("cannot set permissions of %s"),
quote (argv[optind]));
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/mktemp.c b/src/mktemp.c
index 2bd80bae7..d36e502c1 100644
--- a/src/mktemp.c
+++ b/src/mktemp.c
@@ -345,5 +345,5 @@ main (int argc, char **argv)
free (template);
#endif
- exit (status);
+ return status;
}
diff --git a/src/mv.c b/src/mv.c
index 1db404ffb..b71d210f3 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -508,5 +508,5 @@ main (int argc, char **argv)
else
ok = movefile (file[0], file[1], false, &x);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/nice.c b/src/nice.c
index 488ef95ac..91e8f99fe 100644
--- a/src/nice.c
+++ b/src/nice.c
@@ -187,7 +187,7 @@ main (int argc, char **argv)
if (current_niceness == -1 && errno != 0)
error (EXIT_CANCELED, errno, _("cannot get niceness"));
printf ("%d\n", current_niceness);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
errno = 0;
@@ -209,14 +209,12 @@ main (int argc, char **argv)
encountered a write failure, there is no need to try calling
error() again. */
if (ferror (stderr))
- exit (EXIT_CANCELED);
+ return EXIT_CANCELED;
}
execvp (argv[i], &argv[i]);
- {
- int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
- error (0, errno, "%s", argv[i]);
- exit (exit_status);
- }
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
+ error (0, errno, "%s", argv[i]);
+ return exit_status;
}
diff --git a/src/nl.c b/src/nl.c
index 982f468e5..d45dcbd6c 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -612,5 +612,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/nohup.c b/src/nohup.c
index eca1f5124..13bb04531 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -123,10 +123,8 @@ main (int argc, char **argv)
if (ignoring_input)
{
if (fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0) < 0)
- {
- error (0, errno, _("failed to render standard input unusable"));
- exit (exit_internal_failure);
- }
+ error (exit_internal_failure, errno,
+ _("failed to render standard input unusable"));
if (!redirecting_stdout && !redirecting_stderr)
error (0, 0, _("ignoring input"));
}
@@ -164,7 +162,7 @@ main (int argc, char **argv)
if (in_home)
error (0, saved_errno2, _("failed to open %s"),
quote (in_home));
- exit (exit_internal_failure);
+ return exit_internal_failure;
}
file = in_home;
}
@@ -213,28 +211,23 @@ main (int argc, char **argv)
error() again, particularly since we may have just changed the
underlying fd out from under stderr. */
if (ferror (stderr))
- exit (exit_internal_failure);
+ return exit_internal_failure;
signal (SIGHUP, SIG_IGN);
- {
- int exit_status;
- int saved_errno;
- char **cmd = argv + optind;
-
- execvp (*cmd, cmd);
- exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
- saved_errno = errno;
-
- /* The execve failed. Output a diagnostic to stderr only if:
- - stderr was initially redirected to a non-tty, or
- - stderr was initially directed to a tty, and we
- can dup2 it to point back to that same tty.
- In other words, output the diagnostic if possible, but only if
- it will go to the original stderr. */
- if (dup2 (saved_stderr_fd, STDERR_FILENO) == STDERR_FILENO)
- error (0, saved_errno, _("failed to run command %s"), quote (*cmd));
-
- exit (exit_status);
- }
+ char **cmd = argv + optind;
+ execvp (*cmd, cmd);
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
+ int saved_errno = errno;
+
+ /* The execve failed. Output a diagnostic to stderr only if:
+ - stderr was initially redirected to a non-tty, or
+ - stderr was initially directed to a tty, and we
+ can dup2 it to point back to that same tty.
+ In other words, output the diagnostic if possible, but only if
+ it will go to the original stderr. */
+ if (dup2 (saved_stderr_fd, STDERR_FILENO) == STDERR_FILENO)
+ error (0, saved_errno, _("failed to run command %s"), quote (*cmd));
+
+ return exit_status;
}
diff --git a/src/nproc.c b/src/nproc.c
index 9bfc8b398..44ee483d6 100644
--- a/src/nproc.c
+++ b/src/nproc.c
@@ -129,5 +129,5 @@ main (int argc, char **argv)
printf ("%lu\n", nproc);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/numfmt.c b/src/numfmt.c
index b524e65bf..f1113748f 100644
--- a/src/numfmt.c
+++ b/src/numfmt.c
@@ -1538,5 +1538,5 @@ main (int argc, char **argv)
if (!valid_numbers && _invalid != inval_warn && _invalid != inval_ignore)
exit_status = EXIT_CONVERSION_WARNINGS;
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/od.c b/src/od.c
index 7bc0e2a8b..c32d785aa 100644
--- a/src/od.c
+++ b/src/od.c
@@ -1781,7 +1781,7 @@ main (int argc, char **argv)
}
if (!ok)
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
if (flag_dump_strings && n_specs > 0)
error (EXIT_FAILURE, 0,
@@ -1972,5 +1972,5 @@ cleanup:
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, _("standard input"));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/paste.c b/src/paste.c
index 3663aaf6e..8f8f465b4 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -518,5 +518,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/pathchk.c b/src/pathchk.c
index 4b3884fe3..3cb8bef62 100644
--- a/src/pathchk.c
+++ b/src/pathchk.c
@@ -153,7 +153,7 @@ main (int argc, char **argv)
ok &= validate_file_name (argv[optind],
check_basic_portability, check_extra_portability);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* If FILE contains a component with a leading "-", report an error
diff --git a/src/pinky.c b/src/pinky.c
index c48e17054..154b6aafb 100644
--- a/src/pinky.c
+++ b/src/pinky.c
@@ -604,5 +604,5 @@ main (int argc, char **argv)
else
long_pinky (n_users, argv + optind);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/pr.c b/src/pr.c
index 1515b4a47..a3dc9bf1c 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -1170,9 +1170,7 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, _("standard input"));
- if (failed_opens)
- exit (EXIT_FAILURE);
- exit (EXIT_SUCCESS);
+ return failed_opens ? EXIT_FAILURE : EXIT_SUCCESS;
}
/* Parse options of the form -scNNN.
diff --git a/src/printenv.c b/src/printenv.c
index e1faeb5fd..0646c7009 100644
--- a/src/printenv.c
+++ b/src/printenv.c
@@ -150,5 +150,5 @@ main (int argc, char **argv)
ok = (matches == argc - optind);
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/printf.c b/src/printf.c
index 7d523100f..3d303be70 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -657,7 +657,7 @@ main (int argc, char **argv)
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
(char *) NULL);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
}
@@ -692,5 +692,5 @@ main (int argc, char **argv)
_("warning: ignoring excess arguments, starting with %s"),
quote (argv[0]));
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/ptx.c b/src/ptx.c
index d165e9665..39ac5e4b0 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -2155,5 +2155,5 @@ main (int argc, char **argv)
/* All done. */
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/pwd.c b/src/pwd.c
index d126ed754..9bbd78743 100644
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -372,7 +372,7 @@ main (int argc, char **argv)
if (wd)
{
puts (wd);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
}
@@ -390,5 +390,5 @@ main (int argc, char **argv)
file_name_free (file_name);
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/readlink.c b/src/readlink.c
index f46d948e1..d63f07b40 100644
--- a/src/readlink.c
+++ b/src/readlink.c
@@ -174,5 +174,5 @@ main (int argc, char **argv)
}
}
- exit (status);
+ return status;
}
diff --git a/src/realpath.c b/src/realpath.c
index 0c5532710..930530cd4 100644
--- a/src/realpath.c
+++ b/src/realpath.c
@@ -273,5 +273,5 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
ok &= process_path (argv[optind], can_mode);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/rm.c b/src/rm.c
index 708d85d21..7ab1c07e9 100644
--- a/src/rm.c
+++ b/src/rm.c
@@ -315,7 +315,7 @@ main (int argc, char **argv)
if (argc <= optind)
{
if (x.ignore_missing_files)
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
else
{
error (0, 0, _("missing operand"));
@@ -347,10 +347,10 @@ main (int argc, char **argv)
select_plural (n_files))),
program_name, n_files);
if (!yesno ())
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
enum RM_status status = rm (file, &x);
assert (VALID_STATUS (status));
- exit (status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS);
+ return status == RM_ERROR ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/rmdir.c b/src/rmdir.c
index e67d3b002..6bdfb0fc2 100644
--- a/src/rmdir.c
+++ b/src/rmdir.c
@@ -248,5 +248,5 @@ main (int argc, char **argv)
}
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/runcon.c b/src/runcon.c
index 14ccc3d58..efe83f28c 100644
--- a/src/runcon.c
+++ b/src/runcon.c
@@ -177,7 +177,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("failed to get current context"));
fputs (cur_context, stdout);
fputc ('\n', stdout);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
if (!(user || role || type || range || compute_trans))
@@ -258,9 +258,7 @@ main (int argc, char **argv)
execvp (argv[optind], argv + optind);
- {
- int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
- error (0, errno, "%s", argv[optind]);
- exit (exit_status);
- }
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
+ error (0, errno, "%s", argv[optind]);
+ return exit_status;
}
diff --git a/src/seq.c b/src/seq.c
index 1124358cf..7943824d1 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -574,7 +574,7 @@ main (int argc, char **argv)
char const *s1 = n_args == 1 ? "1" : argv[optind];
char const *s2 = argv[optind + (n_args - 1)];
if (seq_fast (s1, s2))
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
/* Upon any failure, let the more general code deal with it. */
}
@@ -608,7 +608,7 @@ main (int argc, char **argv)
{
IF_LINT (free (s1));
IF_LINT (free (s2));
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
free (s1);
@@ -621,5 +621,5 @@ main (int argc, char **argv)
print_numbers (format_str, layout, first.value, step.value, last.value);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/shred.c b/src/shred.c
index bd88e3831..d17c870f8 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -1318,7 +1318,7 @@ main (int argc, char **argv)
free (qname);
}
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
/*
* vim:sw=2:sts=2:
diff --git a/src/shuf.c b/src/shuf.c
index 2505be6f1..915f7b7a5 100644
--- a/src/shuf.c
+++ b/src/shuf.c
@@ -622,5 +622,5 @@ main (int argc, char **argv)
}
#endif
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/sleep.c b/src/sleep.c
index e24c25120..10fd989b5 100644
--- a/src/sleep.c
+++ b/src/sleep.c
@@ -145,5 +145,5 @@ main (int argc, char **argv)
if (xnanosleep (seconds))
error (EXIT_FAILURE, errno, _("cannot read realtime clock"));
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/sort.c b/src/sort.c
index c24931920..deb7c3a5b 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -4708,7 +4708,7 @@ main (int argc, char **argv)
/* POSIX requires that sort return 1 IFF invoked with -c or -C and the
input is not properly sorted. */
- exit (check (files[0], checkonly) ? EXIT_SUCCESS : SORT_OUT_OF_ORDER);
+ return check (files[0], checkonly) ? EXIT_SUCCESS : SORT_OUT_OF_ORDER;
}
/* Check all inputs are accessible, or exit immediately. */
@@ -4746,5 +4746,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
die (_("close failed"), "-");
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/split.c b/src/split.c
index dacacaa88..36295c42e 100644
--- a/src/split.c
+++ b/src/split.c
@@ -1488,5 +1488,5 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, "%s", infile);
closeout (NULL, output_desc, filter_pid, outfile);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/stat.c b/src/stat.c
index b65dbe556..c78ab70d0 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1575,5 +1575,5 @@ main (int argc, char *argv[])
? do_statfs (argv[i], format)
: do_stat (argv[i], format, format2));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/stdbuf.c b/src/stdbuf.c
index 92ee28267..c8398abc6 100644
--- a/src/stdbuf.c
+++ b/src/stdbuf.c
@@ -387,9 +387,7 @@ main (int argc, char **argv)
execvp (*argv, argv);
- {
- int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
- error (0, errno, _("failed to run command %s"), quote (argv[0]));
- exit (exit_status);
- }
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
+ error (0, errno, _("failed to run command %s"), quote (argv[0]));
+ return exit_status;
}
diff --git a/src/stty.c b/src/stty.c
index 3c4857865..4843b9b96 100644
--- a/src/stty.c
+++ b/src/stty.c
@@ -862,7 +862,7 @@ main (int argc, char **argv)
max_col = screen_columns ();
current_col = 0;
display_settings (output_type, &mode, device_name);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
speed_was_set = false;
@@ -1070,7 +1070,7 @@ main (int argc, char **argv)
}
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
/* Return false if not applied because not reversible; otherwise
diff --git a/src/sum.c b/src/sum.c
index 442b7ad8a..5c502ceb9 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -270,5 +270,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/sync.c b/src/sync.c
index 8c8904320..b706fbe93 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -69,5 +69,5 @@ main (int argc, char **argv)
error (0, 0, _("ignoring all arguments"));
sync ();
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/tac.c b/src/tac.c
index c76afc770..ba055a016 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -699,5 +699,5 @@ main (int argc, char **argv)
free (G_buffer - offset);
#endif
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/tail.c b/src/tail.c
index 5ff738df8..7dd3f4a44 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -2218,7 +2218,7 @@ main (int argc, char **argv)
/* Don't read anything if we'll never output anything. */
if (! n_units && ! forever && ! from_start)
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
F = xnmalloc (n_files, sizeof *F);
for (i = 0; i < n_files; i++)
@@ -2286,7 +2286,7 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("write error"));
if (!tail_forever_inotify (wd, F, n_files, sleep_interval))
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
}
error (0, errno, _("inotify cannot be used, reverting to polling"));
}
@@ -2297,5 +2297,5 @@ main (int argc, char **argv)
if (have_read_stdin && close (STDIN_FILENO) < 0)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/tee.c b/src/tee.c
index be365604d..821d825fe 100644
--- a/src/tee.c
+++ b/src/tee.c
@@ -125,7 +125,7 @@ main (int argc, char **argv)
if (close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, _("standard input"));
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
/* Copy the standard input into each of the NFILES files in FILES
diff --git a/src/test.c b/src/test.c
index 75968798c..24bcb93c0 100644
--- a/src/test.c
+++ b/src/test.c
@@ -57,10 +57,12 @@ enum { TEST_TRUE, TEST_FALSE, TEST_FAILURE };
#if defined TEST_STANDALONE
# define test_exit(val) exit (val)
+# define test_main_return(val) return val
#else
static jmp_buf test_exit_buf;
static int test_error_return = 0;
# define test_exit(val) test_error_return = val, longjmp (test_exit_buf, 1)
+# define test_main_return(val) test_exit (val)
#endif /* !TEST_STANDALONE */
static int pos; /* The offset of the current argument in ARGV. */
@@ -851,7 +853,7 @@ main (int margc, char **margv)
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
(char *) NULL);
- test_exit (EXIT_SUCCESS);
+ test_main_return (EXIT_SUCCESS);
}
}
if (margc < 2 || !STREQ (margv[margc - 1], "]"))
@@ -864,12 +866,12 @@ main (int margc, char **margv)
pos = 1;
if (pos >= argc)
- test_exit (TEST_FALSE);
+ test_main_return (TEST_FALSE);
value = posixtest (argc - 1);
if (pos != argc)
test_syntax_error (_("extra argument %s"), quote (argv[pos]));
- test_exit (value ? TEST_TRUE : TEST_FALSE);
+ test_main_return (value ? TEST_TRUE : TEST_FALSE);
}
diff --git a/src/timeout.c b/src/timeout.c
index 68baa23ce..c4cc07407 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -440,12 +440,10 @@ main (int argc, char **argv)
if (monitored_pid == -1)
{
error (0, errno, _("fork system call failed"));
- exit (EXIT_CANCELED);
+ return EXIT_CANCELED;
}
else if (monitored_pid == 0)
{ /* child */
- int exit_status;
-
/* exec doesn't reset SIG_IGN -> SIG_DFL. */
signal (SIGTTIN, SIG_DFL);
signal (SIGTTOU, SIG_DFL);
@@ -453,9 +451,9 @@ main (int argc, char **argv)
execvp (argv[0], argv); /* FIXME: should we use "sh -c" ... here? */
/* exit like sh, env, nohup, ... */
- exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
+ int exit_status = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
error (0, errno, _("failed to run command %s"), quote (argv[0]));
- exit (exit_status);
+ return exit_status;
}
else
{
@@ -500,8 +498,7 @@ main (int argc, char **argv)
}
if (timed_out && !preserve_status)
- exit (EXIT_TIMEDOUT);
- else
- exit (status);
+ status = EXIT_TIMEDOUT;
+ return status;
}
}
diff --git a/src/touch.c b/src/touch.c
index 1ba24269b..b128e8836 100644
--- a/src/touch.c
+++ b/src/touch.c
@@ -433,5 +433,5 @@ main (int argc, char **argv)
for (; optind < argc; ++optind)
ok &= touch (argv[optind]);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/tr.c b/src/tr.c
index 06858f91d..5905a63f0 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -1804,13 +1804,13 @@ main (int argc, char **argv)
spec_init (s1);
if (!parse_str (argv[optind], s1))
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
if (non_option_args == 2)
{
spec_init (s2);
if (!parse_str (argv[optind + 1], s2))
- exit (EXIT_FAILURE);
+ return EXIT_FAILURE;
}
else
s2 = NULL;
@@ -1944,5 +1944,5 @@ main (int argc, char **argv)
if (close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, _("standard input"));
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/true.c b/src/true.c
index 8a1c4f920..ea4833a64 100644
--- a/src/true.c
+++ b/src/true.c
@@ -76,5 +76,5 @@ main (int argc, char **argv)
(char *) NULL);
}
- exit (EXIT_STATUS);
+ return EXIT_STATUS;
}
diff --git a/src/truncate.c b/src/truncate.c
index f31250920..44d0b9670 100644
--- a/src/truncate.c
+++ b/src/truncate.c
@@ -420,5 +420,5 @@ main (int argc, char **argv)
}
}
- exit (errors ? EXIT_FAILURE : EXIT_SUCCESS);
+ return errors ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/tsort.c b/src/tsort.c
index 661c71730..8380ce809 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -557,5 +557,5 @@ main (int argc, char **argv)
ok = tsort (optind == argc ? "-" : argv[optind]);
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/tty.c b/src/tty.c
index 16301e12b..f8c255458 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -120,5 +120,5 @@ main (int argc, char **argv)
puts (_("not a tty"));
}
- exit (isatty (STDIN_FILENO) ? EXIT_SUCCESS : EXIT_FAILURE);
+ return isatty (STDIN_FILENO) ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/uname.c b/src/uname.c
index e3bed488c..3cc3cbae5 100644
--- a/src/uname.c
+++ b/src/uname.c
@@ -371,5 +371,5 @@ main (int argc, char **argv)
putchar ('\n');
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/unexpand.c b/src/unexpand.c
index 505e223cd..03c9a2ef3 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -528,5 +528,5 @@ main (int argc, char **argv)
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
- exit (exit_status);
+ return exit_status;
}
diff --git a/src/uniq.c b/src/uniq.c
index 54200ff45..358d06c63 100644
--- a/src/uniq.c
+++ b/src/uniq.c
@@ -662,5 +662,5 @@ main (int argc, char **argv)
check_file (file[0], file[1], delimiter);
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/unlink.c b/src/unlink.c
index 260a53015..a05aa324e 100644
--- a/src/unlink.c
+++ b/src/unlink.c
@@ -85,5 +85,5 @@ main (int argc, char **argv)
if (unlink (argv[optind]) != 0)
error (EXIT_FAILURE, errno, _("cannot unlink %s"), quote (argv[optind]));
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/uptime.c b/src/uptime.c
index 4ab914f30..93931d233 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -253,5 +253,5 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/users.c b/src/users.c
index ee44c815d..a0dce1912 100644
--- a/src/users.c
+++ b/src/users.c
@@ -147,5 +147,5 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/wc.c b/src/wc.c
index 4909d9fe8..204802543 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -797,5 +797,5 @@ main (int argc, char **argv)
if (have_read_stdin && close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, "-");
- exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
+ return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/src/who.c b/src/who.c
index f07cee61c..23e251156 100644
--- a/src/who.c
+++ b/src/who.c
@@ -828,5 +828,5 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- exit (EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
diff --git a/src/whoami.c b/src/whoami.c
index 7301abb14..545e52134 100644
--- a/src/whoami.c
+++ b/src/whoami.c
@@ -83,12 +83,9 @@ main (int argc, char **argv)
errno = 0;
uid = geteuid ();
pw = (uid == NO_UID && errno ? NULL : getpwuid (uid));
- if (pw)
- {
- puts (pw->pw_name);
- exit (EXIT_SUCCESS);
- }
- fprintf (stderr, _("%s: cannot find name for user ID %lu\n"),
- program_name, (unsigned long int) uid);
- exit (EXIT_FAILURE);
+ if (!pw)
+ error (EXIT_FAILURE, errno, "cannot find name for user ID %lu",
+ (unsigned long int) uid);
+ puts (pw->pw_name);
+ return EXIT_SUCCESS;
}
diff --git a/src/yes.c b/src/yes.c
index 972131245..e5957b9e9 100644
--- a/src/yes.c
+++ b/src/yes.c
@@ -83,6 +83,9 @@ main (int argc, char **argv)
for (i = optind; i < argc; i++)
if (fputs (argv[i], stdout) == EOF
|| putchar (i == argc - 1 ? '\n' : ' ') == EOF)
- error (EXIT_FAILURE, errno, _("standard output"));
+ {
+ error (0, errno, _("standard output"));
+ return EXIT_FAILURE;
+ }
}
}