Windows: Avoid potential mismatch in transfer error reporting
authorMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 1 Oct 2013 12:10:48 +0000 (14:10 +0200)
committerPete Batard <pete@akeo.ie>
Tue, 1 Oct 2013 22:59:42 +0000 (23:59 +0100)
The default case in windows_transfer_callback() calls windows_error_str(0)
which will convert the error code returned by GetLastError() to a string.
This currently works because windows_transfer_callback() is either called
with io_result set to NO_ERROR or io_result set to GetLastError().

If windows_transfer_callback() will ever be called with io_result set
differently then the default case might report the wrong error message.

Call windows_error_str(io_result) instead to avoid this.

Closes #151

libusb/os/windows_usb.c
libusb/version_nano.h

index fdc60c7..4493088 100644 (file)
@@ -2078,7 +2078,7 @@ static void windows_transfer_callback(struct usbi_transfer *itransfer, uint32_t
                }
                break;
        default:
-               usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %d: %s", io_result, windows_error_str(0));
+               usbi_err(ITRANSFER_CTX(itransfer), "detected I/O error %d: %s", io_result, windows_error_str(io_result));
                status = LIBUSB_TRANSFER_ERROR;
                break;
        }
index 7d39e3e..d3d70cf 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10844
+#define LIBUSB_NANO 10845