summaryrefslogtreecommitdiff
path: root/libnm-core/nm-setting.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-01-09 09:08:39 +0100
committerThomas Haller <thaller@redhat.com>2019-01-11 11:48:47 +0100
commit885c872d5a542f820afdf4e8ca59c55f39467c7a (patch)
tree1982a91850189b7b13ba9c309c26236fae2b2e8f /libnm-core/nm-setting.h
parent5aace3dfea61b2409d6b62127853bd5ed4721bf2 (diff)
downloadNetworkManager-885c872d5a542f820afdf4e8ca59c55f39467c7a.tar.gz
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers: nm_setting_compare() and nm_setting_diff(). compare_property() accepts a NMSettingCompareFlags argument, but at the same time, both callers have another complex (and inconsistent!) set of pre-checks for shortcuting the call of compare_property(): should_compare_prop(). Merge should_compare_prop() into compare_property(). This way, nm_setting_compare() and nm_setting_diff() has less additional code, and are simpler to follow. Especially nm_setting_compare() is now trivial. And nm_setting_diff() is still complicated, but not related to the question how the property compares or whether it should be compared at all. If you want to know whether it should be compared, all you need to do now is follow NMSettingClass.compare_property(). This changes function pointer NMSettingClass.compare_property(), which is public API. However, no user can actually use this (and shall not!), because _nm_setting_class_commit_full() etc. is private API. A user outside of libnm-core cannot create his/her own subclasses of NMSetting, and never could in the past. So, this API/ABI change doesn't matter.
Diffstat (limited to 'libnm-core/nm-setting.h')
-rw-r--r--libnm-core/nm-setting.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h
index 3576bdc663..326b533f12 100644
--- a/libnm-core/nm-setting.h
+++ b/libnm-core/nm-setting.h
@@ -169,6 +169,7 @@ typedef gboolean (*NMSettingClearSecretsWithFlagsFn) (NMSetting *setting,
gpointer user_data);
struct _NMMetaSettingInfo;
+struct _NMSettInfoSetting;
typedef struct {
GObjectClass parent;
@@ -204,11 +205,18 @@ typedef struct {
NMSettingClearSecretsWithFlagsFn func,
gpointer user_data);
- /* Returns TRUE if the given property contains the same value in both settings */
- gboolean (*compare_property) (NMSetting *setting,
- NMSetting *other,
- const GParamSpec *prop_spec,
- NMSettingCompareFlags flags);
+ /* compare_property() returns a ternary, where DEFAULT means that the property should not
+ * be compared due to the compare @flags. A TRUE/FALSE result means that the property is
+ * equal/not-equal.
+ *
+ * @other may be %NULL, in which case the function only determines whether
+ * the setting should be compared (TRUE) or not (DEFAULT). */
+ /*< private >*/
+ NMTernary (*compare_property) (const struct _NMSettInfoSetting *sett_info,
+ guint property_idx,
+ NMSetting *setting,
+ NMSetting *other,
+ NMSettingCompareFlags flags);
/*< private >*/
const struct _NMMetaSettingInfo *setting_info;