mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 00:10:11 +01:00
cli: sort DHCP options in connection show output
Otherwise, the output is unstable and changes every time.
This commit is contained in:
parent
5e69b8b9f1
commit
f2109cb810
1 changed files with 8 additions and 7 deletions
|
|
@ -375,11 +375,10 @@ print_dhcp_config (NMDhcpConfig *dhcp,
|
|||
|
||||
table = nm_dhcp_config_get_options (dhcp);
|
||||
if (table) {
|
||||
GHashTableIter table_iter;
|
||||
gpointer key, value;
|
||||
char **options_arr = NULL;
|
||||
int i = 0;
|
||||
NMC_OUTPUT_DATA_DEFINE_SCOPED (out);
|
||||
gs_free const char **keys = NULL;
|
||||
guint i, nkeys;
|
||||
|
||||
tmpl = (const NMMetaAbstractInfo *const*) nmc_fields_dhcp_config;
|
||||
out_indices = parse_output_fields (one_field,
|
||||
|
|
@ -387,10 +386,12 @@ print_dhcp_config (NMDhcpConfig *dhcp,
|
|||
arr = nmc_dup_fields_array (tmpl, NMC_OF_FLAG_FIELD_NAMES);
|
||||
g_ptr_array_add (out.output_data, arr);
|
||||
|
||||
options_arr = g_new (char *, g_hash_table_size (table) + 1);
|
||||
g_hash_table_iter_init (&table_iter, table);
|
||||
while (g_hash_table_iter_next (&table_iter, &key, &value))
|
||||
options_arr[i++] = g_strdup_printf ("%s = %s", (char *) key, (char *) value);
|
||||
keys = (const char **) g_hash_table_get_keys_as_array (table, &nkeys);
|
||||
nm_utils_strv_sort (keys, nkeys);
|
||||
|
||||
options_arr = g_new (char *, nkeys + 1);
|
||||
for (i = 0; i < nkeys; i++)
|
||||
options_arr[i] = g_strdup_printf ("%s = %s", keys[i], (const char *) g_hash_table_lookup (table, keys[i]));
|
||||
options_arr[i] = NULL;
|
||||
|
||||
arr = nmc_dup_fields_array (tmpl, NMC_OF_FLAG_SECTION_PREFIX);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue