mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-16 13:30:19 +01:00
shared: add nm_assert_se() macro
We usually don't build NM with g_assert() disabled (G_DISABLE_ASSERT).
But even if we would, there is no assertion macro that always evaluates
the condition for possible side effects.
I think that is a useful thing to have.
(cherry picked from commit ba950cedee)
This commit is contained in:
parent
beeb676735
commit
d242fdc319
1 changed files with 2 additions and 0 deletions
|
|
@ -300,9 +300,11 @@ nm_strdup_not_empty (const char *str)
|
|||
|
||||
#if NM_MORE_ASSERTS
|
||||
#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END
|
||||
#define nm_assert_se(cond) G_STMT_START { if (G_LIKELY (cond)) { ; } else { g_assert (FALSE && (cond)); } } G_STMT_END
|
||||
#define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END
|
||||
#else
|
||||
#define nm_assert(cond) G_STMT_START { if (FALSE) { if (cond) { } } } G_STMT_END
|
||||
#define nm_assert_se(cond) G_STMT_START { if (G_LIKELY (cond)) { ; } } G_STMT_END
|
||||
#define nm_assert_not_reached() G_STMT_START { ; } G_STMT_END
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue