darwin: fix deprecation warning about kIOMasterPortDefault
authorNathan Hjelm <hjelmn@me.com>
Thu, 28 Oct 2021 16:36:30 +0000 (10:36 -0600)
committerNathan Hjelm <hjelmn@me.com>
Thu, 28 Oct 2021 16:36:30 +0000 (10:36 -0600)
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 <hjelmn@google.com>
libusb/os/darwin_usb.c
libusb/version_nano.h

index 007ffd1..485eb43 100644 (file)
@@ -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) {
index 08f69c6..5046b32 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11657
+#define LIBUSB_NANO 11658