Skip to content

Commit 877b7ee

Browse files
committed
Clear USB fault when getting device ID (Issue #1606)
1 parent 6b56577 commit 877b7ee

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

backend/usb-libusb.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* LIBUSB interface code for CUPS.
33
*
4-
* Copyright © 2020-2025 by OpenPrinting.
4+
* Copyright © 2020-2026 by OpenPrinting.
55
* Copyright © 2007-2019 by Apple Inc.
66
*
77
* Licensed under Apache License v2.0. See the file "LICENSE" for more
@@ -1082,16 +1082,15 @@ get_device_id(usb_printer_t *printer, /* I - Printer */
10821082
char *buffer, /* I - String buffer */
10831083
size_t bufsize) /* I - Number of bytes in buffer */
10841084
{
1085-
size_t length; /* Length of device ID */
1085+
int err; /* libusb error */
1086+
size_t length; /* Length of device ID */
10861087

10871088

1088-
if (libusb_control_transfer(printer->handle,
1089-
LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_ENDPOINT_IN |
1090-
LIBUSB_RECIPIENT_INTERFACE,
1091-
0, printer->conf,
1092-
(printer->iface << 8) | printer->altset,
1093-
(unsigned char *)buffer, bufsize, 5000) < 0)
1089+
if ((err = libusb_control_transfer(printer->handle, LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_ENDPOINT_IN | LIBUSB_RECIPIENT_INTERFACE, 0, printer->conf, (printer->iface << 8) | printer->altset, (unsigned char *)buffer, bufsize, 5000)) < 0)
10941090
{
1091+
if (err == LIBUSB_ERROR_PIPE)
1092+
libusb_clear_halt(printer->handle, printer->read_endp);
1093+
10951094
*buffer = '\0';
10961095
return (-1);
10971096
}

0 commit comments

Comments
 (0)