{"thread":{"id":"34651","subject":"[PATCH] parse-options: fix clang opterror() -Wunused-value warning","startedAt":"2013-08-09T09:06:17Z","lastAt":"2013-08-09T10:32:49Z","messageCount":2,"participants":["Eric Sunshine","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"224888","messageId":"1376039177-17560-1-git-send-email-sunshine@sunshineco.com","threadId":"34651","inReplyTo":null,"subject":"[PATCH] parse-options: fix clang opterror() -Wunused-value warning","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2013-08-09T09:06:17Z","receivedAt":"2013-08-09T09:06:17Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"a469a1019352b8ef (silence some -Wuninitialized false positives;\n2012-12-15) triggered \"unused value\" warnings when the return value of\nopterror() and several other error-related functions was not used.\n5ded807f7c0be10e (fix clang -Wunused-value warnings for error functions;\n2013-01-16) applied a fix by adding #if !defined(__clang__) in cache.h\nand git-compat-util.h, but misspelled it as #if !defined(clang) in\nparse-options.h. Fix this.\n\nThis mistake went unnoticed because existing callers of opterror()\nutilize its return value.  1158826394e162c5 (parse-options: add\nOPT_CMDMODE(); 2013-07-30), however, adds a new invocation of opterror()\nwhich ignores the return value, thus triggering the \"unused value\"\nwarning.\n\nSigned-off-by: Eric Sunshine <sunshine@sunshineco.com>\n---\n parse-options.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex aeab9aa..8736006 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -182,7 +182,7 @@ extern NORETURN void usage_msg_opt(const char *msg,\n \n extern int optbug(const struct option *opt, const char *reason);\n extern int opterror(const struct option *opt, const char *reason, int flags);\n-#if defined(__GNUC__) && ! defined(clang)\n+#if defined(__GNUC__) && ! defined(__clang__)\n #define opterror(o,r,f) (opterror((o),(r),(f)), -1)\n #endif\n \n-- \n1.8.4.rc1.428.gcd48621\n"},{"id":"224891","messageId":"20130809103249.GA18878@sigill.intra.peff.net","threadId":"34651","inReplyTo":"1376039177-17560-1-git-send-email-sunshine@sunshineco.com","subject":"Re: [PATCH] parse-options: fix clang opterror() -Wunused-value warning","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-08-09T10:32:49Z","receivedAt":"2013-08-09T10:32:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 09, 2013 at 05:06:17AM -0400, Eric Sunshine wrote:\n\n> a469a1019352b8ef (silence some -Wuninitialized false positives;\n> 2012-12-15) triggered \"unused value\" warnings when the return value of\n> opterror() and several other error-related functions was not used.\n> 5ded807f7c0be10e (fix clang -Wunused-value warnings for error functions;\n> 2013-01-16) applied a fix by adding #if !defined(__clang__) in cache.h\n> and git-compat-util.h, but misspelled it as #if !defined(clang) in\n> parse-options.h. Fix this.\n> \n> This mistake went unnoticed because existing callers of opterror()\n> utilize its return value.  1158826394e162c5 (parse-options: add\n> OPT_CMDMODE(); 2013-07-30), however, adds a new invocation of opterror()\n> which ignores the return value, thus triggering the \"unused value\"\n> warning.\n\nOops.\n\nPatch looks obviously correct. Thanks for a nice explanation of what\nhappened.\n\n-Peff\n"}]}