Re: [PATCH] selftests/timens: print and parse time_t as long long

From: Andrei Vagin

Date: Mon Nov 30 2026 - 21:54:41 EST


On Tue, Nov 3, 2026 at 6:12 AM Sasha Levin <sashal@xxxxxxxxxx> wrote:
>
> Several timens tests pass time_t values to printf-style functions with
> %ld or %lu, exec.c reads one with sscanf("%ld"), and exec.c and
> vfork_exec.c take the absolute value of a time_t difference with
> labs(). On 32-bit architectures where the C library uses a 64-bit
> time_t, such as armhf in Debian 13, time_t is a long long and every
> timens test fails to build with -Werror:
>
> timens.h:72:48: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'time_t' {aka 'long long int'} [-Werror=format=]
>
> Clang also rejects the labs() calls with -Wabsolute-value.
>
> Cast the values to long long and print them with %lld, parse the exec
> argument into a long long, and use llabs() as timer.c and timerfd.c
> already do.
>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
Acked-by: Andrei Vagin <avagin@xxxxxxxxxx>

Thanks,
Andrei