From 2f5c96d53409160b11f031b22f2d947f75ab06ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Mon, 15 Dec 2025 11:19:34 +0100 Subject: [PATCH 1/4] i386: Fix const qualifier build errors with recent glibc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recent change in glibc 2.42.9000 [1] changes the return type of strstr() and other string functions to be 'const char *' when the input is a 'const char *'. This breaks the build in : ../hw/i386/x86-common.c:827:11: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 827 | vmode = strstr(kernel_cmdline, "vga="); | ^ Fix this by changing the type of the variables that store the result of these functions to 'const char *'. [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Link: https://lore.kernel.org/qemu-devel/20251215101937.281722-2-clg@redhat.com Signed-off-by: Cédric Le Goater --- hw/i386/x86-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index c844749900..f77e2e6304 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -654,7 +654,7 @@ void x86_load_linux(X86MachineState *x86ms, uint8_t header[8192], *setup, *kernel; hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f; - char *vmode; + const char *vmode; MachineState *machine = MACHINE(x86ms); struct setup_data *setup_data; const char *kernel_filename = machine->kernel_filename; From e37a0d514a17a660434ea20c0dd84bc6c20ca517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Mon, 15 Dec 2025 11:19:35 +0100 Subject: [PATCH 2/4] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recent change in glibc 2.42.9000 [1] changes the return type of strstr() and other string functions to be 'const char *' when the input is a 'const char *'. This breaks the build in : ../tests/vhost-user-bridge.c: In function ‘vubr_parse_host_port’: ../tests/vhost-user-bridge.c:749:15: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 749 | char *p = strchr(buf, ':'); | ^~~~~~ Fix this by using the glib g_strsplit() routine instead of strdup(). [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690 Suggested-by: Peter Maydell Acked-by: Yodel Eldar Tested-by: Yodel Eldar Reviewed-by: Thomas Huth Link: https://lore.kernel.org/qemu-devel/20251215101937.281722-3-clg@redhat.com Signed-off-by: Cédric Le Goater --- tests/vhost-user-bridge.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index a5c711b1de..ce4c3426d3 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -746,14 +746,12 @@ vubr_run(VubrDev *dev) static int vubr_parse_host_port(const char **host, const char **port, const char *buf) { - char *p = strchr(buf, ':'); - - if (!p) { + g_auto(GStrv) tokens = g_strsplit(buf, ":", 2); + if (!tokens[0] || !tokens[1]) { return -1; } - *p = '\0'; - *host = strdup(buf); - *port = strdup(p + 1); + *host = g_steal_pointer(&tokens[0]); + *port = g_steal_pointer(&tokens[1]); return 0; } From dfe87815ba450228811f3abc633d7dc02757922e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Mon, 15 Dec 2025 11:19:36 +0100 Subject: [PATCH 3/4] monitor: Fix const qualifier build errors with recent glibc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recent change in glibc 2.42.9000 [1] changes the return type of strchr() and other string functions to be 'const char *' when the input is a 'const char *'. This breaks the build in : ../monitor/hmp.c:589:7: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 589 | p = strchr(type, ':'); | ^ Fix this by changing the type of the variables that store the result of these functions to 'const char *'. [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690 Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/qemu-devel/20251215101937.281722-4-clg@redhat.com Signed-off-by: Cédric Le Goater --- monitor/hmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index 34e2b8f748..a3ee02e52c 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -577,10 +577,11 @@ static const char *get_command_name(const char *cmdline, * Read key of 'type' into 'key' and return the current * 'type' pointer. */ -static char *key_get_info(const char *type, char **key) +static const char *key_get_info(const char *type, char **key) { size_t len; - char *p, *str; + const char *p; + char *str; if (*type == ',') { type++; From d7e1df769910da9d832dda86b01fe1363e4f4a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Date: Mon, 15 Dec 2025 11:19:37 +0100 Subject: [PATCH 4/4] gdbstub: Fix const qualifier build errors with recent glibc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recent change in glibc 2.42.9000 [1] changes the return type of strstr() and other string functions to be 'const char *' when the input is a 'const char *'. This breaks the build in : ../gdbstub/user.c:322:21: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 322 | pid_placeholder = strstr(path, "%d"); | ^ Fix this by changing the type of the variables that store the result of these functions to 'const char *'. [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690 Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Link: https://lore.kernel.org/qemu-devel/20251215101937.281722-5-clg@redhat.com Signed-off-by: Cédric Le Goater --- gdbstub/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbstub/user.c b/gdbstub/user.c index 2e14ded3f0..e233c59816 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -317,7 +317,7 @@ static bool gdb_accept_socket(int gdb_fd) static int gdbserver_open_socket(const char *path, Error **errp) { g_autoptr(GString) buf = g_string_new(""); - char *pid_placeholder; + const char *pid_placeholder; pid_placeholder = strstr(path, "%d"); if (pid_placeholder != NULL) {