1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-08 23:37:47 +02:00

scd: Fix error handling with libusb-compat library.

* scd/ccid-driver.c (bulk_out): Use LIBUSB_ERRNO_NO_SUCH_DEVICE.

--

With libusb-compat library, the error is different than original
libusb.  (The libusb-compat library is used by Fedora.)
This commit is contained in:
NIIBE Yutaka 2015-11-04 21:07:49 +09:00
parent c5a9fedba6
commit 1e94a672ef

View File

@ -1839,6 +1839,11 @@ writen (int fd, const void *buf, size_t nbytes)
return 0; return 0;
} }
#if defined(ENXIO) && !defined(LIBUSB_PATH_MAX) && defined(__GNU_LIBRARY__)
#define LIBUSB_ERRNO_NO_SUCH_DEVICE ENXIO /* libusb-compat */
#elif defined(ENODEV)
#define LIBUSB_ERRNO_NO_SUCH_DEVICE ENODEV /* Original libusb */
#endif
/* Write a MSG of length MSGLEN to the designated bulk out endpoint. /* Write a MSG of length MSGLEN to the designated bulk out endpoint.
Returns 0 on success. */ Returns 0 on success. */
@ -1913,26 +1918,26 @@ bulk_out (ccid_driver_t handle, unsigned char *msg, size_t msglen,
5000 /* ms timeout */); 5000 /* ms timeout */);
if (rc == msglen) if (rc == msglen)
return 0; return 0;
#ifdef ENODEV #ifdef LIBUSB_ERRNO_NO_SUCH_DEVICE
if (rc == -(ENODEV)) if (rc == -(LIBUSB_ERRNO_NO_SUCH_DEVICE))
{ {
/* The Linux libusb returns a negative error value. Catch /* The Linux libusb returns a negative error value. Catch
the most important one. */ the most important one. */
errno = ENODEV; errno = LIBUSB_ERRNO_NO_SUCH_DEVICE;
rc = -1; rc = -1;
} }
#endif /*ENODEV*/ #endif /*LIBUSB_ERRNO_NO_SUCH_DEVICE*/
if (rc == -1) if (rc == -1)
{ {
DEBUGOUT_1 ("usb_bulk_write error: %s\n", strerror (errno)); DEBUGOUT_1 ("usb_bulk_write error: %s\n", strerror (errno));
#ifdef ENODEV #ifdef LIBUSB_ERRNO_NO_SUCH_DEVICE
if (errno == ENODEV) if (errno == LIBUSB_ERRNO_NO_SUCH_DEVICE)
{ {
handle->enodev_seen = 1; handle->enodev_seen = 1;
return CCID_DRIVER_ERR_NO_READER; return CCID_DRIVER_ERR_NO_READER;
} }
#endif /*ENODEV*/ #endif /*LIBUSB_ERRNO_NO_SUCH_DEVICE*/
} }
else else
DEBUGOUT_1 ("usb_bulk_write failed: %d\n", rc); DEBUGOUT_1 ("usb_bulk_write failed: %d\n", rc);