libnm: special handle "name" properties compare_fcn

All settings have a "name" property. Their compare_fcn() is not interesting
and was already previously ignored. But we should not special handle it via
_nm_setting_property_compare_fcn_default().
This commit is contained in:
Thomas Haller 2021-06-29 18:06:46 +02:00
parent c7262c2290
commit 33bd052a87
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 14 additions and 8 deletions

View file

@ -389,11 +389,17 @@ _nm_setting_class_commit(NMSettingClass * setting_class,
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_UINT64,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_STRING)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default);
else if (vtype == G_TYPE_DOUBLE)
else if (vtype == G_TYPE_STRING) {
if (nm_streq(p->name, NM_SETTING_NAME)) {
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_ignore);
} else {
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_STRING,
.compare_fcn = _nm_setting_property_compare_fcn_default);
}
} else if (vtype == G_TYPE_DOUBLE)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_DOUBLE,
.compare_fcn = _nm_setting_property_compare_fcn_default);
@ -1756,9 +1762,6 @@ _nm_setting_property_compare_fcn_default(const NMSettInfoSetting * sett_info,
&& NM_FLAGS_HAS(param_spec->flags, NM_SETTING_PARAM_SECRET))
return NM_TERNARY_DEFAULT;
if (nm_streq(param_spec->name, NM_SETTING_NAME))
return NM_TERNARY_DEFAULT;
if (NM_FLAGS_HAS(param_spec->flags, NM_SETTING_PARAM_SECRET)
&& !_nm_setting_should_compare_secret_property(set_a, set_b, param_spec->name, flags))
return NM_TERNARY_DEFAULT;

View file

@ -4526,6 +4526,7 @@ check_done:;
if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_default) {
g_assert(sip->param_spec);
g_assert_cmpstr(sip->name, !=, NM_SETTING_NAME);
} else if (sip->property_type->compare_fcn == _nm_setting_property_compare_fcn_ignore) {
if (NM_IN_SET(sip->property_type,
&nm_sett_info_propert_type_deprecated_ignore_i,
@ -4534,6 +4535,8 @@ check_done:;
/* pass */
} else if (!sip->param_spec) {
/* pass */
} else if (nm_streq(sip->name, NM_SETTING_NAME)) {
/* pass */
} else {
/* ignoring a property for comparison make only sense in very specific cases. */
g_assert_not_reached();