This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Ensure mktime sets errno on error (bug 23789)
Hi Zack,
On Wed, 24 Oct 2018 20:04:11 -0400, Zack Weinberg <zackw@panix.com>
wrote :
> On Wed, Oct 24, 2018 at 3:32 PM Albert ARIBAUD (3ADEV)
> <albert.aribaud@3adev.fr> wrote:
> >
> > Posix mandates that mktime set errno to EOVERFLOW
> > on error, that it, upon retuning -1, but the glibc
> > mktime does not so far on 32-bit architectures.
> ...
> > # if defined _LIBC || NEED_MKTIME_WORKING
> > static mktime_offset_t localtime_offset;
> > - return __mktime_internal (tp, __localtime_r, &localtime_offset);
> > + result = __mktime_internal (tp, __localtime_r, &localtime_offset);
> > # else
> > # undef mktime
> > - return mktime (tp);
> > + result = mktime (tp);
> > # endif
> > + if (result == -1)
> > + {
> > + __set_errno(EOVERFLOW);
> > + }
> > + return result;
>
> Why do you make this change in the `mktime` wrapper instead of
> `__mktime_internal`?
The change is about errno, which is part of the public interface, so I
considered it was more logical to put it in the wrapper which
implements the public interface than in an internal function.
> zw
Cordialement,
Albert ARIBAUD
3ADEV