hardware: add device ids for QCA9984, 88W8887 and 88W8964 radios
[project/iwinfo.git] / iwinfo_utils.c
index f4b7b58..3090c4c 100644 (file)
@@ -81,7 +81,7 @@ int iwinfo_ifup(const char *ifname)
 {
        struct ifreq ifr;
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
 
        if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
                return 0;
@@ -95,7 +95,7 @@ int iwinfo_ifdown(const char *ifname)
 {
        struct ifreq ifr;
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
 
        if (iwinfo_ioctl(SIOCGIFFLAGS, &ifr))
                return 0;
@@ -109,7 +109,7 @@ int iwinfo_ifmac(const char *ifname)
 {
        struct ifreq ifr;
 
-       strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+       strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
 
        if (iwinfo_ioctl(SIOCGIFHWADDR, &ifr))
                return 0;
@@ -177,8 +177,8 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
        FILE *mtd;
        uint16_t *bc;
 
-       int fd;
-       unsigned int len, off;
+       int fd, off;
+       unsigned int len;
        char buf[128];
 
        if (!(mtd = fopen("/proc/mtd", "r")))
@@ -186,7 +186,7 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)
 
        while (fgets(buf, sizeof(buf), mtd) != NULL)
        {
-               if (fscanf(mtd, "mtd%u: %x %*x %127s", &off, &len, buf) < 3 ||
+               if (fscanf(mtd, "mtd%d: %x %*x %127s", &off, &len, buf) < 3 ||
                    (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") &&
                     strcmp(buf, "\"factory\"")))
                {