_dbus_test_check: Wrap body of macro in do/while

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>
This commit is contained in:
Simon McVittie 2020-04-16 14:11:09 +01:00
parent 0ddc510130
commit c46e002fe6

View 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