all: merge branch 'th/minor-cleanups'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/820
This commit is contained in:
Thomas Haller 2021-04-20 17:30:50 +02:00
commit f1500b32a6
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
6 changed files with 42 additions and 9 deletions

View file

@ -5,9 +5,10 @@
#include "src/core/nm-default-daemon.h"
#include "nm-dnsmasq-utils.h"
#include <arpa/inet.h>
#include "nm-dnsmasq-utils.h"
#include "libnm-platform/nm-platform.h"
#include "nm-utils.h"

View file

@ -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;
}
/*****************************************************************************/

View file

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

View file

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

View file

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

View file

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