aboutsummaryrefslogtreecommitdiff
path: root/hurd/vpprintf.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/vpprintf.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/vpprintf.c')
-rw-r--r--hurd/vpprintf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hurd/vpprintf.c b/hurd/vpprintf.c
index fe73494..010f04c 100644
--- a/hurd/vpprintf.c
+++ b/hurd/vpprintf.c
@@ -25,8 +25,9 @@
static ssize_t
do_write (void *cookie, const char *buf, size_t n)
{
+ io_t io = (io_t) (uintptr_t) cookie;
vm_size_t amount = n;
- error_t error = __io_write ((io_t) cookie, buf, n, -1, &amount);
+ error_t error = __io_write (io, buf, n, -1, &amount);
if (error)
return __hurd_fail (error);
return n;
@@ -51,7 +52,8 @@ vpprintf (io_t port, const char *format, va_list arg)
#endif
_IO_cookie_init (&temp_f.cfile, _IO_NO_READS,
- (void *) port, (cookie_io_functions_t) { write: do_write });
+ (void *) (uintptr_t) port,
+ (cookie_io_functions_t) { write: do_write });
done = __vfprintf_internal (&temp_f.cfile.__fp.file, format, arg, 0);