summaryrefslogtreecommitdiff
path: root/parse-options.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-12-15 12:42:10 -0500
committerJunio C Hamano <gitster@pobox.com>2012-12-15 10:45:59 -0800
commita469a1019352b8efc4bd7003b0bd59eb60fc428c (patch)
tree33246362997de827418a21c7d0a7530b2d92e6f8 /parse-options.h
parente208f9cc7574f5980faba498d0aa30b4defeb34f (diff)
downloadgit-a469a1019352b8efc4bd7003b0bd59eb60fc428c.tar.gz
silence some -Wuninitialized false positives
There are a few error functions that simply wrap error() and provide a standardized message text. Like error(), they always return -1; knowing that can help the compiler silence some false positive -Wuninitialized warnings. One strategy would be to just declare these as inline in the header file so that the compiler can see that they always return -1. However, gcc does not always inline them (e.g., it will not inline opterror, even with -O3), which renders our change pointless. Instead, let's follow the same route we did with error() in the last patch, and define a macro that makes the constant return value obvious to the compiler. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.h')
-rw-r--r--parse-options.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/parse-options.h b/parse-options.h
index 71a39c60d9..e703853749 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -177,6 +177,10 @@ extern NORETURN void usage_msg_opt(const char *msg,
extern int optbug(const struct option *opt, const char *reason);
extern int opterror(const struct option *opt, const char *reason, int flags);
+#ifdef __GNUC__
+#define opterror(o,r,f) (opterror((o),(r),(f)), -1)
+#endif
+
/*----- incremental advanced APIs -----*/
enum {