iwinfo: fix iwinfo_hardware() return value if chip id is not found

SVN-Revision: 36471
This commit is contained in:
Jo-Philipp Wich 2013-04-28 14:04:39 +00:00
parent ad1d3f00cb
commit f1e214411d
2 changed files with 4 additions and 7 deletions

View file

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo PKG_NAME:=libiwinfo
PKG_RELEASE:=43 PKG_RELEASE:=44
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_CONFIG_DEPENDS := \ PKG_CONFIG_DEPENDS := \

View file

@ -131,7 +131,7 @@ struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id)
{ {
FILE *db; FILE *db;
char buf[256] = { 0 }; char buf[256] = { 0 };
static struct iwinfo_hardware_entry e; static struct iwinfo_hardware_entry e, *rv = NULL;
if (!(db = fopen(IWINFO_HARDWARE_FILE, "r"))) if (!(db = fopen(IWINFO_HARDWARE_FILE, "r")))
return NULL; return NULL;
@ -161,15 +161,12 @@ struct iwinfo_hardware_entry * iwinfo_hardware(struct iwinfo_hardware_id *id)
(e.subsystem_device_id != id->subsystem_device_id)) (e.subsystem_device_id != id->subsystem_device_id))
continue; continue;
rv = &e;
break; break;
} }
fclose(db); fclose(db);
return rv;
if (e.device_name[0])
return &e;
return NULL;
} }
int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id) int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id)