X-Git-Url: https://git.ao2.it/libam7xxx.git/blobdiff_plain/ed6e13d9ce88f2cc1decf9a1defe381613274d27..cdc8537bdeed76136a82d1b6a3afd082620d3721:/src/am7xxx.c?ds=sidebyside diff --git a/src/am7xxx.c b/src/am7xxx.c index 006b216..fedf11a 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -747,12 +747,15 @@ static int open_device(am7xxx_context *ctx, debug(ctx, "libusb_claim_interface failed\n"); debug(ctx, "Cannot claim interface %hhu\n", (*dev)->desc->interface_number); -out_libusb_close: - libusb_close((*dev)->usb_device); - (*dev)->usb_device = NULL; + goto out_libusb_close; } out: return ret; + +out_libusb_close: + libusb_close((*dev)->usb_device); + (*dev)->usb_device = NULL; + return ret; } typedef enum { @@ -837,11 +840,12 @@ static int scan_devices(am7xxx_context *ctx, scan_op op, open_device_index, list[i], dev); - if (ret < 0) { + if (ret < 0) debug(ctx, "open_device failed\n"); - goto out; - } + /* exit the loop unconditionally after + * attempting to open the device + * requested by the user */ goto out; } current_index++;