core: check the iface index correctly

If the iface name is invalid, the index is -1.
This commit is contained in:
Gary Ching-Pang Lin 2011-11-23 17:06:19 +08:00 committed by Dan Williams
parent b9ceba6133
commit 4e1abb8315
2 changed files with 2 additions and 2 deletions

View file

@ -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);
}
}

View file

@ -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;
}