This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Ensure mktime sets errno on error (bug 23789)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: "Albert ARIBAUD (3ADEV)" <albert dot aribaud at 3adev dot fr>
- Cc: <libc-alpha at sourceware dot org>
- Date: Mon, 29 Oct 2018 15:15:40 +0000
- Subject: Re: [PATCH v2] Ensure mktime sets errno on error (bug 23789)
- References: <20181028225206.4568-1-albert.aribaud@3adev.fr>
On Sun, 28 Oct 2018, Albert ARIBAUD (3ADEV) wrote:
> +#define TEST_FUNCTION do_test ()
> +#include "../test-skeleton.c"
New tests should use <support/test-driver.c>, not the old test-skeleton.
> + if (result == -1 && errno == 0)
> + return result;
It is never OK for a library function to set errno to 0 (return with errno
set to 0 when it wasn't 0 on entry); if there is no error you can restore
the value that was set on entry to mktime, or set errno to some spurious
other value despite the lack of an error (maybe not a good idea in this
case, because it prevents callers from distinguishing error and non-error
-1), but not set it to 0 if it wasn't 0 on entry to the library function.
(See ISO C: "The value of errno in the initial thread is zero at program
startup (the initial value of errno in other threads is an indeterminate
value), but is never set to zero by any library function.".)
> + __set_errno(errno_from_tzset);
Missing space before '(', here and elsewhere in this patch.
--
Joseph S. Myers
joseph@codesourcery.com