From nobody Thu Apr 04 11:38:47 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V9KPz49lyz5GrPj; Thu, 4 Apr 2024 11:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V9KPz3MGxz5776; Thu, 4 Apr 2024 11:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712230727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7Bloqm3Uj41KAYjyWY/to5WP7tKkDTV4DhGq1gswuXU=; b=mzQFAgdC/Lx81pcYT2xD2HbJFwus55KVwyiAalcXg1dUQ4ClRhFt0ofJySlJ8crIWv0Ytw r+6YtyffiQkV7sA4UfqVF7yFYAmaCjTW424qTRxwo/O+7MUbJpNPScuD0w/xwlm6kZukv/ 1i/dH2UdpQZnrMRdk9wzcSbbraT8VoxxVWNCl/+mInxmGcxGSMmgCDaZn7nISnrKtBanR5 whPWGho4midCH+lOkADK6FPKtHKSMey7nSzwTm+Ren7lXdDkYoeIRREuIegjrdcWXMrBNb i6eiMw8gEAwyHo99KHbu/ysS2BKz67R420FPbTuKgq6VmgX8/Y+3Ewl/1osC4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712230727; a=rsa-sha256; cv=none; b=nx/lmY0UVCRj+xZKvUQhJ0nThXAgZgN9oaWKpgROuBhsaL7X+6YQU4lCHzHCYBsskgpC++ E6YickJ8SaPWCXoyT3BXUMuBuXMVXmwSHf+np+JkP6qTEIBA/g/2nrnfNutw/IxsJCmXap FsP38ZDCLWe+AvLT/1+DFCI4oJB04aFaTH+QhTI3SCJHtooenioS55qPVVKHE36m33URj5 kEdzY2soHAM949FRv7jfKpwk5rI9PauKNEH17ChZX4SqESND0NaOtj6i7XJhEkZkZTuthB 22KO5nnUy1hkUdIt/6WRS+UtgSCf66Ojm1jIiogMZsh4t8Ur416qFtnAjJkB+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712230727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7Bloqm3Uj41KAYjyWY/to5WP7tKkDTV4DhGq1gswuXU=; b=FBpQhqUNMKGhItOqnLxVC3Lg9Yz/X10iVzbsHMXlG+CN6yddjp+/hpUKLK/cQfCrvJokio S/oEaMR2Y09nH3W2icpLsbKmCkXymjcoXTPVsRaJbP9iw3VWA117ZzaAEH/El3ZzhyX7pa vfQ/cpSOHJQ1gI8rxRLfimod/s7CEEwBxONCIvezC+hFSw3ntwux9Cs/A7CgI9SiGTzb4w kadT8kguN8wtXMe3+Yp3B6E5kLFtmMj0p5P+BPGfW5WC0RhgHpWgX2xKP6xlvueiVBrITu I0pDy4+oW+Ootu8DCb1oq1LKto79pT/ygPY+4IwHwoCXyegn77aXW0Gi+xhw/w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4V9KPz2yG2zFVY; Thu, 4 Apr 2024 11:38:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 434BclEu059652; Thu, 4 Apr 2024 11:38:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 434BclUj059649; Thu, 4 Apr 2024 11:38:47 GMT (envelope-from git) Date: Thu, 4 Apr 2024 11:38:47 GMT Message-Id: <202404041138.434BclUj059649@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: fdde01c5b449 - stable/14 - libc: Improve description of mktime() / timegm(). List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: fdde01c5b44904e34ff3b003f446644de865fa21 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=fdde01c5b44904e34ff3b003f446644de865fa21 commit fdde01c5b44904e34ff3b003f446644de865fa21 Author: Dag-Erling Smørgrav AuthorDate: 2024-03-27 10:03:37 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-04-04 09:41:41 +0000 libc: Improve description of mktime() / timegm(). * Mention that mktime() and timegm() set errno on failure. * Correctly determining whether mktime() / timegm() succeeded with arbitrary input (where -1 can be a valid result) is non-trivial. Document the recommended procedure. PR: 277863 MFC after: 1 week Reviewed by: pauamma_gundo.com, gbe Differential Revision: https://reviews.freebsd.org/D44503 (cherry picked from commit 7534109d13a6cdb22e78d9d4c0a0cd5efd323c45) --- lib/libc/stdtime/ctime.3 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3 index 25a7c6a7656e..7216ada23826 100644 --- a/lib/libc/stdtime/ctime.3 +++ b/lib/libc/stdtime/ctime.3 @@ -29,7 +29,7 @@ .\" .\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93 .\" -.Dd April 20, 2023 +.Dd March 26, 2024 .Dt CTIME 3 .Os .Sh NAME @@ -243,7 +243,21 @@ The .Fn mktime function returns the specified calendar time; if the calendar time cannot be -represented, it returns \-1; +represented, it returns \-1 and sets +.Xr errno 3 +to an appropriate value. +.Pp +Note that \-1 is a valid result (representing one second before +midnight UTC on the evening of 31 December 1969), so this cannot be +relied upon to indicate success or failure; instead, +.Fa tm_wday +and / or +.Fa tm_yday +should be set to an out-of-bounds value (e.g. \-1) prior to calling +.Fn mktime +or +.Fn timegm +and checked after the call. .Pp The .Fn difftime