[PATCH] core: check the iface index correctly



If the iface name is invalid, the index is -1.
---
 src/nm-device.c                     |    2 +-
 src/vpn-manager/nm-vpn-connection.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nm-device.c b/src/nm-device.c
index 53eece8..e443663 100644
--- a/src/nm-device.c
+++ b/src/nm-device.c
@@ -423,7 +423,7 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
 	priv->ip_iface = g_strdup (iface);
 	if (priv->ip_iface) {
 		priv->ip_ifindex = nm_netlink_iface_to_index (priv->ip_iface);
-		if (!priv->ip_ifindex) {
+		if (priv->ip_ifindex < 0) {
 			nm_log_warn (LOGD_HW, "(%s): failed to look up interface index", iface);
 		}
 	}
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index 73f2b55..d4b5518 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -452,7 +452,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
 
 	/* Grab the interface index for address/routing operations */
 	priv->ip_ifindex = nm_netlink_iface_to_index (priv->ip_iface);
-	if (!priv->ip_ifindex) {
+	if (priv->ip_ifindex < 0) {
 		nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface);
 		goto error;
 	}
-- 
1.7.3.4



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