diff --git a/src/libnm-core-impl/nm-setting-bond.c b/src/libnm-core-impl/nm-setting-bond.c index 6ef85f633e..b3397a47ea 100644 --- a/src/libnm-core-impl/nm-setting-bond.c +++ b/src/libnm-core-impl/nm-setting-bond.c @@ -1090,20 +1090,19 @@ options_equal(NMSettingBond *s_bond, NMSettingBond *s_bond2, NMSettingCompareFla } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_BOND_OPTIONS)) { + if (property_info->param_spec == obj_properties[PROP_OPTIONS]) return (!set_b || options_equal(NM_SETTING_BOND(set_a), NM_SETTING_BOND(set_b), flags)); - } return NM_SETTING_CLASS(nm_setting_bond_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-bridge-port.c b/src/libnm-core-impl/nm-setting-bridge-port.c index 50be8452d1..28621eee5c 100644 --- a/src/libnm-core-impl/nm-setting-bridge-port.c +++ b/src/libnm-core-impl/nm-setting-bridge-port.c @@ -368,19 +368,19 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingBridgePortPrivate *priv_a; NMSettingBridgePortPrivate *priv_b; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_BRIDGE_PORT_VLANS)) { + if (property_info->param_spec == obj_properties[PROP_VLANS]) { if (set_b) { priv_a = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(set_a); priv_b = NM_SETTING_BRIDGE_PORT_GET_PRIVATE(set_b); @@ -396,7 +396,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_bridge_port_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-bridge.c b/src/libnm-core-impl/nm-setting-bridge.c index 4567a28f0a..d4747af1dc 100644 --- a/src/libnm-core-impl/nm-setting-bridge.c +++ b/src/libnm-core-impl/nm-setting-bridge.c @@ -1315,19 +1315,19 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingBridgePrivate *priv_a; NMSettingBridgePrivate *priv_b; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_BRIDGE_VLANS)) { + if (property_info->param_spec == obj_properties[PROP_VLANS]) { if (set_b) { priv_a = NM_SETTING_BRIDGE_GET_PRIVATE(set_a); priv_b = NM_SETTING_BRIDGE_GET_PRIVATE(set_b); @@ -1343,7 +1343,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_bridge_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-connection.c b/src/libnm-core-impl/nm-setting-connection.c index 869093f156..4129ed2266 100644 --- a/src/libnm-core-impl/nm-setting-connection.c +++ b/src/libnm-core-impl/nm-setting-connection.c @@ -622,7 +622,7 @@ nm_setting_connection_get_timestamp(NMSettingConnection *setting) static GVariant * _to_dbus_fcn_timestamp(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -1558,24 +1558,24 @@ nm_setting_connection_no_interface_name(NMSetting * setting, } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_ID) - && nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_CONNECTION_ID)) - return NM_TERNARY_DEFAULT; - - if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP) - && nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_CONNECTION_TIMESTAMP)) - return NM_TERNARY_DEFAULT; + if (property_info->param_spec == obj_properties[PROP_ID]) { + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_ID)) + return NM_TERNARY_DEFAULT; + } else if (property_info->param_spec == obj_properties[PROP_TIMESTAMP]) { + if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP)) + return NM_TERNARY_DEFAULT; + } return NM_SETTING_CLASS(nm_setting_connection_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index f1e0d7adce..6033fc3688 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -4944,7 +4944,7 @@ nm_setting_ip_config_clear_routing_rules(NMSettingIPConfig *setting) static GVariant * _routing_rules_dbus_only_synth(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -5620,19 +5620,19 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingIPConfigPrivate *a_priv; NMSettingIPConfigPrivate *b_priv; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_IP_CONFIG_ADDRESSES)) { + if (property_info->param_spec == obj_properties[PROP_ADDRESSES]) { if (set_b) { a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); @@ -5650,7 +5650,7 @@ compare_property(const NMSettInfoSetting *sett_info, return TRUE; } - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_IP_CONFIG_ROUTES)) { + if (property_info->param_spec == obj_properties[PROP_ROUTES]) { if (set_b) { a_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_a); b_priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(set_b); @@ -5667,8 +5667,7 @@ compare_property(const NMSettInfoSetting *sett_info, return TRUE; } - if (nm_streq(sett_info->property_infos[property_idx].name, - NM_SETTING_IP_CONFIG_ROUTING_RULES)) { + if (nm_streq(property_info->name, NM_SETTING_IP_CONFIG_ROUTING_RULES)) { if (set_b) { guint n; @@ -5689,7 +5688,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_ip_config_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } static void diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index 4b6f92083d..a9713221e4 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -334,7 +334,7 @@ ip4_dns_from_dbus(GVariant *dbus_value, GValue *prop_value) static GVariant * ip4_addresses_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -394,7 +394,7 @@ ip4_addresses_set(NMSetting * setting, static GVariant * ip4_address_labels_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -438,7 +438,7 @@ ip4_address_labels_get(const NMSettInfoSetting * sett_info, static GVariant * ip4_address_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -477,7 +477,7 @@ ip4_address_data_set(NMSetting * setting, static GVariant * ip4_routes_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -512,7 +512,7 @@ ip4_routes_set(NMSetting * setting, static GVariant * ip4_route_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 6e0e9897b7..e84ed2894c 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -375,7 +375,7 @@ ip6_dns_from_dbus(GVariant *dbus_value, GValue *prop_value) static GVariant * ip6_addresses_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -420,7 +420,7 @@ ip6_addresses_set(NMSetting * setting, static GVariant * ip6_address_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -459,7 +459,7 @@ ip6_address_data_set(NMSetting * setting, static GVariant * ip6_routes_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -494,7 +494,7 @@ ip6_routes_set(NMSetting * setting, static GVariant * ip6_route_data_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting-ovs-external-ids.c b/src/libnm-core-impl/nm-setting-ovs-external-ids.c index d8f41a5919..151ec350ec 100644 --- a/src/libnm-core-impl/nm-setting-ovs-external-ids.c +++ b/src/libnm-core-impl/nm-setting-ovs-external-ids.c @@ -387,18 +387,18 @@ connection_type_is_good: } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingOvsExternalIDsPrivate *priv; NMSettingOvsExternalIDsPrivate *pri2; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_OVS_EXTERNAL_IDS_DATA)) { + if (property_info->param_spec == obj_properties[PROP_DATA]) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) return NM_TERNARY_DEFAULT; @@ -411,7 +411,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_ovs_external_ids_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index 48f225b6d4..f98d58ccc9 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -70,7 +70,7 @@ struct _NMSettingClass { GError ** error); gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); @@ -82,7 +82,7 @@ struct _NMSettingClass { * @other may be %NULL, in which case the function only determines whether * the setting should be compared (TRUE) or not (DEFAULT). */ NMTernary (*compare_property)(const struct _NMSettInfoSetting *sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * con_a, NMSetting * set_a, NMConnection * con_b, @@ -326,14 +326,14 @@ void _nm_setting_property_set_property_direct(GObject * object, GParamSpec * pspec); GVariant *_nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options); GVariant *_nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting-sriov.c b/src/libnm-core-impl/nm-setting-sriov.c index e55bc4c53f..8864709c3d 100644 --- a/src/libnm-core-impl/nm-setting-sriov.c +++ b/src/libnm-core-impl/nm-setting-sriov.c @@ -876,7 +876,7 @@ _nm_setting_sriov_sort_vfs(NMSettingSriov *setting) static GVariant * vfs_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -1119,19 +1119,19 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingSriov *a; NMSettingSriov *b; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_SRIOV_VFS)) { + if (property_info->param_spec == obj_properties[PROP_VFS]) { if (set_b) { a = NM_SETTING_SRIOV(set_a); b = NM_SETTING_SRIOV(set_b); @@ -1147,7 +1147,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_sriov_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-tc-config.c b/src/libnm-core-impl/nm-setting-tc-config.c index a82e65e61b..873bcede89 100644 --- a/src/libnm-core-impl/nm-setting-tc-config.c +++ b/src/libnm-core-impl/nm-setting-tc-config.c @@ -1314,19 +1314,19 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingTCConfig *a_tc_config = NM_SETTING_TC_CONFIG(set_a); NMSettingTCConfig *b_tc_config = NM_SETTING_TC_CONFIG(set_b); guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TC_CONFIG_QDISCS)) { + if (property_info->param_spec == obj_properties[PROP_QDISCS]) { if (set_b) { if (a_tc_config->qdiscs->len != b_tc_config->qdiscs->len) return FALSE; @@ -1339,7 +1339,7 @@ compare_property(const NMSettInfoSetting *sett_info, return TRUE; } - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TC_CONFIG_TFILTERS)) { + if (property_info->param_spec == obj_properties[PROP_TFILTERS]) { if (set_b) { if (a_tc_config->tfilters->len != b_tc_config->tfilters->len) return FALSE; @@ -1353,7 +1353,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_tc_config_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /** @@ -1482,7 +1482,7 @@ next: static GVariant * tc_qdiscs_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -1680,7 +1680,7 @@ next: static GVariant * tc_tfilters_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting-team-port.c b/src/libnm-core-impl/nm-setting-team-port.c index 11aae92638..d371cda9fe 100644 --- a/src/libnm-core-impl/nm-setting-team-port.c +++ b/src/libnm-core-impl/nm-setting-team-port.c @@ -350,19 +350,18 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingTeamPortPrivate *a_priv; NMSettingTeamPortPrivate *b_priv; - if (nm_streq(sett_info->property_infos[property_idx].name, - NM_SETTING_TEAM_PORT_LINK_WATCHERS)) { + if (property_info->param_spec == obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS]) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) return NM_TERNARY_DEFAULT; if (!set_b) @@ -374,7 +373,7 @@ compare_property(const NMSettInfoSetting *sett_info, TRUE); } - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_PORT_CONFIG)) { + if (property_info->param_spec == obj_properties[NM_TEAM_ATTRIBUTE_CONFIG]) { if (set_b) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { /* If we are trying to match a connection in order to assume it (and thus @@ -395,7 +394,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_team_port_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } static void diff --git a/src/libnm-core-impl/nm-setting-team.c b/src/libnm-core-impl/nm-setting-team.c index 8669c58618..6d4c452661 100644 --- a/src/libnm-core-impl/nm-setting-team.c +++ b/src/libnm-core-impl/nm-setting-team.c @@ -1275,17 +1275,17 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingTeamPrivate *a_priv, *b_priv; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_LINK_WATCHERS)) { + if (property_info->param_spec == obj_properties[NM_TEAM_ATTRIBUTE_LINK_WATCHERS]) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) return NM_TERNARY_DEFAULT; if (!set_b) @@ -1297,7 +1297,7 @@ compare_property(const NMSettInfoSetting *sett_info, TRUE); } - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_TEAM_CONFIG)) { + if (property_info->param_spec == obj_properties[NM_TEAM_ATTRIBUTE_CONFIG]) { if (set_b) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) { /* If we are trying to match a connection in order to assume it (and thus @@ -1318,7 +1318,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_team_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } static void diff --git a/src/libnm-core-impl/nm-setting-user.c b/src/libnm-core-impl/nm-setting-user.c index d5e028ce53..861c90cd4c 100644 --- a/src/libnm-core-impl/nm-setting-user.c +++ b/src/libnm-core-impl/nm-setting-user.c @@ -397,17 +397,17 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingUserPrivate *priv, *pri2; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_USER_DATA)) { + if (property_info->param_spec == obj_properties[PROP_DATA]) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) return NM_TERNARY_DEFAULT; @@ -424,7 +424,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_user_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-vlan.c b/src/libnm-core-impl/nm-setting-vlan.c index 78eb9924bc..1d2bcb93f0 100644 --- a/src/libnm-core-impl/nm-setting-vlan.c +++ b/src/libnm-core-impl/nm-setting-vlan.c @@ -677,7 +677,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static GVariant * _override_flags_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting-vpn.c b/src/libnm-core-impl/nm-setting-vpn.c index 1df4f66130..d44aa07fa0 100644 --- a/src/libnm-core-impl/nm-setting-vpn.c +++ b/src/libnm-core-impl/nm-setting-vpn.c @@ -851,41 +851,41 @@ compare_property_secrets(NMSettingVpn *a, NMSettingVpn *b, NMSettingCompareFlags } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_VPN_SECRETS)) { + if (property_info->param_spec == obj_properties[PROP_SECRETS]) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) return NM_TERNARY_DEFAULT; return compare_property_secrets(NM_SETTING_VPN(set_a), NM_SETTING_VPN(set_b), flags); } return NM_SETTING_CLASS(nm_setting_vpn_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } static gboolean clear_secrets(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { - NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); - GParamSpec * prop_spec = sett_info->property_infos[property_idx].param_spec; + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GHashTableIter iter; const char * secret; gboolean changed = TRUE; - if (!prop_spec || !NM_FLAGS_HAS(prop_spec->flags, NM_SETTING_PARAM_SECRET)) + if (!property_info->param_spec + || !NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) return FALSE; - nm_assert(nm_streq(prop_spec->name, NM_SETTING_VPN_SECRETS)); + nm_assert(nm_streq(property_info->param_spec->name, NM_SETTING_VPN_SECRETS)); if (!priv->secrets) return FALSE; @@ -943,7 +943,7 @@ vpn_secrets_from_dbus(NMSetting * setting, static GVariant * vpn_secrets_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting-wired.c b/src/libnm-core-impl/nm-setting-wired.c index 3c0f0302f5..93071e567f 100644 --- a/src/libnm-core-impl/nm-setting-wired.c +++ b/src/libnm-core-impl/nm-setting-wired.c @@ -976,23 +976,22 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - if (nm_streq(sett_info->property_infos[property_idx].name, - NM_SETTING_WIRED_CLONED_MAC_ADDRESS)) { + if (property_info->param_spec == obj_properties[PROP_CLONED_MAC_ADDRESS]) { return !set_b || nm_streq0(NM_SETTING_WIRED_GET_PRIVATE(set_a)->cloned_mac_address, NM_SETTING_WIRED_GET_PRIVATE(set_b)->cloned_mac_address); } return NM_SETTING_CLASS(nm_setting_wired_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index a270881edf..e913ccca77 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -1461,7 +1461,7 @@ nm_setting_wireguard_clear_peers(NMSettingWireGuard *self) static GVariant * _peers_dbus_only_synth(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -1842,12 +1842,12 @@ need_secrets(NMSetting *setting) static gboolean clear_secrets(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_WIREGUARD_PEERS)) { + if (nm_streq(property_info->name, NM_SETTING_WIREGUARD_PEERS)) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); gboolean peers_changed = FALSE; guint i, j; @@ -1894,7 +1894,7 @@ clear_secrets(const NMSettInfoSetting * sett_info, } return NM_SETTING_CLASS(nm_setting_wireguard_parent_class) - ->clear_secrets(sett_info, property_idx, setting, func, user_data); + ->clear_secrets(sett_info, property_info, setting, func, user_data); } static int @@ -1997,19 +1997,19 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMSettingWireGuardPrivate *a_priv; NMSettingWireGuardPrivate *b_priv; guint i; - if (nm_streq(sett_info->property_infos[property_idx].name, NM_SETTING_WIREGUARD_PEERS)) { + if (nm_streq(property_info->name, NM_SETTING_WIREGUARD_PEERS)) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) return NM_TERNARY_DEFAULT; @@ -2033,7 +2033,7 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_wireguard_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } static void diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index 83f8afc158..a3a5d7f2ff 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -744,7 +744,7 @@ nm_setting_wireless_get_seen_bssid(NMSettingWireless *setting, guint32 i) static GVariant * _to_dbus_fcn_seen_bssids(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -1102,21 +1102,20 @@ mac_addr_rand_ok: } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - if (sett_info->property_infos[property_idx].param_spec - == obj_properties[PROP_CLONED_MAC_ADDRESS]) { + if (property_info->param_spec == obj_properties[PROP_CLONED_MAC_ADDRESS]) { return !set_b || nm_streq0(NM_SETTING_WIRELESS_GET_PRIVATE(set_a)->cloned_mac_address, NM_SETTING_WIRELESS_GET_PRIVATE(set_b)->cloned_mac_address); } - if (sett_info->property_infos[property_idx].param_spec == obj_properties[PROP_SEEN_BSSIDS]) { + if (property_info->param_spec == obj_properties[PROP_SEEN_BSSIDS]) { return !set_b || (nm_strv_ptrarray_cmp(NM_SETTING_WIRELESS_GET_PRIVATE(set_a)->seen_bssids, NM_SETTING_WIRELESS_GET_PRIVATE(set_b)->seen_bssids) @@ -1124,14 +1123,14 @@ compare_property(const NMSettInfoSetting *sett_info, } return NM_SETTING_CLASS(nm_setting_wireless_parent_class) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); } /*****************************************************************************/ static GVariant * nm_setting_wireless_get_security(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index f6ef8c74ba..f5fb3c7a71 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -471,7 +471,7 @@ const NMSettInfoProperty * _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, const char * property_name) { - const NMSettInfoProperty *property; + const NMSettInfoProperty *property_info; gssize idx; nm_assert(property_name); @@ -490,13 +490,13 @@ _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, if (idx < 0) return NULL; - property = &sett_info->property_infos[idx]; + property_info = &sett_info->property_infos[idx]; - nm_assert(idx == 0 || strcmp(property[-1].name, property[0].name) < 0); + nm_assert(idx == 0 || strcmp(property_info[-1].name, property_info[0].name) < 0); nm_assert(idx == sett_info->property_infos_len - 1 - || strcmp(property[0].name, property[1].name) < 0); + || strcmp(property_info[0].name, property_info[1].name) < 0); - return property; + return property_info; } const NMSettInfoSetting * @@ -851,14 +851,12 @@ _finalize_direct(NMSetting *setting) GVariant * _nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[property_idx]; - switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { @@ -909,38 +907,37 @@ _nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting * GVariant * _nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options) { - const NMSettInfoProperty *const property = &sett_info->property_infos[property_idx]; - nm_auto_unset_gvalue GValue prop_value = { + nm_auto_unset_gvalue GValue prop_value = { 0, }; GArray *tmp_array; - nm_assert(property->param_spec); - nm_assert(property->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_gprop); - nm_assert(property->property_type->typdata_to_dbus.gprop_type + nm_assert(property_info->param_spec); + nm_assert(property_info->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_gprop); + nm_assert(property_info->property_type->typdata_to_dbus.gprop_type == NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT - || !property->to_dbus_data.gprop_to_dbus_fcn); + || !property_info->to_dbus_data.gprop_to_dbus_fcn); - g_value_init(&prop_value, property->param_spec->value_type); + g_value_init(&prop_value, property_info->param_spec->value_type); - g_object_get_property(G_OBJECT(setting), property->param_spec->name, &prop_value); + g_object_get_property(G_OBJECT(setting), property_info->param_spec->name, &prop_value); - if (!property->to_dbus_data.including_default - && g_param_value_defaults(property->param_spec, &prop_value)) + if (!property_info->to_dbus_data.including_default + && g_param_value_defaults(property_info->param_spec, &prop_value)) return NULL; - switch (property->property_type->typdata_to_dbus.gprop_type) { + switch (property_info->property_type->typdata_to_dbus.gprop_type) { case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT: - if (property->to_dbus_data.gprop_to_dbus_fcn) - return property->to_dbus_data.gprop_to_dbus_fcn(&prop_value); + if (property_info->to_dbus_data.gprop_to_dbus_fcn) + return property_info->to_dbus_data.gprop_to_dbus_fcn(&prop_value); - return g_dbus_gvalue_to_gvariant(&prop_value, property->property_type->dbus_type); + return g_dbus_gvalue_to_gvariant(&prop_value, property_info->property_type->dbus_type); case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_BYTES: nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_BYTES)); return nm_utils_gbytes_to_variant_ay(g_value_get_boxed(&prop_value)); @@ -966,42 +963,45 @@ _nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * s static GVariant * property_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options, gboolean ignore_flags) { - const NMSettInfoProperty *property = &sett_info->property_infos[property_idx]; - GVariant * variant; + GVariant *variant; - nm_assert(property->property_type->dbus_type); + nm_assert(property_info->property_type->dbus_type); - if (!property->property_type->to_dbus_fcn) { - nm_assert(!property->param_spec); - nm_assert(!property->to_dbus_data.none); + if (!property_info->property_type->to_dbus_fcn) { + nm_assert(!property_info->param_spec); + nm_assert(!property_info->to_dbus_data.none); return NULL; } - if (property->param_spec + if (property_info->param_spec && (!ignore_flags - && !NM_FLAGS_HAS(property->param_spec->flags, NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS))) { - if (!NM_FLAGS_HAS(property->param_spec->flags, G_PARAM_WRITABLE)) + && !NM_FLAGS_HAS(property_info->param_spec->flags, + NM_SETTING_PARAM_TO_DBUS_IGNORE_FLAGS))) { + if (!NM_FLAGS_HAS(property_info->param_spec->flags, G_PARAM_WRITABLE)) return NULL; - if (NM_FLAGS_HAS(property->param_spec->flags, NM_SETTING_PARAM_LEGACY) + if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_LEGACY) && !_nm_utils_is_manager_process) return NULL; - if (NM_FLAGS_HAS(property->param_spec->flags, NM_SETTING_PARAM_SECRET)) { + if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) { NMSettingSecretFlags f = NM_SETTING_SECRET_FLAG_NONE; if (NM_FLAGS_ANY(flags, NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED | NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED | NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED)) { - if (!nm_setting_get_secret_flags(setting, property->param_spec->name, &f, NULL)) + if (!nm_setting_get_secret_flags(setting, + property_info->param_spec->name, + &f, + NULL)) return NULL; } @@ -1013,26 +1013,28 @@ property_to_dbus(const NMSettInfoSetting * sett_info, } } - variant = property->property_type - ->to_dbus_fcn(sett_info, property_idx, connection, setting, flags, options); + variant = property_info->property_type + ->to_dbus_fcn(sett_info, property_info, connection, setting, flags, options); nm_g_variant_take_ref(variant); - nm_assert(!variant || g_variant_is_of_type(variant, property->property_type->dbus_type)); + nm_assert(!variant || g_variant_is_of_type(variant, property_info->property_type->dbus_type)); return variant; } static gboolean -set_property_from_dbus(const NMSettInfoProperty *property, GVariant *src_value, GValue *dst_value) +set_property_from_dbus(const NMSettInfoProperty *property_info, + GVariant * src_value, + GValue * dst_value) { - nm_assert(property->param_spec); - nm_assert(property->property_type->dbus_type); + nm_assert(property_info->param_spec); + nm_assert(property_info->property_type->dbus_type); - if (property->property_type->gprop_from_dbus_fcn) { + if (property_info->property_type->gprop_from_dbus_fcn) { if (!g_variant_type_equal(g_variant_get_type(src_value), - property->property_type->dbus_type)) + property_info->property_type->dbus_type)) return FALSE; - property->property_type->gprop_from_dbus_fcn(src_value, dst_value); + property_info->property_type->gprop_from_dbus_fcn(src_value, dst_value); } else if (dst_value->g_type == G_TYPE_BYTES) { if (!g_variant_is_of_type(src_value, G_VARIANT_TYPE_BYTESTRING)) return FALSE; @@ -1102,11 +1104,13 @@ _nm_setting_to_dbus(NMSetting * setting, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (j = 0; j < sett_info->property_infos_len; j++) { - gs_unref_variant GVariant *dbus_value = NULL; + const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; + gs_unref_variant GVariant *dbus_value = NULL; - dbus_value = property_to_dbus(sett_info, j, connection, setting, flags, options, FALSE); + dbus_value = + property_to_dbus(sett_info, property_info, connection, setting, flags, options, FALSE); if (dbus_value) { - g_variant_builder_add(&builder, "{sv}", sett_info->property_infos[j].name, dbus_value); + g_variant_builder_add(&builder, "{sv}", property_info->name, dbus_value); } } @@ -1382,19 +1386,21 @@ init_from_dbus(NMSetting * setting, const GVariantType * nm_setting_get_dbus_property_type(NMSetting *setting, const char *property_name) { - const NMSettInfoProperty *property; + const NMSettInfoProperty *property_info; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); g_return_val_if_fail(property_name != NULL, NULL); - property = _nm_setting_class_get_property_info(NM_SETTING_GET_CLASS(setting), property_name); + property_info = + _nm_setting_class_get_property_info(NM_SETTING_GET_CLASS(setting), property_name); - g_return_val_if_fail(property != NULL, NULL); + g_return_val_if_fail(property_info != NULL, NULL); - nm_assert(property->property_type); - nm_assert(g_variant_type_string_is_valid((const char *) property->property_type->dbus_type)); + nm_assert(property_info->property_type); + nm_assert( + g_variant_type_string_is_valid((const char *) property_info->property_type->dbus_type)); - return property->property_type->dbus_type; + return property_info->property_type->dbus_type; } gboolean @@ -1690,16 +1696,15 @@ _nm_setting_should_compare_secret_property(NMSetting * setting, } static NMTernary -compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[property_idx]; - const GParamSpec * param_spec = property_info->param_spec; + const GParamSpec *param_spec = property_info->param_spec; if (!param_spec) return NM_TERNARY_DEFAULT; @@ -1732,14 +1737,14 @@ compare_property(const NMSettInfoSetting *sett_info, gs_unref_variant GVariant *value2 = NULL; value1 = property_to_dbus(sett_info, - property_idx, + property_info, con_a, set_a, NM_CONNECTION_SERIALIZE_ALL, NULL, TRUE); value2 = property_to_dbus(sett_info, - property_idx, + property_info, con_b, set_b, NM_CONNECTION_SERIALIZE_ALL, @@ -1753,33 +1758,31 @@ compare_property(const NMSettInfoSetting *sett_info, } static NMTernary -_compare_property(const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, - NMSettingCompareFlags flags) +_compare_property(const NMSettInfoSetting * sett_info, + const NMSettInfoProperty *property_info, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { NMTernary compare_result; nm_assert(sett_info); nm_assert(NM_IS_SETTING_CLASS(sett_info->setting_class)); - nm_assert(property_idx < sett_info->property_infos_len); + nm_assert(property_info); nm_assert(NM_SETTING_GET_CLASS(set_a) == sett_info->setting_class); nm_assert(!set_b || NM_SETTING_GET_CLASS(set_b) == sett_info->setting_class); compare_result = NM_SETTING_GET_CLASS(set_a) - ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); + ->compare_property(sett_info, property_info, con_a, set_a, con_b, set_b, flags); nm_assert(NM_IN_SET(compare_result, NM_TERNARY_DEFAULT, NM_TERNARY_FALSE, NM_TERNARY_TRUE)); /* check that the inferable flag and the GObject property flag corresponds. */ - nm_assert(!NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE) - || !sett_info->property_infos[property_idx].param_spec - || NM_FLAGS_HAS(sett_info->property_infos[property_idx].param_spec->flags, - NM_SETTING_PARAM_INFERRABLE) + nm_assert(!NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_INFERRABLE) || !property_info->param_spec + || NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_INFERRABLE) || compare_result == NM_TERNARY_DEFAULT); #if NM_MORE_ASSERTS > 10 @@ -1787,7 +1790,7 @@ _compare_property(const NMSettInfoSetting *sett_info, nm_assert(!set_b || compare_result == NM_SETTING_GET_CLASS(set_a)->compare_property(sett_info, - property_idx, + property_info, con_b, set_b, con_a, @@ -1849,7 +1852,8 @@ _nm_setting_compare(NMConnection * con_a, } for (i = 0; i < sett_info->property_infos_len; i++) { - if (_compare_property(sett_info, i, con_a, a, con_b, b, flags) == NM_TERNARY_FALSE) + if (_compare_property(sett_info, &sett_info->property_infos[i], con_a, a, con_b, b, flags) + == NM_TERNARY_FALSE) return FALSE; } @@ -2005,12 +2009,12 @@ _nm_setting_diff(NMConnection * con_a, } } else { for (i = 0; i < sett_info->property_infos_len; i++) { - NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN; - const NMSettInfoProperty *property_info; + NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN; + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; NMTernary compare_result; GParamSpec * prop_spec; - compare_result = _compare_property(sett_info, i, con_a, a, con_b, b, flags); + compare_result = _compare_property(sett_info, property_info, con_a, a, con_b, b, flags); if (compare_result == NM_TERNARY_DEFAULT) continue; @@ -2031,15 +2035,14 @@ _nm_setting_diff(NMConnection * con_a, * * We need to double-check whether the property should be ignored by * looking at @a alone. */ - if (_compare_property(sett_info, i, con_a, a, NULL, NULL, flags) + if (_compare_property(sett_info, property_info, con_a, a, NULL, NULL, flags) == NM_TERNARY_DEFAULT) continue; } compared_any = TRUE; - property_info = &sett_info->property_infos[i]; - prop_spec = property_info->param_spec; + prop_spec = property_info->param_spec; if (b) { if (compare_result == NM_TERNARY_FALSE) { @@ -2287,13 +2290,13 @@ _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpoint static gboolean clear_secrets(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - GParamSpec * param_spec = sett_info->property_infos[property_idx].param_spec; + GParamSpec * param_spec = property_info->param_spec; if (!param_spec) return FALSE; @@ -2344,7 +2347,7 @@ _nm_setting_clear_secrets(NMSetting * setting, gboolean changed = FALSE; guint16 i; gboolean (*my_clear_secrets)(const struct _NMSettInfoSetting *sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMSetting * setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); @@ -2355,7 +2358,8 @@ _nm_setting_clear_secrets(NMSetting * setting, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (i = 0; i < sett_info->property_infos_len; i++) { - changed |= my_clear_secrets(sett_info, i, setting, func, user_data); + changed |= + my_clear_secrets(sett_info, &sett_info->property_infos[i], setting, func, user_data); } return changed; } @@ -2689,7 +2693,7 @@ nm_setting_to_string(NMSetting *setting) static GVariant * _nm_setting_get_deprecated_virtual_interface_name(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, diff --git a/src/libnm-core-impl/nm-team-utils.c b/src/libnm-core-impl/nm-team-utils.c index bd9ef510cb..c701161183 100644 --- a/src/libnm-core-impl/nm-team-utils.c +++ b/src/libnm-core-impl/nm-team-utils.c @@ -2731,7 +2731,7 @@ _nm_setting_get_team_setting(struct _NMSetting *setting) static GVariant * _nm_team_settings_property_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -2739,8 +2739,7 @@ _nm_team_settings_property_to_dbus(const NMSettInfoSetting * sett_ { NMTeamSetting * self = _nm_setting_get_team_setting(setting); const TeamAttrData *attr_data = - _team_attr_data_get(self->d.is_port, - sett_info->property_infos[property_idx].param_spec->param_id); + _team_attr_data_get(self->d.is_port, property_info->param_spec->param_id); if (attr_data->team_attr == NM_TEAM_ATTRIBUTE_CONFIG) { const char *config; diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index 12e3bd40f4..064c29bde8 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -4004,7 +4004,7 @@ nm_utils_hwaddr_to_dbus(const char *str) static GVariant * _nm_utils_hwaddr_cloned_get(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -4012,7 +4012,7 @@ _nm_utils_hwaddr_cloned_get(const NMSettInfoSetting * sett_info, { gs_free char *addr = NULL; - nm_assert(nm_streq(sett_info->property_infos[property_idx].name, "cloned-mac-address")); + nm_assert(nm_streq(property_info->name, "cloned-mac-address")); g_object_get(setting, "cloned-mac-address", &addr, NULL); return nm_utils_hwaddr_to_dbus(addr); @@ -4069,7 +4069,7 @@ const NMSettInfoPropertType nm_sett_info_propert_type_cloned_mac_address = static GVariant * _nm_utils_hwaddr_cloned_data_synth(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -4080,7 +4080,7 @@ _nm_utils_hwaddr_cloned_data_synth(const NMSettInfoSetting * sett_ if (!_nm_connection_serialize_non_secret(flags)) return NULL; - nm_assert(nm_streq0(sett_info->property_infos[property_idx].name, "assigned-mac-address")); + nm_assert(nm_streq0(property_info->name, "assigned-mac-address")); g_object_get(setting, "cloned-mac-address", &addr, NULL); @@ -5447,7 +5447,7 @@ nm_utils_base64secret_normalize(const char *base64_key, static GVariant * _nm_utils_bridge_vlans_to_dbus(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags, @@ -5456,7 +5456,7 @@ _nm_utils_bridge_vlans_to_dbus(const NMSettInfoSetting * sett_info gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantBuilder builder; guint i; - const char * property_name = sett_info->property_infos[property_idx].name; + const char * property_name = property_info->name; nm_assert(property_name); diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index 98fc0509ae..6c4ce24788 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -651,7 +651,7 @@ typedef struct _NMSettInfoSetting NMSettInfoSetting; typedef struct _NMSettInfoProperty NMSettInfoProperty; typedef GVariant *(*NMSettInfoPropToDBusFcn)(const NMSettInfoSetting * sett_info, - guint property_idx, + const NMSettInfoProperty * property_info, NMConnection * connection, NMSetting * setting, NMConnectionSerializationFlags flags,