From 492dcb2eb191b844a2fd5e51db3eed85289bea1f Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Sat, 15 Oct 2016 23:10:35 +0100 Subject: 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, ...); --- src/head.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/head.c') 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; } -- cgit v1.2.3-54-g00ecf