diff options
author | Thomas Haller <thaller@redhat.com> | 2019-01-10 19:38:36 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-01-11 08:14:31 +0100 |
commit | e950712c256bb353df1b8ac6e7e414625bf87ad5 (patch) | |
tree | afbe05fbb5c7edd59cc0b8e86ac189cbe187a5ee | |
parent | e00dca81e9c718ad188aff49e97f87f99149e115 (diff) | |
download | NetworkManager-th/libnm-setting-compare.tar.gz |
libnm,core: accept failure to _nm_setting_get_property() in _log_connection_get_property()th/libnm-setting-compare
_log_connection_get_property() is a hack, as it cannot meaningfully print complex
properties. Also, it uses _nm_setting_get_property() which can only work with GObject
base properties.
Don't assert against _nm_setting_get_property() returning success. Eventually
we should replace _nm_setting_get_property() by something better. But for the moment,
it's fine to being unable to print a property value.
-rw-r--r-- | libnm-core/nm-setting.c | 9 | ||||
-rw-r--r-- | src/nm-core-utils.c | 2 |
2 files changed, 6 insertions, 5 deletions
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index cfd95a2d3e..0feaa87fb7 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -1016,7 +1016,7 @@ gboolean _nm_setting_get_property (NMSetting *setting, const char *property_name, GValue *value) { const NMSettInfoSetting *sett_info; - GParamSpec *prop_spec; + const NMSettInfoProperty *property_info; g_return_val_if_fail (NM_IS_SETTING (setting), FALSE); g_return_val_if_fail (property_name, FALSE); @@ -1040,13 +1040,14 @@ _nm_setting_get_property (NMSetting *setting, const char *property_name, GValue return TRUE; } - prop_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), property_name); - if (!prop_spec) { + property_info = _nm_sett_info_setting_get_property_info (sett_info, property_name); + if ( !property_info + || !property_info->param_spec) { g_value_unset (value); return FALSE; } - g_value_init (value, prop_spec->value_type); + g_value_init (value, property_info->param_spec->value_type); g_object_get_property (G_OBJECT (setting), property_name, value); return TRUE; } diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 89f8f329f8..3047ebc846 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -2033,7 +2033,7 @@ _log_connection_get_property (NMSetting *setting, const char *name) return g_strdup ("****"); if (!_nm_setting_get_property (setting, name, &val)) - g_return_val_if_reached (FALSE); + return g_strdup ("<unknown>"); if (G_VALUE_HOLDS_STRING (&val)) { const char *val_s; |