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 various files with errors such as :

  error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
    208 |         char *pidstr = strstr(filename, "%");
        |                        ^~~~~~

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 <clg@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251209174328.698774-1-clg@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Cédric Le Goater
2025-12-09 18:43:28 +01:00
committed by Philippe Mathieu-Daudé
parent e742b7bdc2
commit 326e620fc0
7 changed files with 10 additions and 9 deletions

View File

@@ -403,7 +403,8 @@ static bool build_guest_fsinfo_for_pci_dev(char const *syspath,
int i, offset, nhosts = 0, pcilen;
GuestPCIAddress *pciaddr = disk->pci_controller;
bool has_ata = false, has_host = false, has_tgt = false;
char *p, *driver = NULL;
const char *p;
char *driver = NULL;
bool ret = false;
p = strstr(syspath, "/devices/pci");
@@ -543,7 +544,7 @@ static bool build_guest_fsinfo_for_nonpci_virtio(char const *syspath,
Error **errp)
{
unsigned int tgt[3];
char *p;
const char *p;
if (!strstr(syspath, "/virtio") || !strstr(syspath, "/block")) {
g_debug("Unsupported virtio device '%s'", syspath);
@@ -575,7 +576,7 @@ static bool build_guest_fsinfo_for_ccw_dev(char const *syspath,
Error **errp)
{
unsigned int cssid, ssid, subchno, devno;
char *p;
const char *p;
p = strstr(syspath, "/devices/css");
if (!p || sscanf(p + 12, "%*x/%x.%x.%x/%*x.%*x.%x/",