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.
This commit is contained in:
Beniamino Galvani 2023-06-09 10:15:40 +02:00
parent fd6f48ec35
commit 3ea19523ee

View file

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