Skip to content

Commit b642f54

Browse files
authored
Merge pull request apple#175 from glessard/32-are-too-few-bits
fix a 32-bit overflow issue
2 parents 36987d6 + 25c4b1a commit b642f54

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/System/MachPort.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ public enum Mach {
5656
self._name = name
5757

5858
if RightType.self == ReceiveRight.self {
59-
precondition(name != 0xFFFFFFFF /* MACH_PORT_DEAD */,
60-
"Receive rights cannot be dead names")
59+
precondition(
60+
_name != (0xFFFFFFFF as mach_port_name_t) /* MACH_PORT_DEAD */,
61+
"Receive rights cannot be dead names"
62+
)
6163

6264
let secret = mach_port_context_t(arc4random())
6365
_machPrecondition(mach_port_guard(mach_task_self_, name, secret, 0))
@@ -87,8 +89,10 @@ public enum Mach {
8789

8890
deinit {
8991
if RightType.self == ReceiveRight.self {
90-
precondition(_name != 0xFFFFFFFF /* MACH_PORT_DEAD */,
91-
"Receive rights cannot be dead names")
92+
precondition(
93+
_name != (0xFFFFFFFF as mach_port_name_t) /* MACH_PORT_DEAD */,
94+
"Receive rights cannot be dead names"
95+
)
9296
_machPrecondition(
9397
mach_port_destruct(mach_task_self_, _name, 0, _context)
9498
)

0 commit comments

Comments
 (0)