[master] 825e5b2d4 Always wrap code-generating macros in do { ... } while(0)

Poul-Henning Kamp phk at FreeBSD.org
Mon Aug 30 10:27:05 UTC 2021


commit 825e5b2d4d20a7fd5680e2647090b04c61a6b2a4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Aug 30 10:25:26 2021 +0000

    Always wrap code-generating macros in do { ... } while(0)

diff --git a/bin/varnishd/http2/cache_http2_panic.c b/bin/varnishd/http2/cache_http2_panic.c
index 25dda29a0..b9720070a 100644
--- a/bin/varnishd/http2/cache_http2_panic.c
+++ b/bin/varnishd/http2/cache_http2_panic.c
@@ -51,10 +51,12 @@ h2_panic_settings(struct vsb *vsb, const struct h2_settings *s)
 	int cont = 0;
 
 #define H2_SETTING(U,l,...)			\
-	if (cont)				\
-		VSB_printf(vsb, ", ");		\
-	cont = 1;				\
-	VSB_printf(vsb, "0x%x", s->l);
+	do {					\
+		if (cont)			\
+			VSB_printf(vsb, ", ");	\
+		cont = 1;			\
+		VSB_printf(vsb, "0x%x", s->l);	\
+	} while (0);
 #include "tbl/h2_settings.h"
 #undef H2_SETTING
 }


More information about the varnish-commit mailing list