diff options
author | Tormod Volden <debian.tormod@gmail.com> | 2023-01-26 14:02:35 +0100 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2023-01-28 11:53:06 +0100 |
commit | 2abb2a186e6c085396654851f7d18aa20ce2e753 (patch) | |
tree | 6a95cf7d4a4f54fa3c5aab7564149f123c1afa25 | |
parent | 0dbe62bde3596ab83419462682e1c4409e25408c (diff) | |
download | libusb-2abb2a186e6c085396654851f7d18aa20ce2e753.tar.gz |
xusb: Improve Max LUN retrieval stall handling
Do not show an uninitialized Max LUN value if the pipe stalled.
As suggested by the code comment (but not the old code), set a default
zero value only on pipe stall. On other errors simply error out.
References #1181
Closes #1239
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
-rw-r--r-- | examples/xusb.c | 9 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/examples/xusb.c b/examples/xusb.c index 7c2abb9..441af01 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -470,12 +470,15 @@ static int test_mass_storage(libusb_device_handle *handle, uint8_t endpoint_in, BOMS_GET_MAX_LUN, 0, 0, &lun, 1, 1000); // Some devices send a STALL instead of the actual value. // In such cases we should set lun to 0. - if (r == 0) { + if (r == LIBUSB_ERROR_PIPE) { lun = 0; + printf(" Stalled, setting Max LUN to 0\n"); } else if (r < 0) { - perr(" Failed: %s", libusb_strerror((enum libusb_error)r)); + perr(" Failed.\n"); + return r; + } else { + printf(" Max LUN = %d\n", lun); } - printf(" Max LUN = %d\n", lun); // Send Inquiry printf("\nSending Inquiry:\n"); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 4ac20f3..e443da4 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11783 +#define LIBUSB_NANO 11784 |