[PATCH 2/2] Samples: Fix a "value is always 0" Clang warning in xusb.c
Pete Batard
pete at akeo.ie
Wed Mar 28 07:07:40 EDT 2012
This one is due to having to work around a WinUSB limitation that forces
us to use the same value in a place where it should normally not be the
same.
Regards,
/Pete
-------------- next part --------------
>From 498e21d1236feb2ee0b2634dceb8bb9e17b05928 Mon Sep 17 00:00:00 2001
From: Pete Batard <pete at akeo.ie>
Date: Wed, 28 Mar 2012 11:43:00 +0100
Subject: [PATCH 2/2] Samples: Fix a "value is always 0" Clang warning in
xusb.c
* Remove the use of os_fd[i].recipient and alter comments with
regards to Windows Extended Props test limitations with WinUSB
---
examples/xusb.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/examples/xusb.c b/examples/xusb.c
index b94aa1f..f1682ad 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -541,12 +541,7 @@ void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bR
uint16_t header_size;
} os_fd[2] = {
{"Extended Compat ID", LIBUSB_RECIPIENT_DEVICE, 0x0004, 0x10},
- {"Extended Properties", LIBUSB_RECIPIENT_DEVICE, 0x0005, 0x0A}
- // NB: LIBUSB_RECIPIENT_INTERFACE should be used for the Extended Properties.
- // However, for Interface requests, the WinUSB DLL forces the low byte of wIndex
- // to the interface number, regardless of what you set it to, so we have to
- // fallback to Device and hope the firmware answers both equally.
- // See http://www.lvr.com/forum/index.php?topic=331
+ {"Extended Properties", LIBUSB_RECIPIENT_INTERFACE, 0x0005, 0x0A}
};
if (iface_number < 0) return;
@@ -555,7 +550,13 @@ void read_ms_winsub_feature_descriptors(libusb_device_handle *handle, uint8_t bR
printf("\nReading %s OS Feature Descriptor (wIndex = 0x%04d):\n", os_fd[i].desc, os_fd[i].index);
// Read the header part
- r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|os_fd[i].recipient),
+ r = libusb_control_transfer(handle, (uint8_t)(LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_VENDOR|LIBUSB_RECIPIENT_DEVICE),
+ // NB: We should use os_fd[i].recipient instead of LIBUSB_RECIPIENT_DEVICE above, as
+ // LIBUSB_RECIPIENT_INTERFACE should be used for the Extended Properties.
+ // However, for Interface requests, the WinUSB DLL forces the low byte of wIndex
+ // to the interface number, regardless of what you set it to, so we have to
+ // fallback to Device and hope the firmware answers both equally.
+ // See http://www.lvr.com/forum/index.php?topic=331
bRequest, (uint16_t)(((iface_number)<< 8)|0x00), os_fd[i].index, os_desc, os_fd[i].header_size, 1000);
if (r < os_fd[i].header_size) {
perr(" Failed: %s", (r<0)?libusb_error_name((enum libusb_error)r):"header size is too small");
--
1.7.9.msysgit.0
More information about the libusbx
mailing list