mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-21 18:10:54 +02:00
libnm: sort attribute names in nm_tc_action_get_attribute_names()
The order in which the attribute names are returns should be defined and stable. Sort them and re-use the helper functions.
This commit is contained in:
parent
17ff856bf4
commit
f299a79d5b
2 changed files with 13 additions and 23 deletions
|
|
@ -442,22 +442,12 @@ nm_tc_action_get_kind (NMTCAction *action)
|
|||
char **
|
||||
nm_tc_action_get_attribute_names (NMTCAction *action)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
const char *key;
|
||||
GPtrArray *names;
|
||||
const char **names;
|
||||
|
||||
g_return_val_if_fail (action != NULL, NULL);
|
||||
g_return_val_if_fail (action, NULL);
|
||||
|
||||
names = g_ptr_array_new ();
|
||||
|
||||
if (action->attributes) {
|
||||
g_hash_table_iter_init (&iter, action->attributes);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *) &key, NULL))
|
||||
g_ptr_array_add (names, g_strdup (key));
|
||||
}
|
||||
g_ptr_array_add (names, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (names, FALSE);
|
||||
names = nm_utils_strdict_get_keys (action->attributes, TRUE, NULL);
|
||||
return nm_utils_strv_make_deep_copied_nonnull (names);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1329,7 +1319,7 @@ _action_to_variant (NMTCAction *action)
|
|||
|
||||
for (i = 0; attrs[i]; i++) {
|
||||
g_variant_builder_add (&builder, "{sv}", attrs[i],
|
||||
nm_tc_action_get_attribute (action, attrs[i]));
|
||||
nm_tc_action_get_attribute (action, attrs[i]));
|
||||
}
|
||||
|
||||
return g_variant_builder_end (&builder);
|
||||
|
|
|
|||
|
|
@ -2453,10 +2453,10 @@ nm_utils_tc_action_from_str (const char *str, GError **error)
|
|||
nm_assert (str);
|
||||
nm_assert (!error || !*error);
|
||||
|
||||
ht = nm_utils_parse_variant_attributes (str,
|
||||
' ', ' ', FALSE,
|
||||
tc_action_attribute_spec,
|
||||
error);
|
||||
ht = nm_utils_parse_variant_attributes (str,
|
||||
' ', ' ', FALSE,
|
||||
tc_action_attribute_spec,
|
||||
error);
|
||||
if (!ht)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -2492,10 +2492,10 @@ nm_utils_tc_action_from_str (const char *str, GError **error)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
options = nm_utils_parse_variant_attributes (rest,
|
||||
' ', ' ', FALSE,
|
||||
attrs,
|
||||
error);
|
||||
options = nm_utils_parse_variant_attributes (rest,
|
||||
' ', ' ', FALSE,
|
||||
attrs,
|
||||
error);
|
||||
if (!options) {
|
||||
nm_tc_action_unref (action);
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue