devices: Add Cypress CYW43455
[project/iwinfo.git] / iwinfo_nl80211.c
index 84d69e8c32953ad1f224a7993aa5c96ab0bda077..c4b0ee2d7f0635a99ab6a3b0e309319e85bcd6a4 100644 (file)
@@ -298,12 +298,18 @@ static int nl80211_phy_idx_from_path(const char *path)
        char buf[128];
        struct dirent *e;
        const char *cur_path;
+       int cur_path_len;
+       int path_len;
        int idx = -1;
        DIR *d;
 
        if (!path)
                return -1;
 
+       path_len = strlen(path);
+       if (!path_len)
+               return -1;
+
        d = opendir("/sys/class/ieee80211");
        if (!d)
                return -1;
@@ -313,7 +319,11 @@ static int nl80211_phy_idx_from_path(const char *path)
                if (!cur_path)
                        continue;
 
-               if (strcmp(cur_path, path) != 0)
+               cur_path_len = strlen(cur_path);
+               if (cur_path_len < path_len)
+                       continue;
+
+               if (strcmp(cur_path + cur_path_len - path_len, path) != 0)
                        continue;
 
                snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", e->d_name);
@@ -392,7 +402,7 @@ static int nl80211_phy_idx_from_uci(const char *name)
                goto out;
 
        opt = uci_lookup_option_string(uci_ctx, s, "phy");
-       idx = nl80211_phy_idx_from_phy(s);
+       idx = nl80211_phy_idx_from_phy(opt);
 
 out:
        iwinfo_uci_free();