From ad73a7a1e9035fb30c8a5c03143ef1c41da90f6f 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: [PATCH] libnm-util: return empty hash, not NULL in nm_setting_to_hash() (bgo #740681) 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 already behaves this way, since commit 6325c596c093e34d290604e2ef24219427a1078d. https://bugzilla.gnome.org/show_bug.cgi?id=740681 --- libnm-util/nm-setting.c | 6 ------ libnm-util/tests/test-secrets.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index 4df2bced1..105981bc3 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -349,12 +349,6 @@ 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 hash; } diff --git a/libnm-util/tests/test-secrets.c b/libnm-util/tests/test-secrets.c index 085f10bfc..fb0ad4c7e 100644 --- a/libnm-util/tests/test-secrets.c +++ b/libnm-util/tests/test-secrets.c @@ -681,7 +681,7 @@ test_update_secrets_whole_connection_empty_base_setting (void) connection = wifi_connection_new (); secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ONLY_SECRETS); - g_assert_cmpint (g_hash_table_size (secrets), ==, 1); + g_assert_cmpint (g_hash_table_size (secrets), ==, 3); g_assert (g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SETTING_NAME)); success = nm_connection_update_secrets (connection,