mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 09:58:07 +02:00
std-aux: mark _nm_assert_fail() as _nm_unreachable_code() with NDEBUG/G_DISABLE_ASSERT
This is useful, because it can avoid compiler warnings that are emitted if the compiler things that the code can be reached. _nm_assert_fail() can clearly never be reached (unless a bug happens). When compiling we can disable assertion checks with NDEBUG/G_DISABLE_ASSERT, but if we know that an assertion must not be hit (for example with nm_assert_not_reached()) then we still want to mark the path as unreachable, even if assert() does not abort the process.
This commit is contained in:
parent
5ac5d7f8c3
commit
06931221b5
2 changed files with 9 additions and 2 deletions
|
|
@ -529,8 +529,13 @@ nm_str_realloc(char *str)
|
|||
|
||||
/* redefine assertions to use g_assert*() */
|
||||
#undef _nm_assert_fail
|
||||
#define _nm_assert_fail(msg) \
|
||||
g_assertion_message_expr(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg)
|
||||
#define _nm_assert_fail(msg) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
g_assertion_message_expr(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); \
|
||||
_nm_unreachable_code(); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#undef _NM_ASSERT_FAIL_ENABLED
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
|
|
|
|||
|
|
@ -246,6 +246,8 @@ _nm_assert_fail_internal(const char *assertion,
|
|||
#define _nm_assert_fail(msg) \
|
||||
do { \
|
||||
_nm_unused const char *_msg = (msg); \
|
||||
\
|
||||
_nm_unreachable_code(); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue