Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Evgeniy Temirgaleev <e.temirgaleev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Fix corner case of os.time().
Date: Tue, 30 Jun 2026 13:05:25 +0300	[thread overview]
Message-ID: <akOU5W-Fe1_7v2jj@root> (raw)
In-Reply-To: <dc0883ff18fbb518821e577527c9ed070dcc34de.1782588899.git.e.temirgaleev@tarantool.org>

Hi, Evgeniy!
Thanks for the patch!
LGTM, with minor nits below.

On 29.06.26, Evgeniy Temirgaleev wrote:
> From: Mike Pall <mike>
> 
> Thanks to Temir Galeev. #1470

Please strip the issue number to avoid overmentioning the ticket on
GitHub. (The Issue can be easily found by the cherry-picked commit,
though). This helps to avoid overmentioning during the review and
applying the patch to long-term branches.

> 
> (cherry picked from commit 72d2061ae2fa9a5fd45237943f9982baf59435ec)
> 
> This patch fixes invalid os.time(t) behavior, when it handles -1 time value

Typo: s/, when/ when/
Typo: s/-1/the -1/

> as a fail of the libc mktime() regardless of the errno value.
> 
> Temir Galeev:
> * added the description and the test for the patch
> 
> Part of tarantool/tarantool#12480
> ---
>  src/lib_os.c                                         |  3 ++-
>  .../lj-1470-os-time-epoch-minus-1s.test.lua          | 12 ++++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
>  create mode 100644 test/tarantool-tests/lj-1470-os-time-epoch-minus-1s.test.lua
> 
> diff --git a/src/lib_os.c b/src/lib_os.c
> index ffbc3fdc..f6841357 100644
> --- a/src/lib_os.c
> +++ b/src/lib_os.c
> @@ -242,9 +242,10 @@ 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))
> +  if (t == (time_t)(-1) && errno != 0)
>      lua_pushnil(L);
>    else
>      lua_pushnumber(L, (lua_Number)t);
> diff --git a/test/tarantool-tests/lj-1470-os-time-epoch-minus-1s.test.lua b/test/tarantool-tests/lj-1470-os-time-epoch-minus-1s.test.lua
> new file mode 100644
> index 00000000..6b5703e4
> --- /dev/null
> +++ b/test/tarantool-tests/lj-1470-os-time-epoch-minus-1s.test.lua
> @@ -0,0 +1,12 @@
> +local tap = require('tap')
> +
> +-- The test file demonstrates os.time() fail to return -1 time value.

Side note: It looks like the patch is outdated compared to the branch.

> +-- See also: https://github.com/LuaJIT/LuaJIT/issues/1470.
> +local test = tap.test('lj-1470-os-time-epoch-minus-1s')
> +
> +test:plan(1)
> +
> +local minus_1s_time = os.date("*t", -1)

Nit: We use everywhere in Lua code single quotes if possible (see other
tests).

> +test:is(os.time(minus_1s_time), -1, 'correct os.time()')
> +
> +test:done(true)
> -- 
> 2.49.0
> 

-- 
Best regards,
Sergey Kaplun

  reply	other threads:[~2026-06-30 10:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 17:16 [Tarantool-patches] [PATCH luajit 0/2] Fix os.time() to use errno to detect errors Evgeniy Temirgaleev via Tarantool-patches
2026-06-29 17:21 ` [Tarantool-patches] [PATCH luajit 1/2] Fix corner case of os.time() Evgeniy Temirgaleev via Tarantool-patches
2026-06-30 10:05   ` Sergey Kaplun via Tarantool-patches [this message]
2026-06-30 13:53     ` Evgeniy Temirgaleev via Tarantool-patches
2026-06-30 14:18   ` Sergey Bronnikov via Tarantool-patches
2026-06-29 17:21 ` [Tarantool-patches] [PATCH luajit 2/2] Make check in os.time() consistent Evgeniy Temirgaleev via Tarantool-patches
2026-06-30 10:08   ` Sergey Kaplun via Tarantool-patches
2026-06-30 13:57     ` Evgeniy Temirgaleev via Tarantool-patches
2026-06-30 14:20   ` Sergey Bronnikov via Tarantool-patches
2026-06-30 14:55 ` [Tarantool-patches] [PATCH luajit 0/2] Fix os.time() to use errno to detect errors Sergey Kaplun via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=akOU5W-Fe1_7v2jj@root \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=e.temirgaleev@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 1/2] Fix corner case of os.time().' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox