From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 1/2] error_errno: use constant return similar to error()
Date: Tue, 30 Aug 2016 23:41:22 -0400 [thread overview]
Message-ID: <20160831034121.llw7ypnnwgaszarb@sigill.intra.peff.net> (raw)
In-Reply-To: <20160831033934.m2at7ci5f6lty5nb@sigill.intra.peff.net>
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>
---
git-compat-util.h | 1 +
usage.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/git-compat-util.h b/git-compat-util.h
index db89ba7..2ad45b3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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 1dad03f..0efa3fa 100644
--- 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];
--
2.10.0.rc2.125.gcfb3d08
next prev parent reply other threads:[~2016-08-31 3:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-31 3:39 [PATCH 0/2] squelch some "gcc -O3 -Wmaybe-uninitialized" warnings Jeff King
2016-08-31 3:41 ` Jeff King [this message]
2016-08-31 3:43 ` [PATCH 2/2] color_parse_mem: initialize "struct color" temporary Jeff King
2016-08-31 19:55 ` [PATCH 0/2] squelch some "gcc -O3 -Wmaybe-uninitialized" warnings Junio C Hamano
2016-09-01 20:08 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160831034121.llw7ypnnwgaszarb@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).