summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn <max@quendi.de>2013-01-16 10:09:29 -0800
committerJunio C Hamano <gitster@pobox.com>2013-01-16 12:47:46 -0800
commit5ded807f7c0be10ecbb31555e5d10dee553752d6 (patch)
tree4a102e5f0d148fe587cedef9fe9eaa2b4120001e
parenta469a1019352b8efc4bd7003b0bd59eb60fc428c (diff)
downloadgit-5ded807f7c0be10ecbb31555e5d10dee553752d6.tar.gz
fix clang -Wunused-value warnings for error functions
Commit a469a10 wraps some error calls in macros to give the compiler a chance to do more static analysis on their constant -1 return value. We limit the use of these macros to __GNUC__, since gcc is the primary beneficiary of the new information, and because we use GNU features for handling variadic macros. However, clang also defines __GNUC__, but generates warnings with -Wunused-value when these macros are used in a void context, because the constant "-1" ends up being useless. Gcc does not complain about this case (though it is unclear if it is because it is smart enough to see what we are doing, or too dumb to realize that the -1 is unused). We can squelch the warning by just disabling these macros when clang is in use. Signed-off-by: Max Horn <max@quendi.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--cache.h2
-rw-r--r--git-compat-util.h2
-rw-r--r--parse-options.h2
3 files changed, 3 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index 0e8e5d8002..98b62bcb5a 100644
--- a/cache.h
+++ b/cache.h
@@ -1136,7 +1136,7 @@ extern int check_repository_format_version(const char *var, const char *value, v
extern int git_env_bool(const char *, int);
extern int git_config_system(void);
extern int config_error_nonbool(const char *);
-#ifdef __GNUC__
+#if defined(__GNUC__) && ! defined(__clang__)
#define config_error_nonbool(s) (config_error_nonbool(s), -1)
#endif
extern const char *get_log_output_encoding(void);
diff --git a/git-compat-util.h b/git-compat-util.h
index 9002bca28e..77fd848511 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -295,7 +295,7 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
* behavior. But since we're only trying to help gcc, anyway, it's OK; other
* compilers will fall back to using the function as usual.
*/
-#ifdef __GNUC__
+#if defined(__GNUC__) && ! defined(__clang__)
#define error(fmt, ...) (error((fmt), ##__VA_ARGS__), -1)
#endif
diff --git a/parse-options.h b/parse-options.h
index e703853749..1c8bd8d5a0 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -177,7 +177,7 @@ 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__
+#if defined(__GNUC__) && ! defined(clang)
#define opterror(o,r,f) (opterror((o),(r),(f)), -1)
#endif