[LTP] [PATCH] syscalls/time01:Avoid using TST_RET in time() test to support Y2038-safe time_t
Petr Vorel
pvorel@suse.cz
Fri Nov 7 13:19:35 CET 2025
Hi Jiaying,
> On 32-bit systems with Y2038 support, time_t is 64-bit while TST_RET
> remains a long (usually 32-bit).Using TST_RET to store the return value
> of time() causes overflow after 2038, leading to incorrect comparisons
> and false test failures like:
> TFAIL: time() returned value -2085977741, stored value 2208989555 are different
> This patch replaces usage of TST_RET with a local variable of type
> time_t (ret_time), ensuring correct behavior with large timestamps and
> avoiding truncation.
+1
...
> +++ b/testcases/kernel/syscalls/time/time01.c
> @@ -23,24 +23,23 @@ static time_t *targs[] = {
> static void verify_time(unsigned int i)
> {
> time_t *tloc = targs[i];
> + time_t ret_time = time(tloc);
> - TEST(time(tloc));
nit: wrong whitespace indent (can be fixed before merge).
Fixed that and merged.
Thanks!
Kind regards,
Petr
More information about the ltp
mailing list