1
Description: Add more error handling to the libusb-based USB backend,
2
especially to avoid a crash when USB is disabled in the BIOS. Also
3
discard that error when counting warning messages.
4
Author: Till Kamppeter <till.kamppeter@gmail.com>
5
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1108719
6
Last-Update: 2013-05-03
7
--- a/backend/usb-libusb.c
8
+++ b/backend/usb-libusb.c
10
/* Pointer to current alternate setting */
11
const struct libusb_endpoint_descriptor *endpptr = NULL;
12
/* Pointer to current endpoint */
13
- ssize_t numdevs, /* number of connected devices */
15
+ numdevs, /* number of connected devices */
17
uint8_t conf, /* Current configuration */
18
iface, /* Current interface */
20
* Initialize libusb...
24
+ err = libusb_init(NULL);
27
+ fprintf(stderr, "WARNING: Unable to initialize USB access via libusb, libusb error %i\n", err);
31
numdevs = libusb_get_device_list(NULL, &list);
32
fprintf(stderr, "DEBUG: libusb_get_device_list=%d\n", (int)numdevs);
38
- libusb_free_device_list(list, 1);
40
+ libusb_free_device_list(list, 1);
44
--- a/test/run-stp-tests.sh
45
+++ b/test/run-stp-tests.sh
49
# Warning log messages
50
-count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
51
+count=`$GREP '^W ' /tmp/cups-$user/log/error_log | grep -v 'Unable to initialize USB access via libusb, libusb error' | wc -l | awk '{print $1}'`
52
if test $count != 9; then
53
echo "FAIL: $count warning messages, expected 9."
54
$GREP '^W ' /tmp/cups-$user/log/error_log