core: merge branch 'th/more-asserts'

Change NM_MORE_ASSERTS to allow for different levels for which
asserts are enabled.
This commit is contained in:
Thomas Haller 2015-10-05 15:59:56 +02:00
commit d5bfe04dea
14 changed files with 77 additions and 63 deletions

View file

@ -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" \

View 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"

View file

@ -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

View file

@ -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

View file

@ -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 };
return NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, flags, specific_object);
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 available;
}
static void

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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"

View file

@ -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"

View 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;

View file

@ -19,6 +19,8 @@
* Copyright (C) 2013 Thomas Bechtold <thomasbechtold@jpberlin.de>
*/
#include "config.h"
#include "nm-config-data.h"
#include <string.h>

View 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)
{

View 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;