summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-05 15:59:56 +0200
committerThomas Haller <thaller@redhat.com>2015-10-05 16:02:38 +0200
commitd5bfe04dea290ce288b8fe141a20c66ad6588e55 (patch)
treeef5db5c89c747b92e00a4f68c958750a6b8eadfe
parentbb9d4b0ad120af2b66436caa65ff5093e6ad754a (diff)
parent3b6c1aa1a37ae79271240dd980069f312c578c1a (diff)
downloadNetworkManager-d5bfe04dea290ce288b8fe141a20c66ad6588e55.tar.gz
core: merge branch 'th/more-asserts'
Change NM_MORE_ASSERTS to allow for different levels for which asserts are enabled.
-rw-r--r--Makefile.glib2
-rw-r--r--configure.ac18
-rw-r--r--include/nm-macros-internal.h2
-rw-r--r--src/devices/adsl/Makefile.am12
-rw-r--r--src/devices/nm-device.c67
-rw-r--r--src/devices/team/Makefile.am12
-rw-r--r--src/devices/team/nm-device-team.c1
-rw-r--r--src/devices/wifi/Makefile.am16
-rw-r--r--src/devices/wifi/nm-device-olpc-mesh.c1
-rw-r--r--src/devices/wifi/nm-device-wifi.c1
-rw-r--r--src/nm-bus-manager.c2
-rw-r--r--src/nm-config-data.c2
-rw-r--r--src/nm-route-manager.c2
-rw-r--r--src/platform/nmp-object.c2
14 files changed, 77 insertions, 63 deletions
diff --git a/Makefile.glib b/Makefile.glib
index 626b946c75..87b7f8234c 100644
--- a/Makefile.glib
+++ b/Makefile.glib
@@ -85,7 +85,7 @@ $(1).h: $(1).h.stamp
$(1).c.stamp: $(_glib_enum_types_h_sources) Makefile
$$(_GLIB_V_GEN) $$(GLIB_MKENUMS) \
- --fhead "/* Generated by glib-mkenums. Do not edit */\n\n#include \"$(notdir $(1)).h\"\n" \
+ --fhead "/* Generated by glib-mkenums. Do not edit */\n\n#include \"config.h\"\n\n#include \"$(notdir $(1)).h\"\n" \
$$(GLIB_MKENUMS_C_FLAGS) \
$$($(_glib_enum_types_prefix)_MKENUMS_C_FLAGS) \
--fhead "$$(foreach f,$$(filter-out Makefile,$$(^F)),\n#include \"$$(f)\")\n\n" \
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/devices/adsl/Makefile.am b/src/devices/adsl/Makefile.am
index fa32c25a4d..b082ffc4ff 100644
--- a/src/devices/adsl/Makefile.am
+++ b/src/devices/adsl/Makefile.am
@@ -17,13 +17,6 @@ AM_CPPFLAGS = \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GUDEV_CFLAGS)
-GLIB_GENERATED = nm-adsl-enum-types.h nm-adsl-enum-types.c
-GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
-GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
-nm_adsl_enum_types_sources = $(srcdir)/nm-device-adsl.h
-
-BUILT_SOURCES = $(GLIB_GENERATED)
-
pkglib_LTLIBRARIES = libnm-device-plugin-adsl.la
SYMBOL_VIS_FILE=$(srcdir)/exports.ver
@@ -32,9 +25,7 @@ libnm_device_plugin_adsl_la_SOURCES = \
nm-atm-manager.c \
nm-atm-manager.h \
nm-device-adsl.c \
- nm-device-adsl.h \
- \
- $(BUILT_SOURCES)
+ nm-device-adsl.h
libnm_device_plugin_adsl_la_LDFLAGS = \
-module -avoid-version \
@@ -44,7 +35,6 @@ libnm_device_plugin_adsl_la_LIBADD = \
$(top_builddir)/introspection/libnmdbus.la \
$(GUDEV_LIBS)
-CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(SYMBOL_VIS_FILE)
if ENABLE_TESTS
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 5d9644e8e6..961d725a8d 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -8018,6 +8018,33 @@ nm_device_update_metered (NMDevice *self)
}
}
+static gboolean
+_nm_device_check_connection_available (NMDevice *self,
+ NMConnection *connection,
+ NMDeviceCheckConAvailableFlags flags,
+ const char *specific_object)
+{
+ NMDeviceState state;
+
+ state = nm_device_get_state (self);
+ if (state < NM_DEVICE_STATE_UNMANAGED)
+ return FALSE;
+ if ( state < NM_DEVICE_STATE_UNAVAILABLE
+ && nm_device_get_unmanaged (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT))
+ return FALSE;
+ if ( state < NM_DEVICE_STATE_DISCONNECTED
+ && ( ( !NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)
+ && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE))
+ || ( NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)
+ && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER))))
+ return FALSE;
+
+ if (!nm_device_check_connection_compatible (self, connection))
+ return FALSE;
+
+ return NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, flags, specific_object);
+}
+
/**
* nm_device_check_connection_available():
* @self: the #NMDevice
@@ -8039,25 +8066,33 @@ nm_device_check_connection_available (NMDevice *self,
NMDeviceCheckConAvailableFlags flags,
const char *specific_object)
{
- NMDeviceState state;
+ gboolean available;
- state = nm_device_get_state (self);
- if (state < NM_DEVICE_STATE_UNMANAGED)
- return FALSE;
- if ( state < NM_DEVICE_STATE_UNAVAILABLE
- && nm_device_get_unmanaged (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT))
- return FALSE;
- if ( state < NM_DEVICE_STATE_DISCONNECTED
- && ( ( !NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)
- && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE))
- || ( NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER)
- && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER))))
- return FALSE;
+ available = _nm_device_check_connection_available (self, connection, flags, specific_object);
- if (!nm_device_check_connection_compatible (self, connection))
- return FALSE;
+#if NM_MORE_ASSERTS >= 2
+ {
+ /* The meaning of the flags is so that *adding* a flag relaxes a condition, thus making
+ * the device *more* available. Assert against that requirement by testing all the flags. */
+ NMDeviceCheckConAvailableFlags i, j, k;
+ gboolean available_all[NM_DEVICE_CHECK_CON_AVAILABLE_ALL + 1] = { FALSE };
+
+ for (i = 0; i <= NM_DEVICE_CHECK_CON_AVAILABLE_ALL; i++)
+ available_all[i] = _nm_device_check_connection_available (self, connection, i, specific_object);
+
+ for (i = 0; i <= NM_DEVICE_CHECK_CON_AVAILABLE_ALL; i++) {
+ for (j = 1; j <= NM_DEVICE_CHECK_CON_AVAILABLE_ALL; j <<= 1) {
+ if (NM_FLAGS_HAS (i, j)) {
+ k = i & ~j;
+ nm_assert ( available_all[i] == available_all[k]
+ || available_all[i]);
+ }
+ }
+ }
+ }
+#endif
- return NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, flags, specific_object);
+ return available;
}
static void
diff --git a/src/devices/team/Makefile.am b/src/devices/team/Makefile.am
index 13559a1867..3df138609d 100644
--- a/src/devices/team/Makefile.am
+++ b/src/devices/team/Makefile.am
@@ -21,13 +21,6 @@ if WITH_TEAMDCTL
AM_CPPFLAGS += ${LIBTEAMDCTL_CFLAGS}
endif
-GLIB_GENERATED = nm-team-enum-types.h nm-team-enum-types.c
-GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
-GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
-nm_team_enum_types_sources = $(srcdir)/nm-device-team.h
-
-BUILT_SOURCES = $(GLIB_GENERATED)
-
pkglib_LTLIBRARIES = libnm-device-plugin-team.la
SYMBOL_VIS_FILE=$(srcdir)/exports.ver
@@ -36,9 +29,7 @@ libnm_device_plugin_team_la_SOURCES = \
nm-device-team.c \
nm-device-team.h \
nm-team-factory.c \
- nm-team-factory.h \
- \
- $(BUILT_SOURCES)
+ nm-team-factory.h
libnm_device_plugin_team_la_LDFLAGS = \
-module -avoid-version \
@@ -53,7 +44,6 @@ if WITH_TEAMDCTL
libnm_device_plugin_team_la_LIBADD += $(LIBTEAMDCTL_LIBS)
endif
-CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(SYMBOL_VIS_FILE)
if ENABLE_TESTS
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index f20d0922f8..a6679e422e 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -33,7 +33,6 @@
#include "nm-device-private.h"
#include "nm-platform.h"
#include "nm-enum-types.h"
-#include "nm-team-enum-types.h"
#include "nm-core-internal.h"
#include "nm-ip4-config.h"
#include "nm-dbus-compat.h"
diff --git a/src/devices/wifi/Makefile.am b/src/devices/wifi/Makefile.am
index 250727f025..df21597d38 100644
--- a/src/devices/wifi/Makefile.am
+++ b/src/devices/wifi/Makefile.am
@@ -23,16 +23,6 @@ AM_CPPFLAGS = \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(GLIB_CFLAGS)
-GLIB_GENERATED = nm-wifi-enum-types.h nm-wifi-enum-types.c
-GLIB_MKENUMS_H_FLAGS = --identifier-prefix NM
-GLIB_MKENUMS_C_FLAGS = --identifier-prefix NM
-nm_wifi_enum_types_sources = \
- $(srcdir)/nm-device-wifi.h \
- $(srcdir)/nm-wifi-ap.h \
- $(srcdir)/nm-device-olpc-mesh.h
-
-BUILT_SOURCES = $(GLIB_GENERATED)
-
pkglib_LTLIBRARIES = libnm-device-plugin-wifi.la
libnm_device_plugin_wifi_la_SOURCES = \
@@ -44,9 +34,7 @@ libnm_device_plugin_wifi_la_SOURCES = \
nm-wifi-ap-utils.c \
nm-wifi-ap-utils.h \
nm-device-olpc-mesh.c \
- nm-device-olpc-mesh.h \
- \
- $(BUILT_SOURCES)
+ nm-device-olpc-mesh.h
SYMBOL_VIS_FILE=$(srcdir)/exports.ver
@@ -59,8 +47,6 @@ libnm_device_plugin_wifi_la_LIBADD = \
$(GLIB_LIBS) \
$(GUDEV_LIBS)
-CLEANFILES = $(BUILT_SOURCES)
-
EXTRA_DIST = $(SYMBOL_VIS_FILE)
if ENABLE_TESTS
diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c
index f656e4efb3..38f1f88dd4 100644
--- a/src/devices/wifi/nm-device-olpc-mesh.c
+++ b/src/devices/wifi/nm-device-olpc-mesh.c
@@ -48,7 +48,6 @@
#include "nm-manager.h"
#include "nm-enum-types.h"
#include "nm-platform.h"
-#include "nm-wifi-enum-types.h"
/* This is a bug; but we can't really change API now... */
#include "nm-vpn-dbus-interface.h"
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 7415f7ac1c..a208b3a892 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -47,7 +47,6 @@
#include "nm-auth-utils.h"
#include "nm-settings-connection.h"
#include "nm-enum-types.h"
-#include "nm-wifi-enum-types.h"
#include "nm-connection-provider.h"
#include "nm-core-internal.h"
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-config-data.c b/src/nm-config-data.c
index af7ce4f5d7..02467c53d7 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -19,6 +19,8 @@
* Copyright (C) 2013 Thomas Bechtold <thomasbechtold@jpberlin.de>
*/
+#include "config.h"
+
#include "nm-config-data.h"
#include <string.h>
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;