summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heider <a.heider@gmail.com>2022-12-24 11:45:43 +0100
committerChristian Marangi <ansuelsmth@gmail.com>2023-01-20 17:26:58 +0100
commitacbf4fe47d8f6dca340ff05c84779bf4fa16b5dd (patch)
tree115f81eca7ecd018e0b14e677e1aecfa7bac762d
parent0172c977592484804a3a8f72781e428fca844cba (diff)
downloadiwinfo-acbf4fe47d8f6dca340ff05c84779bf4fa16b5dd.tar.gz
nl80211: remove redundant check in nl80211_phy2ifname()
phyidx is already checked for <0 a few lines above. Signed-off-by: Andre Heider <a.heider@gmail.com>
-rw-r--r--iwinfo_nl80211.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 7a67467..6b2a87a 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -826,31 +826,28 @@ static char * nl80211_phy2ifname(const char *ifname)
memset(nif, 0, sizeof(nif));
- if (phyidx > -1)
+ if ((d = opendir("/sys/class/net")) != NULL)
{
- if ((d = opendir("/sys/class/net")) != NULL)
+ while ((e = readdir(d)) != NULL)
{
- while ((e = readdir(d)) != NULL)
+ snprintf(buffer, sizeof(buffer),
+ "/sys/class/net/%s/phy80211/index", e->d_name);
+
+ if (nl80211_readint(buffer) == phyidx)
{
snprintf(buffer, sizeof(buffer),
- "/sys/class/net/%s/phy80211/index", e->d_name);
+ "/sys/class/net/%s/ifindex", e->d_name);
- if (nl80211_readint(buffer) == phyidx)
+ if ((cifidx = nl80211_readint(buffer)) >= 0 &&
+ ((ifidx < 0) || (cifidx < ifidx)))
{
- snprintf(buffer, sizeof(buffer),
- "/sys/class/net/%s/ifindex", e->d_name);
-
- if ((cifidx = nl80211_readint(buffer)) >= 0 &&
- ((ifidx < 0) || (cifidx < ifidx)))
- {
- ifidx = cifidx;
- strncpy(nif, e->d_name, sizeof(nif) - 1);
- }
+ ifidx = cifidx;
+ strncpy(nif, e->d_name, sizeof(nif) - 1);
}
}
-
- closedir(d);
}
+
+ closedir(d);
}
return nif[0] ? nif : NULL;