[Tarantool-patches] [PATCH luajit 2/2] Make check in os.time() consistent.

Sergey Bronnikov sergeyb at tarantool.org
Tue Jun 30 17:20:35 MSK 2026


Hi, Evgeniy!

Thanks for the patch! LGTM

Sergey

On 6/29/26 20:21, Evgeniy Temirgaleev wrote:
> From: Mike Pall <mike>
>
> Thanks to Temir Galeev. #1470
>
> (cherry picked from commit 295d45fb26de56498782c94594f31b97aef744ef)
>
> This patch prevents os.time() to return nil, when machine time is -1
> and some error occurs before os.time() call. In fact, this is
> a theoretical case, so no tests were added.
>
> Temir Galeev:
> * added the description for the patch
>
> Part of tarantool/tarantool#12480
> ---
>   src/lib_os.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib_os.c b/src/lib_os.c
> index f6841357..d4054eae 100644
> --- a/src/lib_os.c
> +++ b/src/lib_os.c
> @@ -229,6 +229,7 @@ LJLIB_CF(os_date)
>   LJLIB_CF(os_time)
>   {
>     time_t t;
> +  errno = 0;
>     if (lua_isnoneornil(L, 1)) {  /* called without args? */
>       t = time(NULL);  /* get current time */
>     } else {
> @@ -242,7 +243,6 @@ LJLIB_CF(os_time)
>       ts.tm_mon = getfield(L, "month", -1) - 1;
>       ts.tm_year = getfield(L, "year", -1) - 1900;
>       ts.tm_isdst = getboolfield(L, "isdst");
> -    errno = 0;
>       t = mktime(&ts);
>     }
>     if (t == (time_t)(-1) && errno != 0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20260630/ef6b30d5/attachment.htm>


More information about the Tarantool-patches mailing list