NetworkManager r3251 - in trunk: . src



Author: dcbw
Date: Sat Jan 19 15:13:13 2008
New Revision: 3251
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3251&view=rev

Log:
2008-01-19  Dan Williams  <dcbw redhat com>

	* src/nm-device-802-3-ethernet.c
		- (real_get_best_connection): collapse find_best_connection() into this
			function



Modified:
   trunk/ChangeLog
   trunk/src/nm-device-802-3-ethernet.c

Modified: trunk/src/nm-device-802-3-ethernet.c
==============================================================================
--- trunk/src/nm-device-802-3-ethernet.c	(original)
+++ trunk/src/nm-device-802-3-ethernet.c	Sat Jan 19 15:13:13 2008
@@ -341,54 +341,40 @@
 	return interrupt;
 }
 
-typedef struct BestConnectionInfo {
-	NMDevice8023Ethernet *self;
-	NMConnection *found;
-} BestConnectionInfo;
-
-static void
-find_best_connection (gpointer data, gpointer user_data)
-{
-	BestConnectionInfo *info = (BestConnectionInfo *) user_data;
-	NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (info->self);
-	NMConnection *connection = NM_CONNECTION (data);
-	NMSettingConnection *s_con;
-	NMSettingWired *s_wired;
-
-	if (info->found)
-		return;
-
-	s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
-	if (s_con == NULL)
-		return;
-	if (strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
-		return;
-	if (!s_con->autoconnect)
-		return;
-
-	s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
-	g_return_if_fail (s_wired != NULL);
-
-	if (s_wired->mac_address) {
-		if (memcmp (s_wired->mac_address->data, priv->hw_addr.ether_addr_octet, ETH_ALEN))
-			return;
-	}
-
-	info->found = connection;
-}
-
 static NMConnection *
 real_get_best_connection (NMDevice *dev,
-			  GSList *connections,
+                          GSList *connections,
                           char **specific_object)
 {
-	NMDevice8023Ethernet * self = NM_DEVICE_802_3_ETHERNET (dev);
-	BestConnectionInfo find_info;
+	NMDevice8023Ethernet *self = NM_DEVICE_802_3_ETHERNET (dev);
+	NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (self);
+	GSList *iter;
+
+	for (iter = connections; iter; iter = g_slist_next (iter)) {
+		NMConnection *connection = NM_CONNECTION (iter->data);
+		NMSettingConnection *s_con;
+		NMSettingWired *s_wired;
+
+		s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
+		g_assert (s_con);
+
+		if (strcmp (s_con->type, NM_SETTING_WIRED_SETTING_NAME))
+			continue;
+		if (!s_con->autoconnect)
+			continue;
+
+		s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
+		if (!s_wired)
+			continue;
+
+		if (s_wired->mac_address) {
+			if (memcmp (s_wired->mac_address->data, priv->hw_addr.ether_addr_octet, ETH_ALEN))
+				continue;
+		}
 
-	memset (&find_info, 0, sizeof (BestConnectionInfo));
-	find_info.self = self;
-	g_slist_foreach (connections, find_best_connection, &find_info);
-	return find_info.found;
+		return connection;
+	}
+	return NULL;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]