This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Ensure mktime sets errno on error (bug 23789)


Hi Zack,

On Thu, 25 Oct 2018 10:12:37 -0400, Zack Weinberg <zackw@panix.com>
wrote :

> On Thu, Oct 25, 2018 at 10:03 AM Albert ARIBAUD <albert.aribaud@3adev.fr> wrote:
> 
> > Hmm... Posix defines the value returned by mktime to be "Seconds since
> > the Epoch" thus: <http://pubs.opengroup.org/onlinepubs/9699919799/>.
> > According to this definition, a year below 1970 makes the corresponding
> > seconds since the epoch value undefined, so I wonder whether the struct
> > tm above is not outside the allowed limits for mktime().  
> 
> That may be true per the letter of POSIX, but there are enough
> programs that expect to be able to use negative time_t values to work
> with dates prior to 1970 that glibc needs to support this usage
> anyway.

I was afraid that would be the case. :)
IMO it warrants at least a comment to explain the divergence from
Posix, but apart from that, I can't see a way to keep __mktime_internal
really internal (i.e., not touch errno) without making the code more
complex than it should; so I will move the setting of errno in
__mktime_internal. This will cover the timegm case too.

I don't think I need to add a test for timegm(), though.

> zw

Cordialement,
Albert ARIBAUD
3ADEV


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]