[PATCH] Ensure mktime sets errno on error (bug 23789)
Zack Weinberg
zackw@panix.com
Thu Oct 25 00:09:00 GMT 2018
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`?
zw
More information about the Libc-alpha
mailing list