NetworkManager r3668 - in trunk: . src



Author: dcbw
Date: Wed May 14 13:59:12 2008
New Revision: 3668
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3668&view=rev

Log:
2008-05-14  Dan Williams  <dcbw redhat com>

	* src/NetworkManagerSystem.c
		- (nm_system_device_is_up_with_iface): clean up



Modified:
   trunk/ChangeLog
   trunk/src/NetworkManagerSystem.c

Modified: trunk/src/NetworkManagerSystem.c
==============================================================================
--- trunk/src/NetworkManagerSystem.c	(original)
+++ trunk/src/NetworkManagerSystem.c	Wed May 14 13:59:12 2008
@@ -470,7 +470,8 @@
 nm_system_device_is_up_with_iface (const char *iface)
 {
 	struct ifreq ifr;
-	int err, fd;
+	int fd;
+	gboolean up = FALSE;
 
 	fd = socket (PF_INET, SOCK_DGRAM, 0);
 	if (fd < 0) {
@@ -480,18 +481,17 @@
 
 	/* Get device's flags */
 	strncpy (ifr.ifr_name, iface, IFNAMSIZ);
-	err = ioctl (fd, SIOCGIFFLAGS, &ifr);
-	close (fd);
-
-	if (!err)
-		return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
-
-	if (errno != ENODEV) {
-		nm_warning ("%s: could not get flags for device %s.  errno = %d", 
-		            __func__, iface, errno);
+	if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0) {
+		if (errno != ENODEV) {
+			nm_warning ("%s: could not get flags for device %s.  errno = %d", 
+			            __func__, iface, errno);
+		}
+	} else {
+		up = !!(ifr.ifr_flags & IFF_UP);
 	}
+	close (fd);
 
-	return FALSE;
+	return up;
 }
 
 gboolean



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