From: Johannes Berg Date: Thu, 12 Mar 2009 10:13:36 +0000 (+0100) Subject: better error reporting if dev/phy does not exist X-Git-Tag: v0.9.11~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=989e97c2b55e4238d6f61edff28858e13032ef35;p=thirdparty%2Fiw.git better error reporting if dev/phy does not exist --- diff --git a/iw.c b/iw.c index f1d912b..9194bbd 100644 --- a/iw.c +++ b/iw.c @@ -149,6 +149,8 @@ static int phy_lookup(char *name) snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", name); fd = open(buf, O_RDONLY); + if (fd < 0) + return -1; pos = read(fd, buf, sizeof(buf) - 1); if (pos < 0) return -1; @@ -200,6 +202,8 @@ static int handle_cmd(struct nl80211_state *state, break; case CIB_NETDEV: devidx = if_nametoindex(*argv); + if (devidx == 0) + devidx = -1; argc--; argv++; break; @@ -207,6 +211,9 @@ static int handle_cmd(struct nl80211_state *state, break; } + if (devidx < 0) + return -errno; + section = command = *argv; argc--; argv++;