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 commitad56cfa914
. Later, the condition had to be relaxed for NMSettingGeneric (commit4d32618264
). 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 commit6325c596c0
. https://bugzilla.gnome.org/show_bug.cgi?id=740681
This commit is contained in:
@@ -349,12 +349,6 @@ nm_setting_to_hash (NMSetting *setting, NMSettingHashFlags flags)
|
|||||||
}
|
}
|
||||||
g_free (property_specs);
|
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;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -681,7 +681,7 @@ test_update_secrets_whole_connection_empty_base_setting (void)
|
|||||||
|
|
||||||
connection = wifi_connection_new ();
|
connection = wifi_connection_new ();
|
||||||
secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ONLY_SECRETS);
|
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));
|
g_assert (g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SETTING_NAME));
|
||||||
|
|
||||||
success = nm_connection_update_secrets (connection,
|
success = nm_connection_update_secrets (connection,
|
||||||
|
Reference in New Issue
Block a user