From 02d942320d8dfe2a51046ff6861e7ec8fb5b2d9e Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 17 Nov 2010 17:42:22 -0600 Subject: [PATCH] core: fix nm_settings_get_connections() result confusion It used to reference items in the list, but no longer does because that's stupid. Fixes some merge damage and a leak. --- src/nm-manager.c | 25 ++++++++++--------------- src/nm-policy.c | 9 +++------ src/settings/nm-settings.c | 6 +++--- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 301cd87927..740a9a5b00 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -992,32 +992,27 @@ manager_hidden_ap_found (NMDeviceInterface *device, s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS); if (!s_wireless) - goto next; + continue; num_bssids = nm_setting_wireless_get_num_seen_bssids (s_wireless); if (num_bssids < 1) - goto next; + continue; ssid = nm_setting_wireless_get_ssid (s_wireless); g_assert (ssid); - for (i = 0; i < num_bssids; i++) { + for (i = 0; i < num_bssids && !done; i++) { const char *seen_bssid = nm_setting_wireless_get_seen_bssid (s_wireless, i); struct ether_addr seen_addr; - if (!ether_aton_r (seen_bssid, &seen_addr)) - continue; - - if (memcmp (ap_addr, &seen_addr, sizeof (struct ether_addr))) - continue; - - /* Copy the SSID from the connection to the AP */ - nm_ap_set_ssid (ap, ssid); - done = TRUE; + if (ether_aton_r (seen_bssid, &seen_addr)) { + if (memcmp (ap_addr, &seen_addr, sizeof (struct ether_addr))) { + /* Copy the SSID from the connection to the AP */ + nm_ap_set_ssid (ap, ssid); + done = TRUE; + } + } } - -next: - g_object_unref (connection); } g_slist_free (connections); } diff --git a/src/nm-policy.c b/src/nm-policy.c index 4f525459f5..6bad928cf3 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -767,11 +767,9 @@ auto_activate_device (gpointer user_data) if (g_object_get_data (G_OBJECT (iter_connection), INVALID_TAG)) { guint retries = get_connection_auto_retries (iter_connection); - if (retries == 0) { - connections = g_slist_remove_link (connections, iter); - g_object_unref (iter_connection); - g_slist_free (iter); - } else if (retries > 0) + if (retries == 0) + connections = g_slist_remove (connections, iter_connection); + else if (retries > 0) set_connection_auto_retries (iter_connection, retries - 1); } else { /* Set the initial # of retries for auto-connection */ @@ -802,7 +800,6 @@ auto_activate_device (gpointer user_data) } } - g_slist_foreach (connections, (GFunc) g_object_unref, NULL); g_slist_free (connections); out: diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index f37b14b0da..8454eb5bb0 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -240,8 +240,8 @@ connection_sort (gconstpointer pa, gconstpointer pb) return 1; } -/* Returns a GSList of referenced NMConnection objects, caller must - * unref the connections in the list and destroy the list. +/* Returns a list of NMSysconfigConnections. Caller must free the list with + * g_slist_free(). */ GSList * nm_settings_get_connections (NMSettings *self) @@ -255,7 +255,7 @@ nm_settings_get_connections (NMSettings *self) g_hash_table_iter_init (&iter, NM_SETTINGS_GET_PRIVATE (self)->connections); while (g_hash_table_iter_next (&iter, NULL, &data)) list = g_slist_insert_sorted (list, data, connection_sort); - return g_slist_reverse (list); + return list; } NMSysconfigConnection *