summaryrefslogtreecommitdiff
path: root/cfg.mk
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 /cfg.mk
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 'cfg.mk')
-rw-r--r--cfg.mk10
1 files changed, 10 insertions, 0 deletions
diff --git a/cfg.mk b/cfg.mk
index 9acb42c34..ece6efa88 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -226,6 +226,16 @@ sc_error_shell_always_quotes:
exit 1; } \
|| :
+# Usage of error() with an exit constant, should instead use die(),
+# as that avoids warnings and may generate better code, due to being apparent
+# to the compiler that it doesn't return.
+sc_die_EXIT_FAILURE:
+ @cd $(srcdir)/src && GIT_PAGER= git grep -E \
+ 'error \(.*_(FAILURE|INVALID)' \
+ && { echo '$(ME): '"Use die() instead of error" 1>&2; \
+ exit 1; } \
+ || :
+
# Avoid unstyled quoting to internal slots and thus destined for diagnostics
# as that can leak unescaped control characters to the output, when using
# the default "literal" quoting style.