git: 30cfb3c8ee3d - main - ctime.3: Add a note about a possible return value of localtime(3)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 16 Sep 2022 18:40:57 UTC
The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=30cfb3c8ee3d3fc79644541207c81d20c72176ce commit 30cfb3c8ee3d3fc79644541207c81d20c72176ce Author: Gordon Bergling <gbe@FreeBSD.org> AuthorDate: 2022-09-16 18:38:58 +0000 Commit: Gordon Bergling <gbe@FreeBSD.org> CommitDate: 2022-09-16 18:38:58 +0000 ctime.3: Add a note about a possible return value of localtime(3) The localtime(3) function returns a NULL pointer, if the passed in-time translates to a year that will not fit in an integer type. It is stricly recommended to check the return value to avoid garage output. Reported by: mckusick Reviewed by: mckusick, imp, rpokala MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D36515 --- contrib/tzcode/stdtime/ctime.3 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/tzcode/stdtime/ctime.3 b/contrib/tzcode/stdtime/ctime.3 index 771027fa62ec..de3a57bab59e 100644 --- a/contrib/tzcode/stdtime/ctime.3 +++ b/contrib/tzcode/stdtime/ctime.3 @@ -30,7 +30,7 @@ .\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 4, 2022 +.Dd September 16, 2022 .Dt CTIME 3 .Os .Sh NAME @@ -94,6 +94,10 @@ and returns a pointer to a (described below) which contains the broken-out time information for the value after adjusting for the current time zone (and any other factors such as Daylight Saving Time). +When the specified time translates to a year that will not fit in an +.Dv int , +.Fn localtime +returns NULL. Time zone adjustments are performed as specified by the .Ev TZ environment variable (see