Hello,
i wondered about the error handling in the ReadUSB()/WriteUSB()
functions in ccid_usb.c.
After the call to libusb_bulk_transfer errno is checked and
strerror(errno) printed to the log, resulting in confusing logs because
the return value of libusb_bulk_transfer might indicate an error but
strerror(errno) returns 'Success'.
The libusb 1.0 API documentation does not mention that errno is set by
libusb_bulk_transfer, so don't use it.
The attached patch should clean that up and is compile tested.
Best regards,
Hendrik
Index: src/ccid_usb.c
===================================================================
--- src/ccid_usb.c (revision 7016)
+++ src/ccid_usb.c (working copy)
@@ -756,9 +756,9 @@
{
DEBUG_CRITICAL5("write failed (%d/%d): %d %s",
usbDevice[reader_index].bus_number,
- usbDevice[reader_index].device_address, rv, strerror(errno));
+ usbDevice[reader_index].device_address, rv, libusb_strerror(rv));
- if ((ENODEV == errno) || (LIBUSB_ERROR_NO_DEVICE == rv))
+ if (LIBUSB_ERROR_NO_DEVICE == rv)
return STATUS_NO_SUCH_DEVICE;
return STATUS_UNSUCCESSFUL;
@@ -795,9 +795,9 @@
*length = 0;
DEBUG_CRITICAL5("read failed (%d/%d): %d %s",
usbDevice[reader_index].bus_number,
- usbDevice[reader_index].device_address, rv, strerror(errno));
+ usbDevice[reader_index].device_address, rv, libusb_strerror(rv));
- if ((ENODEV == errno) || (LIBUSB_ERROR_NO_DEVICE == rv))
+ if (LIBUSB_ERROR_NO_DEVICE == rv)
return STATUS_NO_SUCH_DEVICE;
return STATUS_UNSUCCESSFUL;
_______________________________________________
Pcsclite-muscle mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle