From patchwork Thu Nov 12 14:25:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 41035 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 61085386EC2F; Thu, 12 Nov 2020 14:26:47 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id F3DBA3858034 for ; Thu, 12 Nov 2020 14:26:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F3DBA3858034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CX3nd0gXvz1s2Yr; Thu, 12 Nov 2020 15:26:45 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CX3nc6rH0z1qv5b; Thu, 12 Nov 2020 15:26:44 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 6if46eWFuyPi; Thu, 12 Nov 2020 15:26:43 +0100 (CET) X-Auth-Info: Mn+8EAoHOne+1/QumBVsHBLbaoMoWQ+31CrXaFY7Z/o= Received: from localhost.localdomain (89-64-5-98.dynamic.chello.pl [89.64.5.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 12 Nov 2020 15:26:43 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH] nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64 Date: Thu, 12 Nov 2020 15:25:42 +0100 Message-Id: <20201112142542.26057-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On ports with __TIMESIZE != 64 the remaining time argument always receives pointer to struct __timespec64 instance. This is the different behavior when compared to 64 bit versions of clock_nanosleep and nanosleep functions, which receive NULL. To avoid any potential issues, we also pass NULL when *rem pointer is NULL. Reported-by: Andreas Schwab Reviewed-by: Alistair Francis --- sysdeps/unix/sysv/linux/clock_nanosleep.c | 3 ++- sysdeps/unix/sysv/linux/nanosleep.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index 6ad3321435..82cd11a564 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -78,7 +78,8 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, struct __timespec64 treq64, trem64; treq64 = valid_timespec_to_timespec64 (*req); - r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64); + r = __clock_nanosleep_time64 (clock_id, flags, &treq64, + rem != NULL ? &trem64 : NULL); if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec64_to_timespec (trem64); diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c index 8f4ee0f744..e58815c4d0 100644 --- a/sysdeps/unix/sysv/linux/nanosleep.c +++ b/sysdeps/unix/sysv/linux/nanosleep.c @@ -39,7 +39,7 @@ __nanosleep (const struct timespec *req, struct timespec *rem) struct __timespec64 treq64, trem64; treq64 = valid_timespec_to_timespec64 (*req); - int ret = __nanosleep64 (&treq64, &trem64); + int ret = __nanosleep64 (&treq64, rem != NULL ? &trem64 : NULL); if (ret != 0 && errno == EINTR && rem != NULL) *rem = valid_timespec64_to_timespec (trem64);