From 6325c596c093e34d290604e2ef24219427a1078d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 23 Aug 2014 02:27:53 +0200 Subject: [PATCH] libnm: handle all-default settings in nm_setting_to_hash() properly Before, _nm_setting_to_dbus() would return NULL instead of an empty hash. This would be the case, if all properties are default. When exporting connections via DBUS, we eventually call _nm_setting_to_dbus() to convert the connection into a hash of hashes. By _nm_setting_to_hash() converting empty hashes to NULL, the setting is missing. Not returning empty hashes means that to_dbus() and new_from_dbus() don't make a valid round-trip conversion. Fix that by always returning a hash from _nm_setting_to_dbus() https://bugzilla.gnome.org/show_bug.cgi?id=735255 See-also: 4d32618264d7ca169036347a25f38689cce632f3 Signed-off-by: Thomas Haller --- libnm-core/nm-setting.c | 6 ------ libnm-core/tests/test-secrets.c | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index f65171f97e..535706d82d 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -744,12 +744,6 @@ _nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionS destroy_gvalue (value); } - /* 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-core/tests/test-secrets.c b/libnm-core/tests/test-secrets.c index 221fc76028..22aa460ebc 100644 --- a/libnm-core/tests/test-secrets.c +++ b/libnm-core/tests/test-secrets.c @@ -678,7 +678,7 @@ test_update_secrets_whole_connection_empty_base_setting (void) connection = wifi_connection_new (); secrets = nm_connection_to_dbus (connection, NM_CONNECTION_SERIALIZE_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,