Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: patches/12_check_for_libusb_init_failures.patch

Issue 11038043: Check for failures from libusb_init() in the libusb-1.0 glue code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libmtp/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/libusb1-glue.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Index: src/libusb1-glue.c
2 ===================================================================
3 --- src/libusb1-glue.c (revision 160213)
4 +++ src/libusb1-glue.c (working copy)
5 @@ -84,7 +84,7 @@
6 static const int mtp_device_table_size = sizeof(mtp_device_table) / sizeof(LIBM TP_device_entry_t);
7
8 // Local functions
9 -static void init_usb();
10 +static LIBMTP_error_number_t init_usb();
11 static void close_usb(PTP_USB* ptp_usb);
12 static int find_interface_and_endpoints(libusb_device *dev,
13 uint8_t *interface,
14 @@ -125,16 +125,20 @@
15 }
16
17
18 -static void init_usb()
19 +static LIBMTP_error_number_t init_usb()
20 {
21 /*
22 * Some additional libusb debugging please.
23 * We use the same level debug between MTP and USB.
24 */
25 - libusb_init(NULL);
26 + if (libusb_init(NULL) < 0) {
27 + LIBMTP_ERROR("Libusb1 init failed\n");
28 + return LIBMTP_ERROR_USB_LAYER;
29 + }
30
31 if ((LIBMTP_debug & LIBMTP_DEBUG_USB) != 0)
32 libusb_set_debug(NULL,9);
33 + return LIBMTP_ERROR_NONE;
34 }
35
36 /**
37 @@ -478,8 +482,11 @@
38 ssize_t nrofdevs;
39 libusb_device **devs = NULL;
40 int ret, i;
41 + LIBMTP_error_number_t init_usb_ret;
42
43 - init_usb();
44 + init_usb_ret = init_usb();
45 + if (init_usb_ret != LIBMTP_ERROR_NONE)
46 + return init_usb_ret;
47
48 nrofdevs = libusb_get_device_list (NULL, &devs);
49 for (i = 0; i < nrofdevs ; i++) {
50 @@ -551,8 +558,11 @@
51 ssize_t nrofdevs;
52 libusb_device **devs = NULL;
53 int i;
54 + LIBMTP_error_number_t init_usb_ret;
55
56 - init_usb();
57 + init_usb_ret = init_usb();
58 + if (init_usb_ret != LIBMTP_ERROR_NONE)
59 + return 0;
60
61 nrofdevs = libusb_get_device_list (NULL, &devs);
62 for (i = 0; i < nrofdevs ; i++ ) {
63 @@ -1904,9 +1914,12 @@
64 ssize_t nrofdevs;
65 libusb_device **devs = NULL;
66 struct libusb_device_descriptor desc;
67 + LIBMTP_error_number_t init_usb_ret;
68
69 /* See if we can find this raw device again... */
70 - init_usb();
71 + init_usb_ret = init_usb();
72 + if (init_usb_ret != LIBMTP_ERROR_NONE)
73 + return init_usb_ret;
74
75 nrofdevs = libusb_get_device_list (NULL, &devs);
76 for (i = 0; i < nrofdevs ; i++) {
OLDNEW
« no previous file with comments | « no previous file | src/libusb1-glue.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698