diff options
author | Sean McBride <sean@rogue-research.com> | 2023-12-29 19:09:32 -0500 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2024-01-19 21:53:46 +0100 |
commit | b4f877f6f406913dbe5ee00159b9ebfbb589de12 (patch) | |
tree | 38196ca42f9c7ed96d69b26b619184e9db69785e | |
parent | 5e4b389f74d5201396af827a6647303b65bafaef (diff) | |
download | libusb-b4f877f6f406913dbe5ee00159b9ebfbb589de12.tar.gz |
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>
-rw-r--r-- | libusb/os/darwin_usb.c | 12 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 7 insertions, 7 deletions
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 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { 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 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { 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 @@ static void darwin_devices_detached (void *ptr, io_iterator_t rem_devices) { 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 @@ static enum libusb_error darwin_get_cached_device(struct libusb_context *ctx, io 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 |