From patchwork Sun Aug 28 23:51:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 57124 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBE883860002 for ; Sun, 28 Aug 2022 23:51:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id CFF8A3858418 for ; Sun, 28 Aug 2022 23:51:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CFF8A3858418 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id D6B0920160; Mon, 29 Aug 2022 01:51:16 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wEyrBiXngGPr; Mon, 29 Aug 2022 01:51:16 +0200 (CEST) Received: from begin (lfbn-bor-1-376-208.w109-215.abo.wanadoo.fr [109.215.91.208]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id C30172015B; Mon, 29 Aug 2022 01:51:16 +0200 (CEST) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1oSS3g-004imu-0i; Mon, 29 Aug 2022 01:51:16 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] hurd: Fix vm_size_t incoherencies Date: Mon, 29 Aug 2022 01:51:16 +0200 Message-Id: <20220828235116.1125469-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" In gnumach, 3e1702a65fb3 ("add rpc_versions for vm types") changed the type of vm_size_t, making it always a unsigned long. This made it incompatible on x86 with size_t. Even if we may want to revert it to unsigned int, it's better to fix the types of parameters according to the .defs files. --- hurd/fd-write.c | 2 +- hurd/fopenport.c | 2 +- hurd/get-host.c | 3 ++- hurd/hurdioctl.c | 2 +- hurd/set-host.c | 2 +- hurd/vpprintf.c | 4 ++-- sysdeps/mach/hurd/dl-sysdep.c | 4 ++-- sysdeps/mach/hurd/ptrace.c | 5 ++++- sysdeps/mach/hurd/send.c | 2 +- sysdeps/mach/hurd/sendfile64.c | 2 +- sysdeps/mach/hurd/sendmsg.c | 2 +- sysdeps/mach/hurd/sendto.c | 2 +- 12 files changed, 18 insertions(+), 14 deletions(-) diff --git a/hurd/fd-write.c b/hurd/fd-write.c index a18e76b4d2..28be1ba758 100644 --- a/hurd/fd-write.c +++ b/hurd/fd-write.c @@ -26,7 +26,7 @@ _hurd_fd_write (struct hurd_fd *fd, const void *buf, size_t *nbytes, loff_t offset) { error_t err; - mach_msg_type_number_t wrote; + vm_size_t wrote; error_t writefd (io_t port) { diff --git a/hurd/fopenport.c b/hurd/fopenport.c index 293c902ae3..5bc01fcd7e 100644 --- a/hurd/fopenport.c +++ b/hurd/fopenport.c @@ -48,7 +48,7 @@ readio (void *cookie, char *buf, size_t n) static ssize_t writeio (void *cookie, const char *buf, size_t n) { - mach_msg_type_number_t wrote; + vm_size_t wrote; error_t err; if (err = __io_write ((io_t) cookie, buf, n, -1, &wrote)) diff --git a/hurd/get-host.c b/hurd/get-host.c index bdaf86bbf4..a21aa15008 100644 --- a/hurd/get-host.c +++ b/hurd/get-host.c @@ -27,7 +27,8 @@ _hurd_get_host_config (const char *item, char *buf, size_t buflen) { error_t err; char *data; - mach_msg_type_number_t nread, more; + mach_msg_type_number_t nread; + vm_size_t more; file_t config; err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport, 0, diff --git a/hurd/hurdioctl.c b/hurd/hurdioctl.c index fce487c12c..526a74aa4d 100644 --- a/hurd/hurdioctl.c +++ b/hurd/hurdioctl.c @@ -70,7 +70,7 @@ fioctl (int fd, case FIONREAD: { - mach_msg_type_number_t navail; + vm_size_t navail; err = HURD_DPORT_USE (fd, __io_readable (port, &navail)); if (!err) *arg = (int) navail; diff --git a/hurd/set-host.c b/hurd/set-host.c index 16d1d8deed..afa8f62b5d 100644 --- a/hurd/set-host.c +++ b/hurd/set-host.c @@ -24,7 +24,7 @@ ssize_t _hurd_set_host_config (const char *item, const char *value, size_t valuelen) { error_t err; - mach_msg_type_number_t nwrote; + vm_size_t nwrote; file_t new, dir; char *name; diff --git a/hurd/vpprintf.c b/hurd/vpprintf.c index 67450399f5..9ba39957d2 100644 --- a/hurd/vpprintf.c +++ b/hurd/vpprintf.c @@ -25,8 +25,8 @@ static ssize_t do_write (void *cookie, const char *buf, size_t n) { - error_t error = __io_write ((io_t) cookie, buf, n, -1, - (mach_msg_type_number_t *) &n); + vm_size_t amount = n; + error_t error = __io_write ((io_t) cookie, buf, n, -1, &amount); if (error) return __hurd_fail (error); return n; diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index f23fdee058..2f022ee90c 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -382,7 +382,7 @@ __ssize_t weak_function __write (int fd, const void *buf, size_t nbytes) { error_t err; - mach_msg_type_number_t nwrote; + vm_size_t nwrote; assert (fd < _hurd_init_dtablesize); @@ -415,7 +415,7 @@ __writev (int fd, const struct iovec *iov, int niov) { char buf[total], *bufp = buf; error_t err; - mach_msg_type_number_t nwrote; + vm_size_t nwrote; for (i = 0; i < niov; ++i) bufp = (memcpy (bufp, iov[i].iov_base, iov[i].iov_len) diff --git a/sysdeps/mach/hurd/ptrace.c b/sysdeps/mach/hurd/ptrace.c index 9a32cd9a60..a043f325c5 100644 --- a/sysdeps/mach/hurd/ptrace.c +++ b/sysdeps/mach/hurd/ptrace.c @@ -47,8 +47,11 @@ ptrace (enum __ptrace_request request, ... ) { /* Read the pages containing the addressed range. */ error_t err; + mach_msg_type_number_t nread; *size = round_page (addr + data) - trunc_page (addr); - err = __vm_read (task, trunc_page (addr), *size, ourpage, size); + err = __vm_read (task, trunc_page (addr), *size, ourpage, &nread); + if (!err) + *size = nread; return err; } diff --git a/sysdeps/mach/hurd/send.c b/sysdeps/mach/hurd/send.c index c0826f1d18..4df38e2b5f 100644 --- a/sysdeps/mach/hurd/send.c +++ b/sysdeps/mach/hurd/send.c @@ -27,7 +27,7 @@ ssize_t __send (int fd, const void *buf, size_t n, int flags) { error_t err; - size_t wrote; + vm_size_t wrote; int cancel_oldtype; cancel_oldtype = LIBC_CANCEL_ASYNC(); diff --git a/sysdeps/mach/hurd/sendfile64.c b/sysdeps/mach/hurd/sendfile64.c index 77c3a2fbf1..8b24f2169c 100644 --- a/sysdeps/mach/hurd/sendfile64.c +++ b/sysdeps/mach/hurd/sendfile64.c @@ -42,7 +42,7 @@ __sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t count) count)); if (err == 0) { - size_t nwrote; + vm_size_t nwrote; if (datalen == 0) return 0; err = HURD_DPORT_USE (out_fd, __io_write (port, data, datalen, diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c index 56bcee733f..5ca01fc1ad 100644 --- a/sysdeps/mach/hurd/sendmsg.c +++ b/sysdeps/mach/hurd/sendmsg.c @@ -47,7 +47,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags) } data = { .ptr = NULL }; char data_buf[2048]; mach_msg_type_number_t len; - mach_msg_type_number_t amount; + vm_size_t amount; int dealloc = 0; int socketrpc = 0; int i; diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c index e55469fea0..36a76bc043 100644 --- a/sysdeps/mach/hurd/sendto.c +++ b/sysdeps/mach/hurd/sendto.c @@ -37,7 +37,7 @@ __sendto (int fd, { addr_port_t aport = MACH_PORT_NULL; error_t err; - size_t wrote; + vm_size_t wrote; /* Get an address port for the desired destination address. */ error_t create_address_port (io_t port,