]> git.kaiwu.me - haproxy.git/commit
BUILD: tools: fix C23 incompatible strrchr usage
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 3 Aug 2026 09:00:19 +0000 (11:00 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 3 Aug 2026 09:11:11 +0000 (11:11 +0200)
commit8745931e6f1f7f7010de2a7a2ab430b398755f6c
treee877b8341158ab49b187b34e64f8c8362a011edd
parent9bc6c4d18c2ea9836c171977c1c7c2979ecbb132
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.
src/tools.c