From e37a0d514a17a660434ea20c0dd84bc6c20ca517 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Le=20Goater?= Date: Mon, 15 Dec 2025 11:19:35 +0100 Subject: [PATCH] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 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 a5c711b1de8..ce4c3426d39 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; } -- 2.47.3