fx2lafw: Safer use of libusb_get_device_list
This commit is contained in:
parent
1054920344
commit
6fbe5e6081
|
@ -175,8 +175,14 @@ static int fx2lafw_dev_open(int dev_index)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
skip = 0;
|
skip = 0;
|
||||||
libusb_get_device_list(usb_context, &devlist);
|
const int device_count = libusb_get_device_list(usb_context, &devlist);
|
||||||
for (i = 0; devlist[i]; i++) {
|
if (device_count < 0) {
|
||||||
|
sr_err("fx2lafw: Failed to retrieve device list (%d)",
|
||||||
|
device_count);
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < device_count; i++) {
|
||||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
|
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
|
||||||
sr_err("fx2lafw: Failed to get device descriptor: %d.",
|
sr_err("fx2lafw: Failed to get device descriptor: %d.",
|
||||||
ret);
|
ret);
|
||||||
|
|
Loading…
Reference in New Issue