darwin: return libusb error codes instead of kernel error codes and fix
authorNathan Hjelm <hjelmn@me.com>
Tue, 27 Aug 2013 02:40:52 +0000 (20:40 -0600)
committerNathan Hjelm <hjelmn@me.com>
Tue, 27 Aug 2013 02:40:52 +0000 (20:40 -0600)
a bug introduced in the last commit.

libusb/os/darwin_usb.c
libusb/version_nano.h

index 933fcd7..889c62a 100644 (file)
@@ -702,7 +702,7 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct da
     else
       usbi_warn (ctx, "could not retrieve device descriptor %.4x:%.4x: %s (%x). skipping device",
                  idVendor, idProduct, darwin_error_str (ret), ret);
-    return -1;
+    return darwin_to_libusb (ret);
   }
 
   /* catch buggy hubs (which appear to be virtual). Apple's own USB prober has problems with these devices. */
@@ -710,7 +710,7 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct da
     /* not a valid device */
     usbi_warn (ctx, "idProduct from iokit (%04x) does not match idProduct in descriptor (%04x). skipping device",
                idProduct, libusb_le16_to_cpu (dev->dev_descriptor.idProduct));
-    return -1;
+    return LIBUSB_ERROR_NO_DEVICE;
   }
 
   usbi_dbg ("cached device descriptor:");
@@ -730,7 +730,7 @@ static int darwin_cache_device_descriptor (struct libusb_context *ctx, struct da
 
   dev->can_enumerate = 1;
 
-  return 0;
+  return LIBUSB_SUCCESS;
 }
 
 static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t service,
@@ -758,6 +758,8 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
 
   usbi_mutex_lock(&darwin_cached_devices_lock);
   do {
+    *cached_out = NULL;
+
     list_for_each_entry(new_device, &darwin_cached_devices, list, struct darwin_cached_device) {
       usbi_dbg("matching sessionID 0x%x against cached device with sessionID 0x%x", sessionID, new_device->session);
       if (new_device->session == sessionID) {
index 623a0bb..aa81a72 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10822
+#define LIBUSB_NANO 10823