diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-15 16:06:43 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-15 16:52:32 +0100 |
commit | db3240b97147068bff52f2ff140e3f0bb7f60767 (patch) | |
tree | d12849cb6147a3841d53648bd98252719f495324 | |
parent | 8e37d536bd01081487cbb61114f6fb4bd61c7baa (diff) | |
download | NetworkManager-th/nm-hash-all.tar.gz |
all: use nm_str_hash() instead of g_str_hash()th/nm-hash-all
We also do this for libnm and libnm-core, where it causes visible changes
in behavior. But if somebody would rely on the hashing implementation
for hash tables, it would be seriously flawed.
-rw-r--r-- | libnm-core/nm-connection.c | 6 | ||||
-rw-r--r-- | libnm-core/nm-keyfile-reader.c | 2 | ||||
-rw-r--r-- | libnm-core/nm-setting-bond.c | 2 | ||||
-rw-r--r-- | libnm-core/nm-setting-ip-config.c | 4 | ||||
-rw-r--r-- | libnm-core/nm-setting-user.c | 2 | ||||
-rw-r--r-- | libnm-core/nm-setting-vpn.c | 4 | ||||
-rw-r--r-- | libnm-core/nm-setting-wired.c | 2 | ||||
-rw-r--r-- | libnm-core/nm-setting.c | 6 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 10 | ||||
-rw-r--r-- | libnm-core/tests/test-general.c | 4 | ||||
-rw-r--r-- | libnm/nm-device.c | 2 | ||||
-rw-r--r-- | libnm/nm-dhcp-config.c | 2 | ||||
-rw-r--r-- | libnm/nm-manager.c | 2 | ||||
-rw-r--r-- | libnm/nm-object.c | 2 | ||||
-rw-r--r-- | libnm/nm-vpn-plugin-old.c | 4 | ||||
-rw-r--r-- | libnm/nm-vpn-service-plugin.c | 4 |
16 files changed, 29 insertions, 29 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index d5e28f7b3e..5d03295edc 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -587,7 +587,7 @@ nm_connection_diff (NMConnection *a, if (a == b) return TRUE; - diffs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy); + diffs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy); /* Diff A to B, then B to A to capture keys in B that aren't in A */ if (diff_one_connection (a, b, flags, FALSE, diffs)) @@ -1370,7 +1370,7 @@ nm_connection_verify_secrets (NMConnection *connection, GError **error) * @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with * normalization parameters to allow customization of the normalization by providing * specific arguments. Unknown arguments will be ignored and the default will be - * used. The keys must be strings, hashed by g_str_hash() and g_str_equal() functions. + * used. The keys must be strings compared with g_str_equal() function. * The values are opaque and depend on the parameter name. * @modified: (out) (allow-none): outputs whether any settings were modified. * @error: location to store error, or %NULL. Contains the reason, @@ -2716,7 +2716,7 @@ nm_connection_get_private (NMConnection *connection) priv, (GDestroyNotify) nm_connection_private_free); priv->self = connection; - priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); + priv->settings = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, g_object_unref); } return priv; diff --git a/libnm-core/nm-keyfile-reader.c b/libnm-core/nm-keyfile-reader.c index 0ac417cdb4..f40fe60f92 100644 --- a/libnm-core/nm-keyfile-reader.c +++ b/libnm-core/nm-keyfile-reader.c @@ -763,7 +763,7 @@ read_hash_of_string (GKeyFile *file, NMSetting *setting, const char *key) if (NM_IS_SETTING_USER (setting)) { gs_unref_hashtable GHashTable *data = NULL; - data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); for (iter = (const char *const*) keys; *iter; iter++) { gs_free char *to_free = NULL; char *value = NULL; diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index d12940f6f9..e85d1564ea 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -892,7 +892,7 @@ nm_setting_bond_init (NMSettingBond *setting) { NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting); - priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); /* Default values: */ nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr"); diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c index 41ae0993f6..33664ae93a 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -593,7 +593,7 @@ nm_ip_address_set_attribute (NMIPAddress *address, const char *name, GVariant *v g_return_if_fail (strcmp (name, "address") != 0 && strcmp (name, "prefix") != 0); if (!address->attributes) { - address->attributes = g_hash_table_new_full (g_str_hash, g_str_equal, + address->attributes = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref); } @@ -1227,7 +1227,7 @@ nm_ip_route_set_attribute (NMIPRoute *route, const char *name, GVariant *value) && strcmp (name, "next-hop") != 0 && strcmp (name, "metric") != 0); if (!route->attributes) { - route->attributes = g_hash_table_new_full (g_str_hash, g_str_equal, + route->attributes = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref); } diff --git a/libnm-core/nm-setting-user.c b/libnm-core/nm-setting-user.c index 049607e146..526bbd2073 100644 --- a/libnm-core/nm-setting-user.c +++ b/libnm-core/nm-setting-user.c @@ -210,7 +210,7 @@ nm_setting_user_check_val (const char *val, GError **error) static GHashTable * _create_data_hash (void) { - return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + return g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); } /** diff --git a/libnm-core/nm-setting-vpn.c b/libnm-core/nm-setting-vpn.c index 6b42e0c7a6..343bd9aa30 100644 --- a/libnm-core/nm-setting-vpn.c +++ b/libnm-core/nm-setting-vpn.c @@ -722,8 +722,8 @@ nm_setting_vpn_init (NMSettingVpn *setting) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting); - priv->data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - priv->secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, destroy_one_secret); + priv->data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); + priv->secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, destroy_one_secret); } static void diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 9d255e1d07..09ed8949d0 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -829,7 +829,7 @@ nm_setting_wired_init (NMSettingWired *setting) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - priv->s390_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + priv->s390_options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); /* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */ priv->mac_address_blacklist = g_array_new (TRUE, FALSE, sizeof (char *)); diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 9c8e53aeac..297887411d 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -95,7 +95,7 @@ _ensure_registered (void) { if (G_UNLIKELY (registered_settings == NULL)) { nm_g_type_init (); - registered_settings = g_hash_table_new (g_str_hash, g_str_equal); + registered_settings = g_hash_table_new (nm_str_hash, g_str_equal); registered_settings_by_type = g_hash_table_new (_nm_gtype_hash, _nm_gtype_equal); } } @@ -807,7 +807,7 @@ _nm_setting_new_from_dbus (GType setting_type, GVariant *entry, *entry_key; char *key; - keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + keys = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL); g_variant_iter_init (&iter, setting_dict); while ((entry = g_variant_iter_next_value (&iter))) { @@ -1359,7 +1359,7 @@ nm_setting_diff (NMSetting *a, } if (*results == NULL) { - *results = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + *results = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL); results_created = TRUE; } diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 52e320421e..c3001ab5d1 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -144,7 +144,7 @@ init_lang_to_encodings_hash (void) if (G_UNLIKELY (langToEncodings5 == NULL)) { /* Five-letter codes */ enc = (struct IsoLangToEncodings *) &isoLangEntries5[0]; - langToEncodings5 = g_hash_table_new (g_str_hash, g_str_equal); + langToEncodings5 = g_hash_table_new (nm_str_hash, g_str_equal); while (enc->lang) { g_hash_table_insert (langToEncodings5, (gpointer) enc->lang, (gpointer) enc->encodings); @@ -155,7 +155,7 @@ init_lang_to_encodings_hash (void) if (G_UNLIKELY (langToEncodings2 == NULL)) { /* Two-letter codes */ enc = (struct IsoLangToEncodings *) &isoLangEntries2[0]; - langToEncodings2 = g_hash_table_new (g_str_hash, g_str_equal); + langToEncodings2 = g_hash_table_new (nm_str_hash, g_str_equal); while (enc->lang) { g_hash_table_insert (langToEncodings2, (gpointer) enc->lang, (gpointer) enc->encodings); @@ -512,7 +512,7 @@ _nm_utils_strdict_from_dbus (GVariant *dbus_value, const char *key, *value; GHashTable *hash; - hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + hash = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); g_variant_iter_init (&iter, dbus_value); while (g_variant_iter_next (&iter, "{&s&s}", &key, &value)) g_hash_table_insert (hash, g_strdup (key), g_strdup (value)); @@ -527,7 +527,7 @@ _nm_utils_copy_strdict (GHashTable *strdict) GHashTableIter iter; gpointer key, value; - copy = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + copy = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); if (strdict) { g_hash_table_iter_init (&iter, strdict); while (g_hash_table_iter_next (&iter, &key, &value)) @@ -4861,7 +4861,7 @@ nm_utils_parse_variant_attributes (const char *string, g_return_val_if_fail (key_value_separator, NULL); g_return_val_if_fail (!error || !*error, NULL); - ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref); + ht = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref); while (TRUE) { gs_free char *name = NULL, *value = NULL; diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 59af87d324..28724e7fd5 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -6098,7 +6098,7 @@ test_g_ptr_array_insert (void) static void test_g_hash_table_get_keys_as_array (void) { - GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal); + GHashTable *table = g_hash_table_new (nm_str_hash, g_str_equal); guint length = 0; char **keys; @@ -6752,7 +6752,7 @@ test_route_attributes_format (void) gs_unref_hashtable GHashTable *ht = NULL; char *str; - ht = g_hash_table_new_full (g_str_hash, g_str_equal, + ht = g_hash_table_new_full (nm_str_hash, g_str_equal, NULL, (GDestroyNotify) g_variant_unref); str = nm_utils_format_variant_attributes (NULL, ' ', '='); diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 65afd078dc..5e4c789394 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -2570,7 +2570,7 @@ nm_lldp_neighbor_new (void) neigh = g_new0 (NMLldpNeighbor, 1); neigh->refcount = 1; - neigh->attrs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, + neigh->attrs = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref); return neigh; diff --git a/libnm/nm-dhcp-config.c b/libnm/nm-dhcp-config.c index 3161e2960f..33b99ed04b 100644 --- a/libnm/nm-dhcp-config.c +++ b/libnm/nm-dhcp-config.c @@ -51,7 +51,7 @@ nm_dhcp_config_init (NMDhcpConfig *config) { NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (config); - priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); } static gboolean diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index 2f00545d9d..a8752d682d 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -1458,7 +1458,7 @@ checkpoint_rollback_cb (GObject *object, &variant, result, &error)) { - hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + hash = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, NULL); g_variant_iter_init (&iter, variant); while (g_variant_iter_next (&iter, "{&su}", &path, &r)) g_hash_table_insert (hash, g_strdup (path), GUINT_TO_POINTER (r)); diff --git a/libnm/nm-object.c b/libnm/nm-object.c index c344a08dca..8297259d40 100644 --- a/libnm/nm-object.c +++ b/libnm/nm-object.c @@ -955,7 +955,7 @@ _nm_object_register_properties (NMObject *object, G_CALLBACK (properties_changed), object); g_ptr_array_add (priv->proxies, proxy); - instance = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + instance = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); priv->property_tables = g_slist_prepend (priv->property_tables, instance); for (tmp = (NMPropertiesInfo *) info; tmp->name; tmp++) { diff --git a/libnm/nm-vpn-plugin-old.c b/libnm/nm-vpn-plugin-old.c index 2b5922b925..1892c394b7 100644 --- a/libnm/nm-vpn-plugin-old.c +++ b/libnm/nm-vpn-plugin-old.c @@ -728,8 +728,8 @@ nm_vpn_plugin_old_read_vpn_details (int fd, if (out_secrets) g_return_val_if_fail (*out_secrets == NULL, FALSE); - data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret); + data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); + secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, free_secret); line = g_string_new (NULL); diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 31e1295488..79bd0f8193 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -750,8 +750,8 @@ nm_vpn_service_plugin_read_vpn_details (int fd, if (out_secrets) g_return_val_if_fail (*out_secrets == NULL, FALSE); - data = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); - secrets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_secret); + data = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); + secrets = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, free_secret); line = g_string_new (NULL); |