From 1d4a80cf7f59cfd258d8978e23cfb7c55fe695d7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 28 Dec 2021 10:50:05 +0100 Subject: [PATCH] libnm: refactor some NMSetting to use direct properties for int64 --- src/libnm-core-impl/nm-setting-ip-config.c | 14 +++++++------- src/libnm-core-impl/nm-setting.c | 8 +------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index f53227741a..5b27e988e7 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -5833,6 +5833,13 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, NMSettingIPConfigPrivate, route_table)); + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_ROUTE_METRIC], + &nm_sett_info_propert_type_direct_int64, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(gint64, NMSettingIPConfigPrivate, route_metric)); + _nm_properties_override_gobj( properties_override, obj_properties[PROP_IGNORE_AUTO_DNS], @@ -5936,9 +5943,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) (NMUtilsCopyFunc) nm_ip_route_dup, (GDestroyNotify) nm_ip_route_unref)); break; - case PROP_ROUTE_METRIC: - g_value_set_int64(value, priv->route_metric); - break; case PROP_IGNORE_AUTO_ROUTES: g_value_set_boolean(value, nm_setting_ip_config_get_ignore_auto_routes(setting)); break; @@ -6028,9 +6032,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps (NMUtilsCopyFunc) nm_ip_route_dup, (GDestroyNotify) nm_ip_route_unref); break; - case PROP_ROUTE_METRIC: - priv->route_metric = g_value_get_int64(value); - break; case PROP_IGNORE_AUTO_ROUTES: priv->ignore_auto_routes = g_value_get_boolean(value); break; @@ -6074,7 +6075,6 @@ _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv priv->dns_search = g_ptr_array_new_with_free_func(g_free); priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); - priv->route_metric = -1; } static void diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index a6e33408c2..5c08e72998 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -390,13 +390,7 @@ _nm_setting_class_commit(NMSettingClass *setting_class, goto has_property_type; } - if (vtype == G_TYPE_INT64) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_INT64, - .compare_fcn = _nm_setting_property_compare_fcn_default, - .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, - .from_dbus_is_full = TRUE); - else if (vtype == G_TYPE_STRV) + if (vtype == G_TYPE_STRV) p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( G_VARIANT_TYPE_STRING_ARRAY, .compare_fcn = _nm_setting_property_compare_fcn_default,