summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-05-27 16:20:53 +0200
committerThomas Haller <thaller@redhat.com>2019-06-13 16:10:53 +0200
commitd92356c8683b18fc80e3a15b79878ef0828300f1 (patch)
tree2a9bc0cd46567e19f7c0c5d74a5891da8a257369
parentceaf64eee7c2e7e9cf596bbd601420557dd8feee (diff)
downloadNetworkManager-d92356c8683b18fc80e3a15b79878ef0828300f1.tar.gz
settings: use _nm_utils_slist_to_strv() for NMSettings:unmanaged-specs property getter
Note that now the empty list will be represented as %NULL instead of an empty strv array. That makes no difference in pratice. The main use of this property is as glue for NMDBusManager to expose the property on D-Bus. Thereby it uses g_dbus_gvalue_to_gvariant() which handles %NULL just fine.
-rw-r--r--src/settings/nm-settings.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
index 0bd0f05cc3..d42d439ff3 100644
--- a/src/settings/nm-settings.c
+++ b/src/settings/nm-settings.c
@@ -1865,26 +1865,19 @@ get_property (GObject *object, guint prop_id,
{
NMSettings *self = NM_SETTINGS (object);
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
- const GSList *specs, *iter;
- guint i;
- char **strvs;
const char **strv;
switch (prop_id) {
case PROP_UNMANAGED_SPECS:
- specs = nm_settings_get_unmanaged_specs (self);
- strvs = g_new (char *, g_slist_length ((GSList *) specs) + 1);
- i = 0;
- for (iter = specs; iter; iter = iter->next)
- strvs[i++] = g_strdup (iter->data);
- strvs[i] = NULL;
- g_value_take_boxed (value, strvs);
+ g_value_take_boxed (value,
+ _nm_utils_slist_to_strv (nm_settings_get_unmanaged_specs (self),
+ TRUE));
break;
case PROP_HOSTNAME:
g_value_set_string (value,
- priv->hostname_manager
- ? nm_hostname_manager_get_hostname (priv->hostname_manager)
- : NULL);
+ priv->hostname_manager
+ ? nm_hostname_manager_get_hostname (priv->hostname_manager)
+ : NULL);
break;
case PROP_CAN_MODIFY:
g_value_set_boolean (value, TRUE);