linux_usbfs: Fixed excessive check
authorRoman Kalashnikov <lunix0x@gmail.com>
Sat, 28 Oct 2017 17:31:39 +0000 (20:31 +0300)
committerChris Dickens <christopher.a.dickens@gmail.com>
Fri, 22 Dec 2017 19:34:12 +0000 (11:34 -0800)
Closes #358

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/linux_usbfs.c
libusb/version_nano.h

index 98cce75..9486d66 100644 (file)
@@ -1716,10 +1716,7 @@ static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle,
        strcpy(dc.driver, "usbfs");
        dc.flags = USBFS_DISCONNECT_CLAIM_EXCEPT_DRIVER;
        r = ioctl(fd, IOCTL_USBFS_DISCONNECT_CLAIM, &dc);
-       if (r == 0 || (r != 0 && errno != ENOTTY)) {
-               if (r == 0)
-                       return 0;
-
+       if (r != 0 && errno != ENOTTY) {
                switch (errno) {
                case EBUSY:
                        return LIBUSB_ERROR_BUSY;
@@ -1731,7 +1728,8 @@ static int detach_kernel_driver_and_claim(struct libusb_device_handle *handle,
                usbi_err(HANDLE_CTX(handle),
                        "disconnect-and-claim failed errno %d", errno);
                return LIBUSB_ERROR_OTHER;
-       }
+       } else if (r == 0)
+               return 0;
 
        /* Fallback code for kernels which don't support the
           disconnect-and-claim ioctl */
index d7e79b6..129f818 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11217
+#define LIBUSB_NANO 11218