]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
_dbus_test_check: Wrap body of macro in do/while
authorSimon McVittie <smcv@collabora.com>
Thu, 16 Apr 2020 13:11:09 +0000 (14:11 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 20 Apr 2020 09:11:38 +0000 (10:11 +0100)
This avoids unexpected precedence when used as the body of an "if" or
"else" without being wrapped in {}.

Signed-off-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-test-tap.h

index 423cf48ea8bd9041799c27369ed4a80e0818de30..19f041b6c969dadd5303576b1d660dd01f67421f 100644 (file)
@@ -59,7 +59,10 @@ void _dbus_test_check_memleaks (const char *test_name);
 DBUS_PRIVATE_EXPORT
 int _dbus_test_done_testing (void);
 
-#define _dbus_test_check(a) if (!(a)) _dbus_test_not_ok ("%s:%d - '%s' failed\n", __FILE__, __LINE__, #a)
+#define _dbus_test_check(a) do { \
+    if (!(a)) \
+      _dbus_test_not_ok ("%s:%d - '%s' failed\n", __FILE__, __LINE__, #a); \
+  } while (0)
 
 #endif