darwin: clean up some code. remove a clang warning
authorNathan Hjelm <hjelmn@me.com>
Tue, 27 Aug 2013 02:12:23 +0000 (20:12 -0600)
committerNathan Hjelm <hjelmn@me.com>
Tue, 27 Aug 2013 02:12:23 +0000 (20:12 -0600)
The check for NULL != cached_device was unnecessary and caused clang's
static analysis to print out a warning.

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

index b0ee5b2..933fcd7 100644 (file)
@@ -743,8 +743,6 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
   kern_return_t result;
   UInt8 port = 0;
 
-  *cached_out = NULL;
-
   /* get some info from the io registry */
   (void) get_ioregistry_value_number (service, CFSTR("sessionID"), kCFNumberSInt64Type, &sessionID);
   (void) get_ioregistry_value_number (service, CFSTR("PortNum"), kCFNumberSInt8Type, &port);
@@ -774,17 +772,15 @@ static int darwin_get_cached_device(struct libusb_context *ctx, io_service_t ser
 
     usbi_dbg("caching new device with sessionID 0x%x\n", sessionID);
 
-    new_device = calloc (1, sizeof (*new_device));
-    if (!new_device) {
-      ret = LIBUSB_ERROR_NO_MEM;
-      break;
-    }
-
     device = darwin_device_from_service (service);
     if (!device) {
       ret = LIBUSB_ERROR_NO_DEVICE;
-      free (new_device);
-      new_device = NULL;
+      break;
+    }
+
+    new_device = calloc (1, sizeof (*new_device));
+    if (!new_device) {
+      ret = LIBUSB_ERROR_NO_MEM;
       break;
     }
 
@@ -834,7 +830,7 @@ static int process_new_device (struct libusb_context *ctx, io_service_t service)
   do {
     ret = darwin_get_cached_device (ctx, service, &cached_device);
 
-    if (ret < 0 || (cached_device && !cached_device->can_enumerate)) {
+    if (ret < 0 || !cached_device->can_enumerate) {
       return ret;
     }
 
index 2e56b17..623a0bb 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10821
+#define LIBUSB_NANO 10822