error_errno: use constant return similar to error()
authorJeff King <peff@peff.net>
Wed, 31 Aug 2016 03:41:22 +0000 (23:41 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 31 Aug 2016 18:11:54 +0000 (11:11 -0700)
Commit e208f9c (make error()'s constant return value more
visible, 2012-12-15) introduced some macro trickery to make
the constant return from error() more visible to callers,
which in turn can help gcc produce better warnings (and
possibly even better code).

Later, fd1d672 (usage.c: add warning_errno() and
error_errno(), 2016-05-08) introduced another variant, and
subsequent commits converted some uses of error() to
error_errno(), losing the magic from e208f9c for those
sites.

As a result, compiling vcs-svn/svndiff.c with "gcc -O3"
produces -Wmaybe-uninitialized false positives (at least
with gcc 6.2.0). Let's give error_errno() the same
treatment, which silences these warnings.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h
usage.c
index 49d4029b8dddcb06dc6bea3d5f47c020785e3ddf..24f0ec9986896e180974e7212c22378bcd1630c6 100644 (file)
@@ -436,6 +436,7 @@ static inline int const_error(void)
        return -1;
 }
 #define error(...) (error(__VA_ARGS__), const_error())
+#define error_errno(...) (error_errno(__VA_ARGS__), const_error())
 #endif
 
 extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
diff --git a/usage.c b/usage.c
index 1dad03fb5c9b7f8f7785915d004aff43e39b0d2a..0efa3faf601231db35239161a1a7253b3975b3f8 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -148,6 +148,7 @@ void NORETURN die_errno(const char *fmt, ...)
        va_end(params);
 }
 
+#undef error_errno
 int error_errno(const char *fmt, ...)
 {
        char buf[1024];