From: Amaury Denoyelle Date: Mon, 3 Aug 2026 09:00:19 +0000 (+0200) Subject: BUILD: tools: fix C23 incompatible strrchr usage X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8745931e6f1f7f7010de2a7a2ab430b398755f6c;p=thirdparty%2Fhaproxy.git BUILD: tools: fix C23 incompatible strrchr usage Fix the following warning by ensuring strrchr() return type is set to 'const char *' if its input is declared as such. src/tools.c: In function ‘str2net’: src/tools.c:1618:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 1618 | if ((c = strrchr(str, '/')) != NULL) { | ^ This build warning was introduced by the following patch. 9bc6c4d18c2ea9836c171977c1c7c2979ecbb132 OPTIM: tools/str2net: only duplicate the string when a slash is present This change is required since C23, as strrchr(), along other functions which accept a const-qualified pointer without returning a const type are now declared as macro with generics to preserve the const qualifier. See https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3020.pdf for details. No need to backport, unless the above patch is. --- diff --git a/src/tools.c b/src/tools.c index 7425c4de0..08dbc78d3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1609,7 +1609,7 @@ int str2net(const char *str, int resolve, struct in_addr *addr, struct in_addr * { __label__ out_free, out_err; char *s = NULL; - char *c; + const char *c; int ret_val; memset(mask, 0, sizeof(*mask)); @@ -1660,7 +1660,7 @@ int str2net(const char *str, int resolve, struct in_addr *addr, struct in_addr * int str62net(const char *str, struct in6_addr *addr, unsigned char *mask) { char *s = NULL; - char *c; + const char *c; int ret_val = 0; char *err; unsigned long len = 128;