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

2 messages from 2006-06-28 to 2006-06-28. Participants: Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/4689

## Jeff King, 2006-06-28 05:59

Subject: [PATCH] quote.c: silence compiler warnings from EMIT macro
Message-ID: <20060628055923.GA6071@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20060628055923.GA6071%40coredump.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

```

## Junio C Hamano, 2006-06-28 10:01

Subject: Re: [PATCH] quote.c: silence compiler warnings from EMIT macro
Message-ID: <7vd5ct38gm.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5ct38gm.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060628055923.GA6071@coredump.intra.peff.net>

```
Thanks.

```
