From 869b6ab56d144ccb105be7186e5d66b4d0f3ed20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 25 Nov 2014 13:41:38 +0100 Subject: libnm-util: return empty hash rather than NULL in nm_setting_to_hash() The function was changed to return NULL instead of empty hash by commit ad56cfa914d6a0f49b51e917ce89001f19c72d9f. Later, the condition had to be relaxed for NMSettingGeneric (commit 4d32618264d7ca169036347a25f38689cce632f3). Unforfunately, it shows up that there are other use cases that require presence of a setting (that might have all properties default), such as NMSettingBridgePort for bridge slave connections. --- libnm-util/nm-setting.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index 4df2bced1d..2e27453dbb 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -349,11 +349,12 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags) } g_free (property_specs); - /* Don't return empty hashes, except for base types */ - if (g_hash_table_size (hash) < 1 && !_nm_setting_is_base_type (setting)) { - g_hash_table_destroy (hash); - hash = NULL; - } + /* Return the hash even if it is empty (due to default values). + * Some settings can have all properties with default values, but + * the presence of the setting may be required. (For example, + * NMSettingGeneric, NMSettingBridgePort, + * NMSettingTeamPort) + */ return hash; } -- cgit v1.2.1