summaryrefslogtreecommitdiff
path: root/src/head.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-10-15 23:10:35 +0100
committerPádraig Brady <P@draigBrady.com>2016-10-16 12:23:55 +0100
commit492dcb2eb191b844a2fd5e51db3eed85289bea1f (patch)
tree910f93d88891b573520ebd5c812d61ddc7fbeed8 /src/head.c
parentd035eacfdeba2da0134e606c8a63b2f3c0bd05bb (diff)
downloadcoreutils-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/head.c')
-rw-r--r--src/head.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/head.c b/src/head.c
index 282c2ea8d..21ace70b4 100644
--- a/src/head.c
+++ b/src/head.c
@@ -31,6 +31,7 @@
#include "system.h"
+#include "die.h"
#include "error.h"
#include "full-read.h"
#include "quote.h"
@@ -180,8 +181,8 @@ xwrite_stdout (char const *buffer, size_t n_bytes)
if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) < n_bytes)
{
clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */
- error (EXIT_FAILURE, errno, _("error writing %s"),
- quoteaf ("standard output"));
+ die (EXIT_FAILURE, errno, _("error writing %s"),
+ quoteaf ("standard output"));
}
}
@@ -270,8 +271,8 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0,
if (SIZE_MAX < n_elide_0 + READ_BUFSIZE)
{
char umax_buf[INT_BUFSIZE_BOUND (n_elide_0)];
- error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
- umaxtostr (n_elide_0, umax_buf));
+ die (EXIT_FAILURE, 0, _("%s: number of bytes is too large"),
+ umaxtostr (n_elide_0, umax_buf));
}
/* Two cases to consider...
@@ -1074,8 +1075,8 @@ main (int argc, char **argv)
if ( ! count_lines && elide_from_end && OFF_T_MAX < n_units)
{
char umax_buf[INT_BUFSIZE_BOUND (n_units)];
- error (EXIT_FAILURE, EOVERFLOW, "%s: %s", _("invalid number of bytes"),
- quote (umaxtostr (n_units, umax_buf)));
+ die (EXIT_FAILURE, EOVERFLOW, "%s: %s", _("invalid number of bytes"),
+ quote (umaxtostr (n_units, umax_buf)));
}
file_list = (optind < argc
@@ -1089,7 +1090,7 @@ main (int argc, char **argv)
ok &= head_file (file_list[i], n_units, count_lines, elide_from_end);
if (have_read_stdin && close (STDIN_FILENO) < 0)
- error (EXIT_FAILURE, errno, "-");
+ die (EXIT_FAILURE, errno, "-");
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}