aboutsummaryrefslogtreecommitdiff
path: root/hurd/port-cleanup.c
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-02-12 14:10:34 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-12 15:55:04 +0100
commit62d6c3303089d9c708527ab7bf98348a6429e8c3 (patch)
tree73a5a9637c522d97df9281137cb26c44809e9167 /hurd/port-cleanup.c
parentf4315054b46d5e58b44a709a51943fb73f846afb (diff)
downloadglibc-62d6c3303089d9c708527ab7bf98348a6429e8c3.zip
glibc-62d6c3303089d9c708527ab7bf98348a6429e8c3.tar.gz
glibc-62d6c3303089d9c708527ab7bf98348a6429e8c3.tar.bz2
mach, hurd: Cast through uintptr_t
When casting between a pointer and an integer of a different size, GCC emits a warning (which is escalated to a build failure by -Werror). Indeed, if what you start with is a pointer, which you then cast to a shorter integer and then back again, you're going to cut off some bits of the pointer. But if you start with an integer (such as mach_port_t), then cast it to a longer pointer (void *), and then back to a shorter integer, you are fine. To keep GCC happy, cast through an intermediary uintptr_t, which is always the same size as a pointer. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230212111044.610942-4-bugaevc@gmail.com>
Diffstat (limited to 'hurd/port-cleanup.c')
-rw-r--r--hurd/port-cleanup.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/hurd/port-cleanup.c b/hurd/port-cleanup.c
index 08ab3d4..ad43b83 100644
--- a/hurd/port-cleanup.c
+++ b/hurd/port-cleanup.c
@@ -26,7 +26,8 @@
void
_hurd_port_cleanup (void *cleanup_data, jmp_buf env, int val)
{
- __mach_port_deallocate (__mach_task_self (), (mach_port_t) cleanup_data);
+ mach_port_t port = (mach_port_t) (uintptr_t) cleanup_data;
+ __mach_port_deallocate (__mach_task_self (), port);
}
/* We were cancelled while using a port, and called from the cleanup unwinding.