summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/nm-keyfile-writer.c8
-rw-r--r--libnm-core/nm-setting-ip-config.c2
-rw-r--r--libnm-core/nm-setting-user.c19
3 files changed, 9 insertions, 20 deletions
diff --git a/libnm-core/nm-keyfile-writer.c b/libnm-core/nm-keyfile-writer.c
index 8af7c086e7..f92faef5bb 100644
--- a/libnm-core/nm-keyfile-writer.c
+++ b/libnm-core/nm-keyfile-writer.c
@@ -338,13 +338,9 @@ write_hash_of_string (GKeyFile *file,
}
hash = g_value_get_boxed (value);
- keys = (const char **) g_hash_table_get_keys_as_array (hash, &l);
- if (!keys)
- return;
-
- g_qsort_with_data (keys, l, sizeof (const char *), nm_strcmp_p_with_data, NULL);
- for (i = 0; keys[i]; i++) {
+ keys = nm_utils_strdict_get_keys (hash, TRUE, &l);
+ for (i = 0; i < l; i++) {
const char *property, *data;
gboolean write_item = TRUE;
diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c
index 45539becb8..dc8ce564c8 100644
--- a/libnm-core/nm-setting-ip-config.c
+++ b/libnm-core/nm-setting-ip-config.c
@@ -1129,7 +1129,7 @@ _nm_ip_route_get_attributes_direct (NMIPRoute *route)
*
* Returns: (array length=out_length) (transfer container): a %NULL-terminated array
* of attribute names or %NULL if there are no attributes. The order of the returned
- * names is undefined.
+ * names depends on @sorted.
**/
const char **
_nm_ip_route_get_attribute_names (const NMIPRoute *route, gboolean sorted, guint *out_length)
diff --git a/libnm-core/nm-setting-user.c b/libnm-core/nm-setting-user.c
index 526bbd2073..0ebca13770 100644
--- a/libnm-core/nm-setting-user.c
+++ b/libnm-core/nm-setting-user.c
@@ -226,7 +226,6 @@ nm_setting_user_get_keys (NMSettingUser *setting, guint *out_len)
{
NMSettingUser *self = setting;
NMSettingUserPrivate *priv;
- guint len;
g_return_val_if_fail (NM_IS_SETTING_USER (self), NULL);
@@ -237,19 +236,13 @@ nm_setting_user_get_keys (NMSettingUser *setting, guint *out_len)
return priv->keys;
}
- if (!priv->data || !g_hash_table_size (priv->data)) {
- NM_SET_OUT (out_len, 0);
- return (const char **) &priv->keys;
- }
+ priv->keys = nm_utils_strdict_get_keys (priv->data,
+ TRUE,
+ out_len);
- priv->keys = (const char **) g_hash_table_get_keys_as_array (priv->data, &len);
- g_qsort_with_data (priv->keys,
- len,
- sizeof (const char *),
- nm_strcmp_p_with_data,
- NULL);
- NM_SET_OUT (out_len, len);
- return priv->keys;
+ /* don't return %NULL, but hijack the @keys fields as a pseudo
+ * empty strv array. */
+ return priv->keys ?: ((const char **) &priv->keys);
}
/*****************************************************************************/