summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-05 13:48:01 +0200
committerThomas Haller <thaller@redhat.com>2015-10-05 15:25:54 +0200
commit6395c829bb143301275b9bb449780d46a381553c (patch)
treeac4546ae08473a0f2532456bcc805c4be19fa214
parent0907f3c21eee831deb338e6c91a79f0c92e7dd66 (diff)
downloadNetworkManager-6395c829bb143301275b9bb449780d46a381553c.tar.gz
build: make NM_MORE_ASSERTS define numeric for different levels of more-asserts
Allows to enable more-asserts more granularly. Unfortunately, the old check was "${enable_more_asserts} == "yes", thus we cannot extend "--enable-more-assert=level" because that would mean that the same build script cannot set the option on both old and new NetworkManager. Thus, add a new option --with-more-asserts=level. If you put the following in your build script, it will work as expected whether you build a new or an old version of NetworkManager. ./configure --enable-more-asserts --with-more-asserts=5
-rw-r--r--configure.ac18
-rw-r--r--include/nm-macros-internal.h2
-rw-r--r--src/nm-bus-manager.c2
-rw-r--r--src/nm-route-manager.c2
-rw-r--r--src/platform/nmp-object.c2
5 files changed, 20 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 16ffa4f876..cebaa437e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -891,10 +891,23 @@ AM_CONDITIONAL(BUILD_NMTUI, test "$build_nmtui" = yes)
NM_COMPILER_WARNINGS
AC_ARG_ENABLE(more-asserts,
- AS_HELP_STRING([--enable-more-asserts], [Enable more assertions for debugging (default: no)]))
+ AS_HELP_STRING([--enable-more-asserts], [Enable more assertions for debugging (default: no). Deprecated option. Use --with-more-asserts=level]))
+more_asserts=0
if test "${enable_more_asserts}" = "yes"; then
- AC_DEFINE(NM_MORE_ASSERTS, [1], [Define if more asserts are enabled])
+ more_asserts=100
+fi
+AC_ARG_WITH(more-asserts,
+ AS_HELP_STRING([--with-more-asserts=level], [Enable more assertions for debugging (default: 0)]),
+ [more_asserts=${with_more_asserts}],
+ [])
+if test "${more_asserts}" = "no"; then
+ more_asserts=0
+else
+ if test "${more_asserts}" = "yes"; then
+ more_asserts=100
+ fi
fi
+AC_DEFINE_UNQUOTED(NM_MORE_ASSERTS, $more_asserts, [Define if more asserts are enabled])
AC_ARG_ENABLE(more-logging,
AS_HELP_STRING([--enable-more-logging], [Enable more debug logging (default: no)]))
@@ -1169,6 +1182,7 @@ echo
echo "Miscellaneous:"
echo " documentation: $enable_gtk_doc"
echo " tests: $enable_tests"
+echo " more-asserts: $more_asserts"
echo " valgrind: $with_valgrind $with_valgrind_suppressions"
echo " code coverage: $enable_code_coverage"
echo " LTO: $enable_lto"
diff --git a/include/nm-macros-internal.h b/include/nm-macros-internal.h
index 4ee5499f22..b1d75e68ed 100644
--- a/include/nm-macros-internal.h
+++ b/include/nm-macros-internal.h
@@ -179,7 +179,7 @@
/*****************************************************************************/
-#ifdef NM_MORE_ASSERTS
+#if NM_MORE_ASSERTS
#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END
#else
#define nm_assert(cond) G_STMT_START { if (FALSE) { if (cond) { } } } G_STMT_END
diff --git a/src/nm-bus-manager.c b/src/nm-bus-manager.c
index 22a1c98098..1c09a7b68a 100644
--- a/src/nm-bus-manager.c
+++ b/src/nm-bus-manager.c
@@ -106,7 +106,7 @@ nm_bus_manager_setup (NMBusManager *instance)
static void
nm_assert_exported (NMBusManager *self, const char *path, NMExportedObject *object)
{
-#ifdef NM_MORE_ASSERTS
+#if NM_MORE_ASSERTS
NMBusManagerPrivate *priv;
const char *p2, *po;
NMExportedObject *o2;
diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c
index 19ba9066bd..2c08c9eee7 100644
--- a/src/nm-route-manager.c
+++ b/src/nm-route-manager.c
@@ -147,7 +147,7 @@ static gboolean _ip4_device_routes_cancel (NMRouteManager *self);
/*********************************************************************************************/
-#if defined (NM_MORE_ASSERTS) && !defined (G_DISABLE_ASSERT)
+#if NM_MORE_ASSERTS && !defined (G_DISABLE_ASSERT)
inline static void
ASSERT_route_index_valid (const VTableIP *vtable, const GArray *entries, const RouteIndex *index, gboolean unique_ifindexes)
{
diff --git a/src/platform/nmp-object.c b/src/platform/nmp-object.c
index 2e3e440c17..9f8d4f3cc1 100644
--- a/src/platform/nmp-object.c
+++ b/src/platform/nmp-object.c
@@ -1727,7 +1727,7 @@ nmp_cache_free (NMPCache *cache)
void
ASSERT_nmp_cache_is_consistent (const NMPCache *cache)
{
-#ifdef NM_MORE_ASSERTS
+#if NM_MORE_ASSERTS
NMMultiIndexIter iter_multi;
GHashTableIter iter_hash;
guint i, len;