From patchwork Wed Apr 15 20:59:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 133149 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 2A15E4BA2E2B for ; Wed, 15 Apr 2026 20:59:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A15E4BA2E2B X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 49D6F4BA543C for ; Wed, 15 Apr 2026 20:59:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49D6F4BA543C 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 49D6F4BA543C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776286749; cv=none; b=AXBWuFPpS8ehlOeE/B+5KlP1jyLE1jKaZF25J60PehT0uIm0omCk4rFK38qVuYKHLkODxgQI5TRuy5jKSLhASOLTsQNq0D77GUetP4IhwgzkVYvX0CxRoNgdMfWKrvpfx4SDUwKXalpZ8H8ZU47OA4jDnj6v8G52lQUVPUHhiyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776286749; c=relaxed/simple; bh=hM/1qyYVkg+Sxci98ZqZZJHoCrZ+Mxs4a649KqDTGP4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=oX4SfNWsJD6nWrMTTv5skYLVx3xlMmIK3S5dmHRHf4Fh4X54v98a0KklVt97kThy6kn2VxRQqJecWKEFFtvG6PWzkEFRCyE+cGGzqIePHF7Rmvl6kZXM0gvJvvY849IyiEB7Z26A8WW1iWKOsicrIztrAAGXUU1sY8l+vm+FV7E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49D6F4BA543C Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 4A84FA0230; Wed, 15 Apr 2026 22:59:07 +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 SSyGCPf8AT11; Wed, 15 Apr 2026 22:59:07 +0200 (CEST) Received: from end (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (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 93AB3A022F; Wed, 15 Apr 2026 22:59:06 +0200 (CEST) Received: from samy by end with local (Exim 4.99.1) (envelope-from ) id 1wD7KE-00000005HEx-0awS; Wed, 15 Apr 2026 22:59:06 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Michael Kelly , commit-hurd@gnu.org Subject: [hurd, commited 2/3] hurd: __adjtime(): struct timeval and time_value_t are not identical. Date: Wed, 15 Apr 2026 22:59:04 +0200 Message-ID: <20260415205905.1257892-3-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260415205905.1257892-1-samuel.thibault@ens-lyon.org> References: <20260415205905.1257892-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: Michael Kelly 'struct timeval' and 'struct time_value' have different types for the microseconds component: int and long int. Casting one to the other leads to negative numbers not being preserved properly within the called code. Message-ID: <20260415180318.109742-3-mike@weatherwax.co.uk> --- sysdeps/mach/hurd/adjtime.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sysdeps/mach/hurd/adjtime.c b/sysdeps/mach/hurd/adjtime.c index 915b86da13..9d01533b23 100644 --- a/sysdeps/mach/hurd/adjtime.c +++ b/sysdeps/mach/hurd/adjtime.c @@ -28,31 +28,36 @@ __adjtime (const struct timeval *delta, struct timeval *olddelta) { error_t err; mach_port_t hostpriv; - struct timeval dummy; + time_value_t rpc_delta, rpc_olddelta; err = __get_privileged_ports (&hostpriv, NULL); if (err) return __hurd_fail (EPERM); - if (olddelta == NULL) - olddelta = &dummy; - if (delta != NULL) { if (delta->tv_usec >= TIME_MICROS_MAX || delta->tv_usec <= -TIME_MICROS_MAX) return EINVAL; + + rpc_delta.seconds = delta->tv_sec; + rpc_delta.microseconds = delta->tv_usec; } + else + return EINVAL; - err = __host_adjust_time (hostpriv, - /* `time_value_t' and `struct timeval' are in - fact identical with the names changed. */ - *(time_value_t *) delta, - (time_value_t *) olddelta); + err = __host_adjust_time (hostpriv, rpc_delta, &rpc_olddelta); __mach_port_deallocate (__mach_task_self (), hostpriv); if (err) return __hurd_fail (err); + + if (olddelta != NULL) + { + olddelta->tv_sec = rpc_olddelta.seconds; + olddelta->tv_usec = rpc_olddelta.microseconds; + } + return 0; }