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

[PATCH] quote.c: silence compiler warnings from EMIT macro

From
Jeff King <peff@peff.net>
Date
Jun 28, 2006, 05:59 UTC
Message-ID
<20060628055923.GA6071@coredump.intra.peff.net>
Signed-off-by: Jeff King <peff@peff.net>
---
This allows compiling with gcc -Wall -Werror, which makes finding useful
warnings easier. I also think the 'if' is easier to read than the
short-circuit.
 quote.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/quote.c b/quote.c
index dcc2326..1910d00 100644
--- a/quote.c
+++ b/quote.c
@@ -13,7 +13,7 @@ #include "quote.h"
  *  a!b      ==> a'\!'b    ==> 'a'\!'b'
  */
 #undef EMIT
-#define EMIT(x) ( (++len < n) && (*bp++ = (x)) )
+#define EMIT(x) do { if (++len < n) *bp++ = (x); } while(0)
 
 static inline int need_bs_quote(char c)
 {
-- 
1.4.1.rc1.g29f4a-dirty
Next: Junio C Hamano
Message 1 of 2 in “quote.c: silence compiler warnings from EMIT macro”
  1. quote.c: silence compiler warnings from EMIT macroJeff King, Jun 28, 2006
  2. Junio C HamanoJun 28, 2006

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.