selftests/seccomp: print tv_sec as long long
Subsystems (2)
PATCH 1/1 selftests/seccomp: print tv_sec as long long
On 32-bit architectures with a 64-bit time_t, such as armhf in Debian 13, tv_sec is a long long, and printing it with %lu warns:
seccomp_benchmark.c:43:27: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type '__time64_t' {aka 'long long int'} [-Wformat=]
Cast it to long long and print it with %lld. While at it, print tv_nsec, a long, with %ld instead of %lu, and cast it to long, as it is a long long on x32.
---
Found with a 32-bit build of the selftests with a 64-bit time_t (gcc 16 and clang 21 with -m32 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64); KernelCI's 32-bit arm builds show the same warnings. The changed files build without format warnings there now, and the x86_64 builds don't change. The other selftests get the same kind of fix in separate patches.
tools/testing/selftests/seccomp/seccomp_benchmark.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/seccomp/seccomp_benchmark.c +3 -3
@@ -40,9 +40,9 @@ unsigned long long timing(clockid_t clk_id, unsigned long long samples) i *=1000000000ULL ; i += finish.tv_nsec - start.tv_nsec; -ksft_print_msg ("%lu.%09lu - %lu.%09lu = %llu (%.1fs)\n" , - finish.tv_sec, finish.tv_nsec, - start.tv_sec, start.tv_nsec, +ksft_print_msg ("%lld.%09ld - %lld.%09ld = %llu (%.1fs)\n" , + (long long )finish.tv_sec, (long )finish.tv_nsec, + (long long )start.tv_sec, (long )start.tv_nsec, i, (double )i /1000000000.0 );return i;
Signature · 1 line
2.53.0