Fix const qualifier build errors with recent glibc
v2 cover Fix const qualifier build errors with recent glibc
Hello,
More fixes for the build breakage due to the recent change in glibc 2.42.9000 :
https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Thanks,
C.
Changes in v2:
- I did a full QEMU build this time and found a couple more issues to fix. We should be done now.
Cédric Le Goater (4):
i386: Fix const qualifier build errors with recent glibc tests/vhost-user-bridge.c: Fix const qualifier build errors with
recent glibc
monitor: Fix const qualifier build errors with recent glibc
gdbstub: Fix const qualifier build errors with recent glibc
gdbstub/user.c | 2 +- hw/i386/x86-common.c | 2 +- monitor/hmp.c | 5 +++-- tests/vhost-user-bridge.c | 10 ++++------ 4 files changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.52.0
PATCH v2 1/4 i386: Fix const qualifier build errors with recent glibc
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
--- hw/i386/x86-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/x86-common.c +1 -1
@@ -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;
Signature · 1 line
2.52.0
PATCH v2 2/4 tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterA 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
--- tests/vhost-user-bridge.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
tests/vhost-user-bridge.c +4 -6
@@ -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 ; }
Signature · 1 line
2.52.0
Re: [PATCH v2 2/4] tests/vhost-user-bridge.c: Fix const qualifier build errors with recent glibc
Quoted 35 lines · Cédric Le Goater
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 ofstrdup().[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Suggested-by Peter Maydell <[email protected]>Acked-by Yodel Eldar <[email protected]>Tested-by Yodel Eldar <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- tests/vhost-user-bridge.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)tests/vhost-user-bridge.c +2
-3@@ -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 ]) {
tests/vhost-user-bridge.c vubr_run(VubrDev *dev) · line 757
Quoted 10 lines
tests/vhost-user-bridge.c +2
-3return -1 ; } - *p ='\0' ; - *host =strdup (buf); - *port =strdup (p +1 ); + *host =g_steal_pointer (&tokens[0 ]); + *port =g_steal_pointer (&tokens[1 ]);return 0 ; }
PATCH v2 3/4 monitor: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterA 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
--- monitor/hmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
monitor/hmp.c +3 -2
@@ -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++;
Signature · 1 line
2.52.0
Re: [PATCH v2 3/4] monitor: Fix const qualifier build errors with recent glibc
Quoted 11 lines · Cédric Le Goater
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 *'.
Quoted 6 lines
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Signed-off-by Cédric Le Goater <[email protected]>--- monitor/hmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Re: [PATCH v2 3/4] monitor: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterQuoted 26 lines · Cédric Le Goater
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
Signed-off-by Cédric Le Goater <[email protected]>--- monitor/hmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)monitor/hmp.c +0
-0@@ -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. */
monitor/hmp.c static const char *get_command_name(const char *cmdline, · line 587
Quoted 10 lines
monitor/hmp.c +3
-2-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++;
PATCH v2 4/4 gdbstub: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterA 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
--- gdbstub/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gdbstub/user.c +1 -1
@@ -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 ) {
Signature · 1 line
2.52.0
Re: [PATCH v2 4/4] gdbstub: Fix const qualifier build errors with recent glibc
Quoted 10 lines · Cédric Le Goater
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 *'.
Quoted 6 lines
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=cd748a63ab1a7ae846175c532a3daab341c62690
Signed-off-by Cédric Le Goater <[email protected]>--- gdbstub/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH v2 4/4] gdbstub: Fix const qualifier build errors with recent glibc
In reply to Cédric Le GoaterQuoted 22 lines · Cédric Le Goater
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
Signed-off-by Cédric Le Goater <[email protected]>--- gdbstub/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)gdbstub/user.c +0
-0
gdbstub/user.c static bool gdb_accept_socket(int gdb_fd) · line 323
Quoted 8 lines
gdbstub/user.c +1
-1@@ -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 ) {