X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=iwinfo_utils.c;h=3b993d124884a061fe8444ac8a871491e03bb379;hb=b19476dec2a657cfb87052f013a98ccb9cfb8109;hp=b313ea2049ca540c24b1922d085485a845c346bf;hpb=fe7133f7e5a4faca63b6d939c6d55d09d8c240fb;p=project%2Fiwinfo.git diff --git a/iwinfo_utils.c b/iwinfo_utils.c index b313ea2..3b993d1 100644 --- a/iwinfo_utils.c +++ b/iwinfo_utils.c @@ -177,13 +177,14 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id) FILE *mtd; uint16_t *bc; - int fd, len, off; + int fd, off; + unsigned int len; char buf[128]; if (!(mtd = fopen("/proc/mtd", "r"))) return -1; - while (fgets(buf, sizeof(buf), mtd) > 0) + while (fgets(buf, sizeof(buf), mtd) != NULL) { if (fscanf(mtd, "mtd%d: %x %*x %127s", &off, &len, buf) < 3 || (strcmp(buf, "\"boardconfig\"") && strcmp(buf, "\"EEPROM\"") && @@ -246,7 +247,7 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id) id->subsystem_vendor_id = 0x1814; /* device */ - if (bc[off] & 0xf0 == 0x30) + if ((bc[off] & 0xf0) == 0x30) id->device_id = (bc[off] >> 8) | (bc[off] & 0x00ff) << 8; else id->device_id = bc[off]; @@ -372,6 +373,7 @@ struct uci_section *iwinfo_uci_get_radio(const char *name, const char *type) struct uci_ptr ptr = { .package = "wireless", .section = name, + .flags = (name && *name == '@') ? UCI_LOOKUP_EXTENDED : 0, }; const char *opt; @@ -381,11 +383,7 @@ struct uci_section *iwinfo_uci_get_radio(const char *name, const char *type) return NULL; } - memset(&ptr, 0, sizeof(ptr)); - ptr.package = "wireless"; - ptr.section = name; - - if (uci_lookup_ptr(uci_ctx, &ptr, NULL, false)) + if (uci_lookup_ptr(uci_ctx, &ptr, NULL, true)) return NULL; if (!ptr.s || strcmp(ptr.s->type, "wifi-device") != 0)