~ubuntu-branches/ubuntu/wily/cups/wily

« back to all changes in this revision

Viewing changes to debian/patches/usb-backend-do-not-crash-if-usb-disabled-in-bios.patch

  • Committer: Package Import Robot
  • Author(s): Didier Raboud
  • Date: 2013-05-03 11:30:59 UTC
  • mfrom: (100.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20130503113059-u4vwqd3op51vu7o7
Update the patch adding libusb error handling to also discard its
errors in the counting of warning messages; this should make the
error-suite succeed in more cases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
9
@@ -898,7 +898,8 @@
 
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 */
 
14
+  ssize_t               err = 0,
 
15
+                        numdevs,        /* number of connected devices */
 
16
                         i = 0;
 
17
   uint8_t              conf,           /* Current configuration */
 
18
                        iface,          /* Current interface */
 
19
@@ -917,7 +918,13 @@
 
20
   * Initialize libusb...
 
21
   */
 
22
 
 
23
-  libusb_init(NULL);
 
24
+  err = libusb_init(NULL);
 
25
+  if (err)
 
26
+  {
 
27
+    fprintf(stderr, "WARNING: Unable to initialize USB access via libusb, libusb error %i\n", err);
 
28
+    return (NULL);
 
29
+  }
 
30
+
 
31
   numdevs = libusb_get_device_list(NULL, &list);
 
32
   fprintf(stderr, "DEBUG: libusb_get_device_list=%d\n", (int)numdevs);
 
33
 
 
34
@@ -1087,7 +1094,8 @@
 
35
   * Clean up ....
 
36
   */
 
37
 
 
38
-  libusb_free_device_list(list, 1);
 
39
+  if (numdevs >= 0)
 
40
+    libusb_free_device_list(list, 1);
 
41
   libusb_exit(NULL);
 
42
 
 
43
   return (NULL);
 
44
--- a/test/run-stp-tests.sh
 
45
+++ b/test/run-stp-tests.sh
 
46
@@ -838,7 +838,7 @@
 
47
 fi
 
48
 
 
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