From 8c0947892b56c3df792b8557cbf33b54038d8a1c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 27 Dec 2025 12:41:06 +0100 Subject: [PATCH] tests: cast pid_t and struct timeval fields before printing The exact type behind these might depend on the architecture. For instance, on ARMv7, struct timeval fields are long long int instead of long int: FAILED: tests/libtest-runner.a.p/test-compositor.c.o cc -Itests/libtest-runner.a.p -Itests -I../tests -I. -I.. -Isrc -I../src -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c99 -O0 -g -D_POSIX_C_SOURCE=200809L -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden -fPIC -pthread -MD -MQ tests/libtest-runner.a.p/test-compositor.c.o -MF tests/libtest-runner.a.p/test-compositor.c.o.d -o tests/libtest-runner.a.p/test-compositor.c.o -c ../tests/test-compositor.c ../tests/test-compositor.c: In function 'get_socket_name': ../tests/test-compositor.c:95:60: error: format '%ld' expects argument of type 'long int', but argument 5 has type '__time64_t' {aka 'long long int'} [-Werror=format=] 95 | snprintf(retval, sizeof retval, "wayland-test-%d-%ld%ld", | ~~^ | | | long int | %lld 96 | getpid(), tv.tv_sec, tv.tv_usec); | ~~~~~~~~~ | | | __time64_t {aka long long int} ../tests/test-compositor.c:95:63: error: format '%ld' expects argument of type 'long int', but argument 6 has type '__suseconds64_t' {aka 'long long int'} [-Werror=format=] 95 | snprintf(retval, sizeof retval, "wayland-test-%d-%ld%ld", | ~~^ | | | long int | %lld 96 | getpid(), tv.tv_sec, tv.tv_usec); | ~~~~~~~~~~ | | | __suseconds64_t {aka long long int} Signed-off-by: Simon Ser --- tests/test-compositor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-compositor.c b/tests/test-compositor.c index 8ec0631b..efec31fa 100644 --- a/tests/test-compositor.c +++ b/tests/test-compositor.c @@ -92,8 +92,8 @@ get_socket_name(void) static char retval[64]; gettimeofday(&tv, NULL); - snprintf(retval, sizeof retval, "wayland-test-%d-%ld%ld", - getpid(), tv.tv_sec, tv.tv_usec); + snprintf(retval, sizeof retval, "wayland-test-%d-%lld%lld", + (int) getpid(), (long long int) tv.tv_sec, (long long int) tv.tv_usec); return retval; }