threads / patch / 4689

patchquote.c: silence compiler warnings from EMIT macro

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

## tl;dr

2 messages between Jun 28, 2006 and Jun 28, 2006. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Jeff King· Jun 28, 2006, 05:59 UTC · lore
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(-)
Show changes to quote.c +1 −1
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

← back to recent threads