On 2012.09.11 13:04, Hans de Goede wrote:
This patch therefor makes libusb_cancel_transfer not log an error when the
cancel fails with LIBUSB_ERROR_NO_DEVICE, so that apps can properly clean
things up on device disconnect without flooding the console with these errors.
Actually, I'm going to add to that one patch, as the Cypress FX upload
process, which is used in the fxload sample, results in the device
changing its VID:PID on the fly, and we get a "device is not connected"
error on Windows when that happens in the fxload sample, whereas this is
expected behaviour => I'm adding an usbi_err -> usbi_warn for Windows
and altering the subject.
I'm also acking your original patch.
Regards,
/Pete
>From 463ea71de66ca86e2db980c7c99c40c9bdae2d87 Mon Sep 17 00:00:00 2001
From: Pete Batard <p...@akeo.ie>
Date: Wed, 12 Sep 2012 02:03:47 +0100
Subject: [PATCH] All: Avoid polluting errors reported on device disconnect
* Makes libusb_cancel_transfer not log an error when the cancel fails
with LIBUSB_ERROR_NO_DEVICE, so that apps can properly clean things
up on device disconnect without flooding the console with these errors.
* Also, some devices (Cypress FX) may switch VID:PID on the fly during
firmware upload => reduce severity of the Windows message when that happens.
---
libusb/io.c | 3 ++-
libusb/os/windows_usb.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libusb/io.c b/libusb/io.c
index 8a8bc67..1338981 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1417,7 +1417,8 @@ int API_EXPORTED libusb_cancel_transfer(struct
libusb_transfer *transfer)
usbi_mutex_lock(&itransfer->lock);
r = usbi_backend->cancel_transfer(itransfer);
if (r < 0) {
- if (r != LIBUSB_ERROR_NOT_FOUND)
+ if (r != LIBUSB_ERROR_NOT_FOUND &&
+ r != LIBUSB_ERROR_NO_DEVICE)
usbi_err(TRANSFER_CTX(transfer),
"cancel transfer failed error %d", r);
else
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 3b751a5..946c71f 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -2877,7 +2877,7 @@ static int winusbx_submit_control_transfer(int sub_api,
struct usbi_transfer *it
} else {
if (!WinUSBX[sub_api].ControlTransfer(wfd.handle, *setup,
transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, size, NULL, wfd.overlapped)) {
if(GetLastError() != ERROR_IO_PENDING) {
- usbi_err(ctx, "ControlTransfer failed: %s",
windows_error_str(0));
+ usbi_warn(ctx, "ControlTransfer failed: %s",
windows_error_str(0));
usbi_free_fd(wfd.fd);
return LIBUSB_ERROR_IO;
}
--
1.7.11.msysgit.0
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel