git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Use __VA_ARGS__ for all of error's arguments

From
MKMatt Kraai <kraai@ftbfs.org>
Date
Feb 8, 2013, 15:09 UTC
Message-ID
<1360336168-27740-1-git-send-email-kraai@ftbfs.org>
In-Reply-To
<20130208043915.GB4525@ftbfs.org>
From: Matt Kraai <matt.kraai@amo.abbott.com>

QNX 6.3.2 uses GCC 2.95.3 by default, and GCC 2.95.3 doesn't remove the comma if the error macro's variable argument is left out.

Instead of testing for a sufficiently recent version of GCC, make __VA_ARGS__ match all of the arguments.

Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
---
 git-compat-util.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index cc2abee..b7eaaa9 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -305,13 +305,13 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
 
 /*
  * Let callers be aware of the constant return value; this can help
- * gcc with -Wuninitialized analysis. We have to restrict this trick to
- * gcc, though, because of the variadic macro and the magic ## comma pasting
- * 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.
+ * gcc with -Wuninitialized analysis. We restrict this trick to gcc, though,
+ * because some compilers may not support variadic macros. Since we're only
+ * trying to help gcc, anyway, it's OK; other compilers will fall back to
+ * using the function as usual.
  */
 #if defined(__GNUC__) && ! defined(__clang__)
-#define error(fmt, ...) (error((fmt), ##__VA_ARGS__), -1)
+#define error(...) (error(__VA_ARGS__), -1)
 #endif
 
 extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
-- 
1.8.1.2.546.g90a97a4
Previous: Matt KraaiNext: Jeff King
Message 8 of 9 in “Use __VA_ARGS__ for all of error's arguments”
  1. Use __VA_ARGS__ for all of error's argumentsMatt Kraai, Feb 7, 2013
  2. Junio C HamanoFeb 7, 2013
  3. John KeepingFeb 7, 2013
  4. Matt KraaiFeb 7, 2013
  5. Use __VA_ARGS__ for all of error's argumentsMatt Kraai, Feb 7, 2013
  6. Jeff KingFeb 8, 2013
  7. Matt KraaiFeb 8, 2013
  8. Use __VA_ARGS__ for all of error's argumentsMatt Kraai, Feb 8, 2013
  9. Jeff KingFeb 8, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.