No need to check return value of libusb_get_device_descriptor().
Since libusb 1.0.16 this is guaranteed to always succeed. This fixes bug #658.
This commit is contained in:
parent
8de8551b88
commit
2a8f2d41ad
|
@ -228,11 +228,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((ret = libusb_get_device_descriptor( devlist[i], &des)) != 0) {
|
||||
sr_warn("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor( devlist[i], &des);
|
||||
|
||||
if ((ret = libusb_open(devlist[i], &hdl)) < 0)
|
||||
continue;
|
||||
|
|
|
@ -157,8 +157,7 @@ SR_PRIV gboolean match_manuf_prod(libusb_device *dev, const char *manufacturer,
|
|||
ret = FALSE;
|
||||
while (!ret) {
|
||||
/* Assume the FW has not been loaded, unless proven wrong. */
|
||||
if (libusb_get_device_descriptor(dev, &des) != 0)
|
||||
break;
|
||||
libusb_get_device_descriptor(dev, &des);
|
||||
|
||||
if (libusb_open(dev, &hdl) != 0)
|
||||
break;
|
||||
|
@ -211,11 +210,7 @@ SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di)
|
|||
}
|
||||
|
||||
for (i = 0; i < device_count; i++) {
|
||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
if (des.idVendor != devc->profile->vid
|
||||
|| des.idProduct != devc->profile->pid)
|
||||
|
|
|
@ -270,7 +270,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
GSList *l, *devices, *conn_devices;
|
||||
struct libusb_device_descriptor des;
|
||||
libusb_device **devlist;
|
||||
int ret, i, j;
|
||||
int i, j;
|
||||
const char *conn;
|
||||
char connection_id[64];
|
||||
|
||||
|
@ -308,11 +308,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
|
||||
|
||||
|
|
|
@ -76,8 +76,7 @@ static int dso_getmps(libusb_device *dev)
|
|||
const struct libusb_interface_descriptor *intf_dsc;
|
||||
int mps;
|
||||
|
||||
if (libusb_get_device_descriptor(dev, &des) != 0)
|
||||
return 0;
|
||||
libusb_get_device_descriptor(dev, &des);
|
||||
|
||||
if (des.bNumConfigurations != 1)
|
||||
return 0;
|
||||
|
@ -128,11 +127,7 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
|
|||
|
||||
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
|
||||
for (i = 0; devlist[i]; i++) {
|
||||
if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(err));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
if (des.idVendor != devc->profile->fw_vid
|
||||
|| des.idProduct != devc->profile->fw_pid)
|
||||
|
|
|
@ -111,8 +111,7 @@ static gboolean check_conf_profile(libusb_device *dev)
|
|||
ret = FALSE;
|
||||
while (!ret) {
|
||||
/* Assume the FW has not been loaded, unless proven wrong. */
|
||||
if (libusb_get_device_descriptor(dev, &des) != 0)
|
||||
break;
|
||||
libusb_get_device_descriptor(dev, &des);
|
||||
|
||||
if (libusb_open(dev, &hdl) != 0)
|
||||
break;
|
||||
|
@ -148,7 +147,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
GSList *l, *devices, *conn_devices;
|
||||
struct libusb_device_descriptor des;
|
||||
libusb_device **devlist;
|
||||
int ret;
|
||||
unsigned int i, j;
|
||||
const char *conn;
|
||||
char connection_id[64];
|
||||
|
@ -187,11 +185,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des)) != 0) {
|
||||
sr_warn("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
|
||||
|
||||
|
@ -272,11 +266,7 @@ static int logic16_dev_open(struct sr_dev_inst *sdi)
|
|||
}
|
||||
|
||||
for (i = 0; i < device_count; i++) {
|
||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
if (des.idVendor != LOGIC16_VID || des.idProduct != LOGIC16_PID)
|
||||
continue;
|
||||
|
|
|
@ -92,11 +92,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((ret = libusb_get_device_descriptor( devlist[i], &des)) != 0) {
|
||||
sr_warn("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
if ((ret = libusb_open(devlist[i], &hdl)) < 0)
|
||||
continue;
|
||||
|
|
|
@ -63,7 +63,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
struct libusb_device_descriptor des;
|
||||
libusb_device **devlist;
|
||||
GSList *devices;
|
||||
int ret, i;
|
||||
int i;
|
||||
char connection_id[64];
|
||||
|
||||
(void)options;
|
||||
|
@ -73,11 +73,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
devices = NULL;
|
||||
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
|
||||
for (i = 0; devlist[i]; i++) {
|
||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des)) != 0) {
|
||||
sr_warn("Failed to get device descriptor: %s",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
if (des.idVendor != VICTOR_VID || des.idProduct != VICTOR_PID)
|
||||
continue;
|
||||
|
|
|
@ -183,12 +183,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); /* TODO: Errors. */
|
||||
|
||||
for (i = 0; devlist[i]; i++) {
|
||||
ret = libusb_get_device_descriptor(devlist[i], &des);
|
||||
if (ret != 0) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
if ((ret = libusb_open(devlist[i], &hdl)) < 0)
|
||||
continue;
|
||||
|
|
|
@ -114,11 +114,7 @@ static GSList *scpi_usbtmc_libusb_scan(struct drv_context *drvc)
|
|||
return NULL;
|
||||
}
|
||||
for (i = 0; devlist[i]; i++) {
|
||||
if ((ret = libusb_get_device_descriptor(devlist[i], &des)) < 0) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
continue;
|
||||
}
|
||||
libusb_get_device_descriptor(devlist[i], &des);
|
||||
|
||||
for (confidx = 0; confidx < des.bNumConfigurations; confidx++) {
|
||||
if ((ret = libusb_get_config_descriptor(devlist[i], confidx, &confdes)) < 0) {
|
||||
|
@ -198,11 +194,7 @@ static int scpi_usbtmc_libusb_open(void *priv)
|
|||
return SR_ERR;
|
||||
|
||||
dev = libusb_get_device(usb->devhdl);
|
||||
if ((ret = libusb_get_device_descriptor(dev, &des)) < 0) {
|
||||
sr_err("Failed to get device descriptor: %s.",
|
||||
libusb_error_name(ret));
|
||||
return SR_ERR;
|
||||
}
|
||||
libusb_get_device_descriptor(dev, &des);
|
||||
|
||||
for (confidx = 0; confidx < des.bNumConfigurations; confidx++) {
|
||||
if ((ret = libusb_get_config_descriptor(dev, confidx, &confdes)) < 0) {
|
||||
|
|
Loading…
Reference in New Issue