From ed97b1dc25b43fb2f24049a5497db5bf7ec2793b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 11 Dec 2023 10:31:14 +0100 Subject: [PATCH] libnm: rename direct_hook union in NMSettInfoProperty direct_hook is a union, which currently only has one member (the set function for a direct string). Extending this might make sense, for other set functions (e.g. overwriting setting a strv array). However, then the name was bad. The union is already for the set-function of direct properties, it's not a place for various kinds of hooks (as it is a union). Rename. --- src/libnm-core-impl/nm-setting-ip6-config.c | 2 +- src/libnm-core-impl/nm-setting-wireguard.c | 2 +- src/libnm-core-impl/nm-setting.c | 6 +++--- src/libnm-core-impl/tests/test-setting.c | 8 ++++---- src/libnm-core-intern/nm-core-internal.h | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 272523b143..82715e2637 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -1181,7 +1181,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) NM_SETTING_PARAM_NONE, NMSettingIP6ConfigPrivate, dhcp_pd_hint, - .direct_hook.set_string_fcn = + .direct_set_fcn.set_string = _set_string_fcn_dhcp_pd_hint); /* IP6-specific property overrides */ diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index ee289b5233..f736a54496 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -2362,7 +2362,7 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) NM_SETTING_PARAM_SECRET, NMSettingWireGuard, _priv.private_key, - .direct_hook.set_string_fcn = + .direct_set_fcn.set_string = _set_string_fcn_public_key); /** diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index f3399d58c8..8c129df7f6 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -683,10 +683,10 @@ _property_direct_set_string(const NMSettInfoSetting *sett_info, + (!!property_info->direct_string_is_refstr) + (property_info->direct_set_string_mac_address_len > 0) + (property_info->direct_set_string_ip_address_addr_family != 0)) - <= (property_info->direct_hook.set_string_fcn ? 0 : 1)); + <= (property_info->direct_set_fcn.set_string ? 0 : 1)); - if (property_info->direct_hook.set_string_fcn) { - return property_info->direct_hook.set_string_fcn(sett_info, property_info, setting, src); + if (property_info->direct_set_fcn.set_string) { + return property_info->direct_set_fcn.set_string(sett_info, property_info, setting, src); } dst = _nm_setting_get_private_field(setting, sett_info, property_info); diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index e9aa99819f..e799069d7e 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -4565,7 +4565,7 @@ test_setting_metadata(void) GArray *property_types_data; guint prop_idx_val; gboolean can_set_including_default = FALSE; - gboolean can_have_direct_hook = FALSE; + gboolean can_have_direct_set_fcn = FALSE; int n_special_options; g_assert(sip->name); @@ -4708,7 +4708,7 @@ test_setting_metadata(void) g_assert(g_variant_type_equal(sip->property_type->dbus_type, "s")); g_assert(sip->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_direct); - can_have_direct_hook = TRUE; + can_have_direct_set_fcn = TRUE; } g_assert(sip->param_spec); g_assert(sip->param_spec->value_type == G_TYPE_STRING); @@ -4746,8 +4746,8 @@ test_setting_metadata(void) g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); } - if (!can_have_direct_hook) - g_assert(!sip->direct_hook.set_string_fcn); + if (!can_have_direct_set_fcn) + g_assert(!sip->direct_set_fcn.set_string); n_special_options = (sip->direct_set_string_mac_address_len != 0) + (!!sip->direct_set_string_strip) diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index 2172ed0b9c..42ddeb5e1e 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -778,11 +778,11 @@ struct _NMSettInfoProperty { union { /* Optional hook for direct string properties, this gets called when setting the string. * Return whether the value changed. */ - gboolean (*set_string_fcn)(const NMSettInfoSetting *sett_info, - const NMSettInfoProperty *property_info, - NMSetting *setting, - const char *src); - } direct_hook; + gboolean (*set_string)(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, + const char *src); + } direct_set_fcn; /* This only has meaning for direct properties (property_type->direct_type != NM_VALUE_TYPE_UNSPEC). * In that case, this is the offset where _nm_setting_get_private() can find