Skip to content

[th/fix-print-config-duplicates] core/config: fix duplicate entires in `NetworkManager --print-config` output

Thomas Haller requested to merge th/fix-print-config-duplicates into main

_nm_config_data_log_sort() is used for sorting the groups in the keyfile during nm_config_data_log(). The idea is to present the keyfile in a defined, but useful order.

However, it is not a total order. That is, it will return c=0 (equal) for certain groups, if the pre-existing order in the GKeyFile should be honored. For example, we want to sort all [device*] sections close to each other, but we want to preserve their relative order. In that case, the function would return 0 although the group names differed.

Also, _nm_config_data_log_sort() does not expect to receive duplicate names. It would return c!=0 for comparing "device" and "device".

This means, _nm_config_data_log_sort() is fine for sorting the input as we have it. However, it cannot be used to binary search the groups. This caused that some sections might be duplicated in the NetworkManager --print-config output. Otherwise, it had no bad effects.

Fixes(no-backport): 78d34d7c ('config: fix printing default values for missing sections')

Merge request reports