mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 02:20:12 +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.
This commit is contained in:
parent
632dd26288
commit
ba950cedee
1 changed files with 2 additions and 0 deletions
|
|
@ -305,9 +305,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