Skip to contentSkip to conversation

selftests/futex: print tv_sec as long long

PATCH In review Sasha Levin 2 participants 2 messages Nov 3 – Nov 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/futex: 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 %ld warns:

futex_requeue_pi.c:351:30: warning: format specifies type 'long' but the argument has type '__time64_t' (aka 'long long') [-Wformat]

Cast it to long long and print it with %lld.

---
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/futex/functional/futex_requeue_pi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/futex/functional/futex_requeue_pi.c +1 -1
index 65326cbef3a44..2530e6999f933 100644
@@ -348,7 +348,7 @@ TEST_F(args, futex_requeue_pi)
 		secs = (ts.tv_nsec + timeout_ns) / 1000000000;
 		ts.tv_nsec = ((int64_t)ts.tv_nsec + timeout_ns) % 1000000000;
 		ts.tv_sec += secs;
-		TH_LOG("ts.tv_sec  = %ld", ts.tv_sec);
+		TH_LOG("ts.tv_sec  = %lld", (long long)ts.tv_sec);
 		TH_LOG("ts.tv_nsec = %ld", ts.tv_nsec);
 		tsp = &ts;
 	}
Signature · 1 line
2.53.0
reviewer Reviewed-by on v1 1/1
#1 lore raw

Em 03/11/2026 12:54, Sasha Levin escreveu:

Quoted 8 lines

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 %ld warns:

futex_requeue_pi.c:351:30: warning: format specifies type 'long' but the argument has type '__time64_t' (aka 'long long') [-Wformat]

Cast it to long long and print it with %lld.