From 92c15464aa8652534ec49c2f3a0d42fcfba882e8 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 16 Dec 2025 13:10:29 +0200 Subject: [PATCH] tests/client-buffer: fix false-positive uninitialized variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 14.2 with debugoptimized build complained: ../../git/weston/tests/client-buffer-test.c: In function ‘y_u_v_create_buffer’: ../../git/weston/tests/client-buffer-test.c:1045:33: error: ‘u_row’ may be used uninitialized [-Werror=maybe-uninitialized] 1045 | x8r8g8b8_to_ycbcr8_bt709(argb, y_row + x, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1046 | u_row + x / pixel_format_hsub(buf->fmt, 1), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1047 | v_row + x / pixel_format_hsub(buf->fmt, 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../git/weston/tests/client-buffer-test.c:986:18: note: ‘u_row’ was declared here 986 | uint8_t *u_row; | ^~~~~ ../../git/weston/tests/client-buffer-test.c:1045:33: error: ‘v_row’ may be used uninitialized [-Werror=maybe-uninitialized] 1045 | x8r8g8b8_to_ycbcr8_bt709(argb, y_row + x, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1046 | u_row + x / pixel_format_hsub(buf->fmt, 1), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1047 | v_row + x / pixel_format_hsub(buf->fmt, 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../git/weston/tests/client-buffer-test.c:987:18: note: ‘v_row’ was declared here 987 | uint8_t *v_row; | ^~~~~ The debug build did not complain. Even though only u_row and v_row were reported, I don't understand why there is no warning about u_base and v_base, as they are initialized with a similar switch. So initialize them too, just in case. Signed-off-by: Pekka Paalanen --- tests/client-buffer-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/client-buffer-test.c b/tests/client-buffer-test.c index 6ab7d8e3d..823d5d136 100644 --- a/tests/client-buffer-test.c +++ b/tests/client-buffer-test.c @@ -980,11 +980,11 @@ y_u_v_create_buffer(struct client *client, int x, y; uint32_t *rgb_row; uint8_t *y_base; - uint8_t *u_base; - uint8_t *v_base; + uint8_t *u_base = NULL; + uint8_t *v_base = NULL; uint8_t *y_row; - uint8_t *u_row; - uint8_t *v_row; + uint8_t *u_row = NULL; + uint8_t *v_row = NULL; uint32_t argb; buf = client_buffer_create(client, &args);