summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-11 12:23:02 +0200
committerThomas Haller <thaller@redhat.com>2016-10-11 13:14:43 +0200
commit6b904a51ee3e6dcb8926d963d901e6689d4f9fad (patch)
tree9fb22fb567c219b990cef29ecfd01e718018fcb6 /libnm-core
parent97d3b07753c7e5fc884d4a0240d8d335891e9a76 (diff)
downloadNetworkManager-6b904a51ee3e6dcb8926d963d901e6689d4f9fad.tar.gz
shared: re-define _G_BOOLEAN_EXPR() to allow nesting g_assert()
g_assert() uses G_LIKELY(), which in turn uses _G_BOOLEAN_EXPR(). As glib's version of _G_BOOLEAN_EXPR() uses a local variable _g_boolean_var_, we cannot nest a G_LIKELY() inside a G_LIKELY(), or inside a g_assert(), or a g_assert() inside a g_assert(). Workaround that, by redefining the macro. I already encountered this problem before, when having a nm_assert() inside a ({...}) block, inside a g_assert(). Then I just avoided that combination, but this situation is quite easy to encounter.
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/tests/test-general.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 414c6659b3..3bb2e1bb09 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -5426,6 +5426,15 @@ test_nm_set_out (void)
call_count = 0;
NM_SET_OUT (p_val, do_test_nm_set_out_called (&call_count));
g_assert_cmpint (call_count, ==, 0);
+
+ /* test that we successfully re-defined _G_BOOLEAN_EXPR() */
+#define _T1(a) \
+ ({ \
+ g_assert (a > 5); \
+ a; \
+ })
+ g_assert (_T1 (3) > 1);
+#undef _T1
}
/*****************************************************************************/