summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2013-02-02 01:02:18 +0000
committerPete Batard <pete@akeo.ie>2013-02-02 01:02:18 +0000
commit4d15ffc486f4b1153391f9b9e778312c8b63c43c (patch)
tree8612dcf15f2d9a2d7427c5d2bdc82f9d61e07044
parentaa482f89ac2fd157fb039bf4518a951aac35acdc (diff)
downloadlibusb-4d15ffc486f4b1153391f9b9e778312c8b63c43c.tar.gz
Windows: Improve error reporting in winusbx_claim_interface()
* After the filter detection code is run, the error reported may have nothing to do with the original error (or report SUCCESS) and is unhelpful * Also change TODO comments to default VS2012 task style
-rw-r--r--libusb/os/windows_usb.c13
-rw-r--r--libusb/version_nano.h2
2 files changed, 8 insertions, 7 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index ee7a9f1..8a8caf4 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -635,7 +635,7 @@ static unsigned long get_ancestor_session_id(DWORD devinst, unsigned level)
if (CM_Get_Device_IDA(devinst, path, MAX_PATH_LENGTH, 0) != CR_SUCCESS) {
return 0;
}
- // TODO (post hotplug): try without sanitizing
+ // TODO: (post hotplug): try without sanitizing
sanitized_path = sanitize_path(path);
if (sanitized_path == NULL) {
return 0;
@@ -2664,6 +2664,7 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
struct windows_device_priv *priv = _device_priv(dev_handle->dev);
bool is_using_usbccgp = (priv->apib->id == USB_API_COMPOSITE);
HANDLE file_handle, winusb_handle;
+ DWORD err;
int i;
SP_DEVICE_INTERFACE_DETAIL_DATA_A *dev_interface_details = NULL;
HDEVINFO dev_info;
@@ -2685,15 +2686,15 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
if (!WinUSBX[sub_api].Initialize(file_handle, &winusb_handle)) {
handle_priv->interface_handle[iface].api_handle = INVALID_HANDLE_VALUE;
-
- switch(GetLastError()) {
+ err = GetLastError();
+ switch(err) {
case ERROR_BAD_COMMAND:
// The device was disconnected
usbi_err(ctx, "could not access interface %d: %s", iface, windows_error_str(0));
return LIBUSB_ERROR_NO_DEVICE;
default:
// it may be that we're using the libusb0 filter driver.
- // [TODO] can we move this whole business into the K/0 DLL?
+ // TODO: can we move this whole business into the K/0 DLL?
for (i = 0; ; i++) {
safe_free(dev_interface_details);
safe_free(dev_path_no_guid);
@@ -2719,7 +2720,7 @@ static int winusbx_claim_interface(int sub_api, struct libusb_device_handle *dev
}
}
if (!found_filter) {
- usbi_err(ctx, "could not access interface %d: %s", iface, windows_error_str(0));
+ usbi_err(ctx, "could not access interface %d: %s", iface, windows_error_str(err));
return LIBUSB_ERROR_ACCESS;
}
}
@@ -3057,7 +3058,7 @@ static int winusbx_abort_transfers(int sub_api, struct usbi_transfer *itransfer)
* IOCTL_USB_HUB_CYCLE_PORT ioctl was removed from Vista => the best we can do is
* cycle the pipes (and even then, the control pipe can not be reset using WinUSB)
*/
-// TODO (post hotplug): see if we can force eject the device and redetect it (reuse hotplug?)
+// TODO: (post hotplug): see if we can force eject the device and redetect it (reuse hotplug?)
static int winusbx_reset_device(int sub_api, struct libusb_device_handle *dev_handle)
{
struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev);
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index bc838f0..44e6d46 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10601
+#define LIBUSB_NANO 10602