build: make NM_MORE_ASSERTS define numeric for different levels of more-asserts
authorThomas Haller <thaller@redhat.com>
Mon, 5 Oct 2015 11:48:01 +0000 (13:48 +0200)
committerThomas Haller <thaller@redhat.com>
Mon, 5 Oct 2015 13:25:54 +0000 (15:25 +0200)
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

configure.ac
include/nm-macros-internal.h
src/nm-bus-manager.c
src/nm-route-manager.c
src/platform/nmp-object.c

index 16ffa4f..cebaa43 100644 (file)
@@ -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"
index 4ee5499..b1d75e6 100644 (file)
 
 /*****************************************************************************/
 
-#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
index 22a1c98..1c09a7b 100644 (file)
@@ -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;
index 19ba906..2c08c9e 100644 (file)
@@ -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)
 {
index 2e3e440..9f8d4f3 100644 (file)
@@ -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;