From 8d7616886e062f58d0de12db2acd5d81e06240bb Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Thu, 28 Oct 2021 10:36:30 -0600 Subject: [PATCH] darwin: fix deprecation warning about kIOMasterPortDefault The kIOMasterPortDefault constant has been replaced by kIOMainPortDefault. Both are synonmys for 0. To avoid extra checks on the target macOS release just go ahead and use 0. Signed-off-by: Nathan Hjelm --- libusb/os/darwin_usb.c | 11 +++++++---- libusb/version_nano.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 007ffd1..485eb43 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -54,6 +54,9 @@ static int init_count = 0; +/* Both kIOMasterPortDefault or kIOMainPortDefault are synonyms for 0. */ +static const mach_port_t darwin_default_master_port = 0; + /* async event thread */ static pthread_mutex_t libusb_darwin_at_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t libusb_darwin_at_cond = PTHREAD_COND_INITIALIZER; @@ -254,7 +257,7 @@ static IOReturn usb_setup_device_iterator (io_iterator_t *deviceIterator, UInt32 CFRelease (locationCF); } - return IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, deviceIterator); + return IOServiceGetMatchingServices(darwin_default_master_port, matchingDict, deviceIterator); } /* Returns 1 on success, 0 on failure. */ @@ -442,7 +445,7 @@ static void darwin_hotplug_poll (void) /* since a kernel thread may notify the IOIterators used for * hotplug notification we can't just clear the iterators. * instead just wait until all IOService providers are quiet */ - (void) IOKitWaitQuiet (kIOMasterPortDefault, &timeout); + (void) IOKitWaitQuiet (darwin_default_master_port, &timeout); } static void darwin_clear_iterator (io_iterator_t iter) { @@ -502,7 +505,7 @@ static void *darwin_event_thread_main (void *arg0) { CFRunLoopAddSource(runloop, libusb_shutdown_cfsource, kCFRunLoopDefaultMode); /* add the notification port to the run loop */ - libusb_notification_port = IONotificationPortCreate (kIOMasterPortDefault); + libusb_notification_port = IONotificationPortCreate (darwin_default_master_port); libusb_notification_cfsource = IONotificationPortGetRunLoopSource (libusb_notification_port); CFRunLoopAddSource(runloop, libusb_notification_cfsource, kCFRunLoopDefaultMode); @@ -1839,7 +1842,7 @@ static io_service_t usb_find_interface_matching_location (const io_name_t class_ CFRelease (locationCF); CFRelease (propertyMatchDict); - return IOServiceGetMatchingService (kIOMasterPortDefault, matchingDict); + return IOServiceGetMatchingService (darwin_default_master_port, matchingDict); } static int darwin_kernel_driver_active(struct libusb_device_handle *dev_handle, uint8_t interface) { diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 08f69c6..5046b32 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11657 +#define LIBUSB_NANO 11658 -- 2.7.4