diff options
author | Pádraig Brady <P@draigBrady.com> | 2016-10-15 23:10:35 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2016-10-16 12:23:55 +0100 |
commit | 492dcb2eb191b844a2fd5e51db3eed85289bea1f (patch) | |
tree | 910f93d88891b573520ebd5c812d61ddc7fbeed8 /src/wc.c | |
parent | d035eacfdeba2da0134e606c8a63b2f3c0bd05bb (diff) | |
download | coreutils-492dcb2eb191b844a2fd5e51db3eed85289bea1f.tar.xz |
all: use die() rather than error(EXIT_FAILURE)
die() has the advantage of being apparent to the compiler
that it doesn't return, which will avoid warnings in some cases,
and possibly generate better code.
* cfg.mk (sc_die_EXIT_FAILURE): A new syntax check rule to
catch any new uses of error (CONSTANT, ...);
Diffstat (limited to 'src/wc.c')
-rw-r--r-- | src/wc.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -28,6 +28,7 @@ #include "system.h" #include "argv-iter.h" +#include "die.h" #include "error.h" #include "fadvise.h" #include "mbchar.h" @@ -707,8 +708,8 @@ main (int argc, char **argv) { stream = fopen (files_from, "r"); if (stream == NULL) - error (EXIT_FAILURE, errno, _("cannot open %s for reading"), - quoteaf (files_from)); + die (EXIT_FAILURE, errno, _("cannot open %s for reading"), + quoteaf (files_from)); } /* Read the file list into RAM if we can detect its size and that @@ -721,8 +722,8 @@ main (int argc, char **argv) read_tokens = true; readtokens0_init (&tok); if (! readtokens0 (stream, &tok) || fclose (stream) != 0) - error (EXIT_FAILURE, 0, _("cannot read file names from %s"), - quoteaf (files_from)); + die (EXIT_FAILURE, 0, _("cannot read file names from %s"), + quoteaf (files_from)); files = tok.tok; nfiles = tok.n_tok; ai = argv_iter_init_argv (files); @@ -827,7 +828,7 @@ main (int argc, char **argv) free (fstatus); if (have_read_stdin && close (STDIN_FILENO) != 0) - error (EXIT_FAILURE, errno, "-"); + die (EXIT_FAILURE, errno, "-"); return ok ? EXIT_SUCCESS : EXIT_FAILURE; } |