From 3ea19523ee9865d7210b8da1fe2b6b7fa5011825 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 9 Jun 2023 10:15:40 +0200 Subject: [PATCH] device: generic: make type-description const The type is initialized from nm_platform_link_get_type_name(), which returns a static string; there is no need to duplicate the string. --- src/core/devices/nm-device-generic.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/core/devices/nm-device-generic.c b/src/core/devices/nm-device-generic.c index f3ac16e8b7..c0dcf0de69 100644 --- a/src/core/devices/nm-device-generic.c +++ b/src/core/devices/nm-device-generic.c @@ -16,7 +16,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_TYPE_DESCRIPTION, ); typedef struct { - char *type_description; + const char *type_description; } NMDeviceGenericPrivate; struct _NMDeviceGeneric { @@ -64,11 +64,11 @@ realize_start_notify(NMDevice *device, const NMPlatformLink *plink) NM_DEVICE_CLASS(nm_device_generic_parent_class)->realize_start_notify(device, plink); - nm_clear_g_free(&priv->type_description); ifindex = nm_device_get_ip_ifindex(NM_DEVICE(self)); - if (ifindex > 0) + if (ifindex > 0) { priv->type_description = - g_strdup(nm_platform_link_get_type_name(nm_device_get_platform(device), ifindex)); + nm_platform_link_get_type_name(nm_device_get_platform(device), ifindex); + } } static gboolean @@ -164,17 +164,6 @@ nm_device_generic_new(const NMPlatformLink *plink, gboolean nm_plugin_missing) NULL); } -static void -dispose(GObject *object) -{ - NMDeviceGeneric *self = NM_DEVICE_GENERIC(object); - NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE(self); - - nm_clear_g_free(&priv->type_description); - - G_OBJECT_CLASS(nm_device_generic_parent_class)->dispose(object); -} - static const NMDBusInterfaceInfoExtended interface_info_device_generic = { .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT( NM_DBUS_INTERFACE_DEVICE_GENERIC, @@ -194,7 +183,6 @@ nm_device_generic_class_init(NMDeviceGenericClass *klass) NMDeviceClass *device_class = NM_DEVICE_CLASS(klass); object_class->constructor = constructor; - object_class->dispose = dispose; object_class->get_property = get_property; dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS(&interface_info_device_generic);