diff options
author | Thomas Haller <thaller@redhat.com> | 2016-05-14 23:01:21 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-05-14 23:11:59 +0200 |
commit | b871106e25857328393a11b5fc319f6e151c0b52 (patch) | |
tree | d62e1a7da343e65a706c56f0c49435444ee7c68a /shared | |
parent | dab2d46aa2f44da6334762fbbf86bee276dd4471 (diff) | |
download | NetworkManager-b871106e25857328393a11b5fc319f6e151c0b52.tar.gz |
macros: define NM_MORE_ASSERTS is not defined
In NetworkManager's configure script we have --with-more-asserts
option which always defines NM_MORE_ASSERTS in config.h.
When reusing the header file outside of NetworkManager, the
NM_MORE_ASSERTS define might be unset. Define it in that case
to avoid compiler warnings about undefined preprocessor define.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/nm-macros-internal.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h index ffa3ace086..256cfb77f0 100644 --- a/shared/nm-macros-internal.h +++ b/shared/nm-macros-internal.h @@ -297,6 +297,22 @@ _NM_IN_STRSET_streq (const char *x, const char *s) /*****************************************************************************/ +/* glib/C provides the following kind of assertions: + * - assert() -- disable with NDEBUG + * - g_return_if_fail() -- disable with G_DISABLE_CHECKS + * - g_assert() -- disable with G_DISABLE_ASSERT + * but they are all enabled by default and usually even production builds have + * these kind of assertions enabled. It also means, that disabling assertions + * is an untested configuration, and might have bugs. + * + * Add our own assertion macro nm_assert(), which is disabled by default and must + * be explicitly enabled. They are useful for more expensive checks or checks that + * depend less on runtime conditions (that is, are generally expected to be true). */ + +#ifndef NM_MORE_ASSERTS +#define NM_MORE_ASSERTS 0 +#endif + #if NM_MORE_ASSERTS #define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END #define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END |