From a67a3439b0eb59a854c0b0d0fedd5b4726ffa8a9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 29 Jul 2018 14:32:36 +0200 Subject: [PATCH] libnm: minor rework checking property flags in _nm_setting_to_dbus() Properties that are backed by a GObject property are fundamentally different. I think it's clearer to rework the check, to first check whether we have a param_spec, and then implement different checks. --- libnm-core/nm-setting.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 1b4f3b23e9..3d0726c7e6 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -794,26 +794,29 @@ _nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionS const NMSettingProperty *property = &properties[i]; GParamSpec *prop_spec = property->param_spec; - if (!prop_spec && !property->synth_func) { - /* D-Bus-only property with no synth_func, so we skip it. */ - continue; + if (!prop_spec) { + if (!property->synth_func) + continue; + + if (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS) + continue; + } else { + if (!(prop_spec->flags & G_PARAM_WRITABLE)) + continue; + + if ( (prop_spec->flags & NM_SETTING_PARAM_LEGACY) + && !_nm_utils_is_manager_process) + continue; + + if ( (flags & NM_CONNECTION_SERIALIZE_NO_SECRETS) + && (prop_spec->flags & NM_SETTING_PARAM_SECRET)) + continue; + + if ( (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS) + && !(prop_spec->flags & NM_SETTING_PARAM_SECRET)) + continue; } - if (prop_spec && !(prop_spec->flags & G_PARAM_WRITABLE)) - continue; - - if ( prop_spec && (prop_spec->flags & NM_SETTING_PARAM_LEGACY) - && !_nm_utils_is_manager_process) - continue; - - if ( (flags & NM_CONNECTION_SERIALIZE_NO_SECRETS) - && (prop_spec && (prop_spec->flags & NM_SETTING_PARAM_SECRET))) - continue; - - if ( (flags & NM_CONNECTION_SERIALIZE_ONLY_SECRETS) - && !(prop_spec && (prop_spec->flags & NM_SETTING_PARAM_SECRET))) - continue; - if (property->synth_func) dbus_value = property->synth_func (setting, connection, property->name); else