diff options
author | Thomas Haller <thaller@redhat.com> | 2023-02-13 09:20:13 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-02-13 09:59:47 +0100 |
commit | c1fd9fee128f986df7ec452e574213aa292bd883 (patch) | |
tree | 4ee30dbdc4e0ef93d20f196cf8d5752d1c671648 | |
parent | f5c48ee2380001e84e6fea1e669420d493ad844c (diff) | |
download | NetworkManager-c1fd9fee128f986df7ec452e574213aa292bd883.tar.gz |
std-aux: suppress verbose assert message with _nm_assert_fail()
We also do that with g_return*() macros. These strings increase the
binary size for little use. Drop them, unless we build with
more asserts enabled.
This affects nm_assert() messages.
(cherry picked from commit d3548279c1ca761738e960a6c2935dbf0656baaf)
-rw-r--r-- | src/libnm-glib-aux/nm-macros-internal.h | 12 | ||||
-rw-r--r-- | src/libnm-std-aux/nm-std-aux.h | 13 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index 71a17e3e37..0534ee5d9b 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -529,12 +529,12 @@ nm_str_realloc(char *str) /* redefine assertions to use g_assert*() */ #undef _nm_assert_fail -#define _nm_assert_fail(msg) \ - G_STMT_START \ - { \ - g_assertion_message_expr(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); \ - _nm_unreachable_code(); \ - } \ +#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 diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h index 75703e70b4..a5e5abd3d5 100644 --- a/src/libnm-std-aux/nm-std-aux.h +++ b/src/libnm-std-aux/nm-std-aux.h @@ -221,15 +221,14 @@ typedef uint64_t _nm_bitwise nm_be64_t; #ifndef NDEBUG #define _NM_ASSERT_FAIL_ENABLED 1 -#define _nm_assert_fail(msg) __assert_fail((msg), __FILE__, __LINE__, __func__) +#define _nm_assert_fail(msg) \ + __assert_fail(((NM_MORE_ASSERTS) ? "" msg "" : "<dropped>"), \ + __FILE__, \ + __LINE__, \ + ((NM_MORE_ASSERTS) ? __func__ : "<unknown-fcn>")) #else #define _NM_ASSERT_FAIL_ENABLED 0 -#define _nm_assert_fail(msg) \ - do { \ - _nm_unused const char *_msg = (msg); \ - \ - _nm_unreachable_code(); \ - } while (0) +#define _nm_assert_fail(msg) ((void) ("" msg ""), _nm_unreachable_code()) #endif #define NM_MORE_ASSERTS_EFFECTIVE (_NM_ASSERT_FAIL_ENABLED ? NM_MORE_ASSERTS : 0) |