From 25c4b1ad75f842680346035ea42ccabf46fccd2e Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Sun, 12 May 2024 14:07:11 -0700 Subject: [PATCH] fix a 32-bit overflow issue - ensures compatibility with watchOS --- Sources/System/MachPort.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/System/MachPort.swift b/Sources/System/MachPort.swift index b3eb0a99..62b5547a 100644 --- a/Sources/System/MachPort.swift +++ b/Sources/System/MachPort.swift @@ -56,8 +56,10 @@ public enum Mach { self._name = name if RightType.self == ReceiveRight.self { - precondition(name != 0xFFFFFFFF /* MACH_PORT_DEAD */, - "Receive rights cannot be dead names") + precondition( + _name != (0xFFFFFFFF as mach_port_name_t) /* MACH_PORT_DEAD */, + "Receive rights cannot be dead names" + ) let secret = mach_port_context_t(arc4random()) _machPrecondition(mach_port_guard(mach_task_self_, name, secret, 0)) @@ -87,8 +89,10 @@ public enum Mach { deinit { if RightType.self == ReceiveRight.self { - precondition(_name != 0xFFFFFFFF /* MACH_PORT_DEAD */, - "Receive rights cannot be dead names") + precondition( + _name != (0xFFFFFFFF as mach_port_name_t) /* MACH_PORT_DEAD */, + "Receive rights cannot be dead names" + ) _machPrecondition( mach_port_destruct(mach_task_self_, _name, 0, _context) )