diff --git a/src/core/dnsmasq/nm-dnsmasq-utils.c b/src/core/dnsmasq/nm-dnsmasq-utils.c index 86e18b5640..c2791b9e6c 100644 --- a/src/core/dnsmasq/nm-dnsmasq-utils.c +++ b/src/core/dnsmasq/nm-dnsmasq-utils.c @@ -5,9 +5,10 @@ #include "src/core/nm-default-daemon.h" +#include "nm-dnsmasq-utils.h" + #include -#include "nm-dnsmasq-utils.h" #include "libnm-platform/nm-platform.h" #include "nm-utils.h" diff --git a/src/core/nm-dbus-object.c b/src/core/nm-dbus-object.c index 6f294fe2ec..0414973929 100644 --- a/src/core/nm-dbus-object.c +++ b/src/core/nm-dbus-object.c @@ -183,23 +183,25 @@ nm_dbus_object_unexport_on_idle(gpointer /* (NMDBusObject *) */ self_take) /*****************************************************************************/ -void +gboolean _nm_dbus_object_clear_and_unexport(NMDBusObject **location) { NMDBusObject *self; - g_return_if_fail(location); + g_return_val_if_fail(location, FALSE); + if (!*location) - return; + return FALSE; self = g_steal_pointer(location); - g_return_if_fail(NM_IS_DBUS_OBJECT(self)); + g_return_val_if_fail(NM_IS_DBUS_OBJECT(self), FALSE); if (self->internal.path) nm_dbus_object_unexport(self); g_object_unref(self); + return TRUE; } /*****************************************************************************/ diff --git a/src/core/nm-dbus-object.h b/src/core/nm-dbus-object.h index d94bd5df45..c7c1b4f445 100644 --- a/src/core/nm-dbus-object.h +++ b/src/core/nm-dbus-object.h @@ -166,9 +166,9 @@ void nm_dbus_object_unexport(gpointer /* (NMDBusObject *) */ self); void nm_dbus_object_unexport_on_idle(gpointer /* (NMDBusObject *) */ self_take); -void _nm_dbus_object_clear_and_unexport(NMDBusObject **location); +gboolean _nm_dbus_object_clear_and_unexport(NMDBusObject **location); #define nm_dbus_object_clear_and_unexport(location) \ - _nm_dbus_object_clear_and_unexport((NMDBusObject **) (location)) + _nm_dbus_object_clear_and_unexport(NM_CAST_PPTR(NMDBusObject, (location))) void nm_dbus_object_emit_signal_variant(NMDBusObject * self, const NMDBusInterfaceInfoExtended *interface_info, diff --git a/src/core/nm-dhcp-config.c b/src/core/nm-dhcp-config.c index c26b371dca..c77e0adbaf 100644 --- a/src/core/nm-dhcp-config.c +++ b/src/core/nm-dhcp-config.c @@ -59,6 +59,7 @@ struct _NMDhcpConfig { struct _NMDhcpConfigClass { NMDBusObjectClass parent; + int addr_family; }; G_DEFINE_ABSTRACT_TYPE(NMDhcpConfig, nm_dhcp_config, NM_TYPE_DBUS_OBJECT) @@ -67,6 +68,14 @@ G_DEFINE_ABSTRACT_TYPE(NMDhcpConfig, nm_dhcp_config, NM_TYPE_DBUS_OBJECT) /*****************************************************************************/ +int +nm_dhcp_config_get_addr_family(NMDhcpConfig *self) +{ + return NM_DHCP_CONFIG_GET_CLASS(self)->addr_family; +} + +/*****************************************************************************/ + void nm_dhcp_config_set_options(NMDhcpConfig *self, GHashTable *options) { @@ -197,10 +206,13 @@ static void nm_dhcp4_config_class_init(NMDhcp4ConfigClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); + NMDhcpConfigClass *dhcp_config_class = NM_DHCP_CONFIG_CLASS(klass); dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED(NM_DBUS_PATH "/DHCP4Config"); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_dhcp4_config); dbus_object_class->export_on_construction = TRUE; + + dhcp_config_class->addr_family = AF_INET; } /*****************************************************************************/ @@ -234,8 +246,11 @@ static void nm_dhcp6_config_class_init(NMDhcp6ConfigClass *klass) { NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass); + NMDhcpConfigClass *dhcp_config_class = NM_DHCP_CONFIG_CLASS(klass); dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED(NM_DBUS_PATH "/DHCP6Config"); dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_dhcp6_config); dbus_object_class->export_on_construction = TRUE; + + dhcp_config_class->addr_family = AF_INET6; } diff --git a/src/core/ppp/nm-ppp-manager.c b/src/core/ppp/nm-ppp-manager.c index 137fccf31f..85f8d9aba6 100644 --- a/src/core/ppp/nm-ppp-manager.c +++ b/src/core/ppp/nm-ppp-manager.c @@ -1446,8 +1446,8 @@ nm_ppp_manager_class_init(NMPPPManagerClass *manager_class) NULL, G_TYPE_NONE, 2, - G_TYPE_UINT /*guint32 in_bytes*/, - G_TYPE_UINT /*guint32 out_bytes*/); + G_TYPE_UINT, /* guint32 in_bytes */ + G_TYPE_UINT); /* guint32 out_bytes */ } NMPPPOps ppp_ops = { diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index cc3b19c3a1..aaf5cff61a 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -683,6 +683,21 @@ NM_G_ERROR_MSG(GError *error) #define NM_STRUCT_OFFSET_ENSURE_TYPE(type, container, field) G_STRUCT_OFFSET(container, field) #endif +/* Casts (arg) to (type**), but also having a compile time check that + * the arg is some sort of pointer to a pointer. + * + * The only purpose of this macro is some additional compile time safety, + * that the argument is a pointer to pointer. But then it will C cast any kind + * of such argument. */ +#define NM_CAST_PPTR(type, arg) \ + ({ \ + typeof(*(arg)) *const _arg = (arg); \ + typeof(*_arg) _arg2 = _arg ? *_arg : NULL; \ + _nm_unused const void *const _arg3 = _arg2; \ + \ + (type **) _arg; \ + }) + #if _NM_CC_SUPPORT_GENERIC /* these macros cast (value) to * - "const char **" (for "MC", mutable-const)