From 73468bab7d12fd4d7b62d3b50a56e77acd977607 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 5 Aug 2022 00:35:40 +0200 Subject: [PATCH] server: Extend display name string size MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Typically this is a number between 0 and 32. Just that the compiler doesn't know that well. Make the string buffer a bit larger, so that it fits the longer integers. Fixes build warnings like: ../subprojects/wayland/src/wayland-server.c: In function ‘wl_display_add_socket_auto’: ../subprojects/wayland/src/wayland-server.c:1649:70: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=] 1649 | snprintf(display_name, sizeof display_name, "wayland-%d", displayno); | ^~ ../subprojects/wayland/src/wayland-server.c:1649:61: note: directive argument in the range [-2147483647, 32] 1649 | snprintf(display_name, sizeof display_name, "wayland-%d", displayno); | ^~~~~~~~~~~~ ../subprojects/wayland/src/wayland-server.c:1649:17: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16 1649 | snprintf(display_name, sizeof display_name, "wayland-%d", displayno); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Seen in GTK CI. Signed-off-by: Carlos Garnacho --- src/wayland-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wayland-server.c b/src/wayland-server.c index 8e24b41..a44982f 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -1635,7 +1635,7 @@ wl_display_add_socket_auto(struct wl_display *display) { struct wl_socket *s; int displayno = 0; - char display_name[16] = ""; + char display_name[20] = ""; /* A reasonable number of maximum default sockets. If * you need more than this, use the explicit add_socket API. */ -- 2.7.4