darwin: locationID is 32-bit, not 64-bit
Also zero-initialize locationID since otherwise it could be used
uninitialized.
Also change the return variable to bool, matching what the function
actually returns.
Fortunately, this only affected log messages.
Closes #1412
[Tormod: Use PRIx32 for printing the 32-bit locationID]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 607d8da..c0963e0 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -629,8 +629,6 @@
struct darwin_cached_device *old_device;
io_service_t device;
- UInt64 session, locationID;
- int ret;
usbi_mutex_lock(&active_contexts_lock);
@@ -638,7 +636,9 @@
bool is_reenumerating = false;
/* get the location from the i/o registry */
- ret = get_ioregistry_value_number (device, CFSTR("sessionID"), kCFNumberSInt64Type, &session);
+ UInt64 session = 0;
+ bool ret = get_ioregistry_value_number (device, CFSTR("sessionID"), kCFNumberSInt64Type, &session);
+ UInt32 locationID = 0;
(void) get_ioregistry_value_number (device, CFSTR("locationID"), kCFNumberSInt32Type, &locationID);
IOObjectRelease (device);
if (!ret)
@@ -652,8 +652,8 @@
if (old_device->in_reenumerate) {
/* device is re-enumerating. do not dereference the device at this time. libusb_reset_device()
* will deref if needed. */
- usbi_dbg (NULL, "detected device detached due to re-enumeration. sessionID: 0x%" PRIx64 ", locationID: 0x%" PRIx64,
- session, locationID);
+ usbi_dbg (NULL, "detected device detached due to re-enumeration. sessionID: 0x%" PRIx64
+ ", locationID: 0x%" PRIx32, session, locationID);
/* the device object is no longer usable so go ahead and release it */
if (old_device->device) {
@@ -1287,7 +1287,7 @@
usbi_mutex_lock(&darwin_cached_devices_mutex);
do {
list_for_each_entry(new_device, &darwin_cached_devices, list, struct darwin_cached_device) {
- usbi_dbg(ctx, "matching sessionID/locationID 0x%" PRIx64 "/0x%x against cached device with sessionID/locationID 0x%" PRIx64 "/0x%x",
+ usbi_dbg(ctx, "matching sessionID/locationID 0x%" PRIx64 "/0x%" PRIx32 " against cached device with sessionID/locationID 0x%" PRIx64 "/0x%" PRIx32,
sessionID, locationID, new_device->session, new_device->location);
if (new_device->location == locationID && new_device->in_reenumerate) {
usbi_dbg (ctx, "found cached device with matching location that is being re-enumerated");
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 3a55cda..b4ca6bb 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11869
+#define LIBUSB_NANO 11870