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/touch.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/touch.c') diff --git a/src/touch.c b/src/touch.c index b851b6ffd..901b2750e 100644 --- a/src/touch.c +++ b/src/touch.c @@ -25,6 +25,7 @@ #include "system.h" #include "argmatch.h" +#include "die.h" #include "error.h" #include "fd-reopen.h" #include "parse-datetime.h" @@ -112,7 +113,7 @@ get_reldate (struct timespec *result, char const *flex_date, struct timespec const *now) { if (! parse_datetime (result, flex_date, now)) - error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date)); + die (EXIT_FAILURE, 0, _("invalid date format %s"), quote (flex_date)); } /* Update the time of file FILE according to the options given. @@ -306,8 +307,8 @@ main (int argc, char **argv) case 't': if (! posixtime (&newtime[0].tv_sec, optarg, PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)) - error (EXIT_FAILURE, 0, _("invalid date format %s"), - quote (optarg)); + die (EXIT_FAILURE, 0, _("invalid date format %s"), + quote (optarg)); newtime[0].tv_nsec = 0; newtime[1] = newtime[0]; date_set = true; @@ -343,8 +344,8 @@ main (int argc, char **argv) might be an object-like macro. */ if (no_dereference ? lstat (ref_file, &ref_stats) : stat (ref_file, &ref_stats)) - error (EXIT_FAILURE, errno, - _("failed to get attributes of %s"), quoteaf (ref_file)); + die (EXIT_FAILURE, errno, + _("failed to get attributes of %s"), quoteaf (ref_file)); newtime[0] = get_stat_atime (&ref_stats); newtime[1] = get_stat_mtime (&ref_stats); date_set = true; -- cgit v1.2.3-70-g09d2