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/touch.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/touch.c')
-rw-r--r-- | src/touch.c | 11 |
1 files changed, 6 insertions, 5 deletions
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; |