]> sigrok.org Git - libsigrok.git/commitdiff
No need to check return value of libusb_get_device_descriptor().
authorBert Vermeulen <redacted>
Sat, 19 Sep 2015 15:59:54 +0000 (17:59 +0200)
committerUwe Hermann <redacted>
Sun, 20 Sep 2015 22:25:40 +0000 (00:25 +0200)
Since libusb 1.0.16 this is guaranteed to always succeed.

This fixes bug #658.

src/hardware/fx2lafw/api.c
src/hardware/fx2lafw/protocol.c
src/hardware/hantek-dso/api.c
src/hardware/hantek-dso/dso.c
src/hardware/saleae-logic16/api.c
src/hardware/testo/api.c
src/hardware/victor-dmm/api.c
src/hardware/zeroplus-logic-cube/api.c
src/scpi/scpi_usbtmc_libusb.c

index ed4405373720f5f693315f001070e28d099a01c8..16ab9be01a6846d6c41c0222ca5dd89e978da168 100644 (file)
@@ -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;
index 32a65c501b6257d16e85308b23b4c778d8b0a2ad..12fc9e2c061166405b494ad813c6c704d146d1fe 100644 (file)
@@ -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)
index 4e8ac83fcac5804a9cb599cf6c114cffc1842e94..b05e644aff3b616f66a13db3fab75f2aa2d279dc 100644 (file)
@@ -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));
 
index 79c160088dfa06d930669f4677be4f55f8f3b2d0..8561ac3ded1494474bd48564cee18cc15e734874 100644 (file)
@@ -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)
index 95b28f1271a47675ccd70e7fb58f2d07e64b0be9..9d5231440bf806f6d05b930d0bec23257e5f7701 100644 (file)
@@ -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;
index 6907ba4ec8023dbfc0b6891730658c6e67933d1c..0c37886e30c9d995e17c1a9c95eeee59c24e3679 100644 (file)
@@ -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;
index 6f7416ce72e390349e2b9dbc1c35084e11b3e2bf..8e8f0276e60c8a97b8fd7f0083966004da19e10c 100644 (file)
@@ -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;
index 7886fbbdce00e861e3f6012e15295a4b3d197c22..50b7df9e423ece744797a9af375bf7af8403a9f3 100644 (file)
@@ -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;
index a6eb922b9a67eb1e9aceb57b1a627747370f1657..d54ea40c7e2d5dd31ccb3441b42b092e98f206b1 100644 (file)
@@ -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) {