From 323881f8a48c582df8789240e666cc23ad21bf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Fonseca?= Date: Mon, 28 Aug 2023 15:28:22 +0200 Subject: [PATCH] rename deprecated constant kIOMasterPortDefault This constant is now deprecated since macOS 12.0 and a new constant named kIOMainPortDefault is provided. There is a fallback in place that retains compatibility for older macOS versions. https://developer.apple.com/documentation/iokit/kiomasterportdefault [ gsi: tweak style to match existing code base ] --- libserialport_internal.h | 3 +++ macosx.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libserialport_internal.h b/libserialport_internal.h index ecf8fe9..f1d0d85 100644 --- a/libserialport_internal.h +++ b/libserialport_internal.h @@ -93,6 +93,9 @@ #include #include #include +#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 /* Before macOS 12 */ +#define kIOMainPortDefault kIOMasterPortDefault +#endif #endif #ifdef __linux__ #include diff --git a/macosx.c b/macosx.c index a0df84e..0d22bb6 100644 --- a/macosx.c +++ b/macosx.c @@ -42,7 +42,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port) if (!(classes = IOServiceMatching(kIOSerialBSDServiceValue))) RETURN_FAIL("IOServiceMatching() failed"); - if (IOServiceGetMatchingServices(kIOMasterPortDefault, classes, + if (IOServiceGetMatchingServices(kIOMainPortDefault, classes, &iter) != KERN_SUCCESS) RETURN_FAIL("IOServiceGetMatchingServices() failed"); @@ -210,7 +210,7 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list) } DEBUG("Getting matching services"); - if (IOServiceGetMatchingServices(kIOMasterPortDefault, classes, + if (IOServiceGetMatchingServices(kIOMainPortDefault, classes, &iter) != KERN_SUCCESS) { SET_FAIL(ret, "IOServiceGetMatchingServices() failed"); goto out_done;