Skip to content

Commit

Permalink
IOKit: Silence some compiler warnings about unused variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Nov 17, 2023
1 parent 1535d99 commit d15e347
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/libirecovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,15 @@ static int _irecv_is_recovery_device(void *device)
kern_return_t kr;
IOUSBDeviceInterface **dev = device;
kr = (*dev)->GetDeviceVendor(dev, &vendor_id);
if (kr != kIOReturnSuccess) {
debug("%s: Failed to get vendor id\n", __func__);
return 0;
}
kr = (*dev)->GetDeviceProduct(dev, &product_id);
if (kr != kIOReturnSuccess) {
debug("%s: Failed to get product id\n", __func__);
return 0;
}
#else
libusb_device *device_ = (libusb_device*)device;
struct libusb_device_descriptor devdesc;
Expand Down Expand Up @@ -2507,21 +2515,21 @@ static void iokit_device_added(void *refcon, io_iterator_t iterator)
kr = IOCreatePlugInInterfaceForService(device, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score);
if ((kIOReturnSuccess != kr) || !plugInInterface) {
debug("%s: ERROR: Unable to create a plug-in (%08x)\n", __func__, kr);
kr = IOObjectRelease(device);
IOObjectRelease(device);
continue;
}
result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID320), (LPVOID *)&dev);
(*plugInInterface)->Release(plugInInterface);

if (result || !dev) {
debug("%s: ERROR: Couldn't create a device interface (%08x)\n", __func__, (int)result);
kr = IOObjectRelease(device);
IOObjectRelease(device);
continue;
}

if (!_irecv_is_recovery_device(dev)) {
(void) (*dev)->Release(dev);
kr = IOObjectRelease(device);
IOObjectRelease(device);
continue;
}

Expand All @@ -2530,7 +2538,7 @@ static void iokit_device_added(void *refcon, io_iterator_t iterator)
idev.dev = dev;
_irecv_handle_device_add(&idev);
(void) (*dev)->Release(dev);
kr = IOObjectRelease(device);
IOObjectRelease(device);
}
}

Expand Down Expand Up @@ -2719,10 +2727,16 @@ static void *_irecv_event_handler(void* data)

io_iterator_t devAddedIter;
kr = IOServiceAddMatchingNotification(notifyPort, kIOFirstMatchNotification, matchingDict, iokit_device_added, NULL, &devAddedIter);
if (kr != kIOReturnSuccess) {
debug("%s: Failed to register device add notification callback\n", __func__);
}
iokit_device_added(NULL, devAddedIter);

io_iterator_t devRemovedIter;
kr = IOServiceAddMatchingNotification(notifyPort, kIOTerminatedNotification, matchingDict, iokit_device_removed, NULL, &devRemovedIter);
if (kr != kIOReturnSuccess) {
debug("%s: Failed to register device remove notification callback\n", __func__);
}
iokit_device_removed(NULL, devRemovedIter);

i++;
Expand Down

0 comments on commit d15e347

Please sign in to comment.