This patch fixes a warning when building on 64-bit architectures where
sizeof(void *) > sizeof(mach_port_name_t).
The double cast (via uintptr_t) explicitly tells the compiler that the
truncation of the pointer value into the 32-bit port name is intentional,
preserving the existing behavior while silencing the warning.
---
ipc/ipc_port.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ipc/ipc_port.c b/ipc/ipc_port.c
index e959f67..884a4f4 100644
--- a/ipc/ipc_port.c
+++ b/ipc/ipc_port.c
@@ -35,6 +35,7 @@
*/
#include <kern/printf.h>
+#include <stdint.h>
#include <string.h>
#include <mach/port.h>
@@ -1177,6 +1178,7 @@ ipc_port_t
ipc_port_alloc_special(ipc_space_t space)
{
ipc_port_t port;
+ mach_port_name_t name;
port = ip_alloc();
if (port == IP_NULL)
@@ -1197,7 +1199,8 @@ ipc_port_alloc_special(ipc_space_t space)
* the fast rpc path).
*/
- ipc_port_init(port, space, (mach_port_name_t)port);
+ name = (mach_port_name_t)(uintptr_t) port;
+ ipc_port_init(port, space, name);
return port;
}
--
2.52.0