]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: tools: memchr definition changed in C23
authorWilliam Lallemand <wlallemand@irq6.net>
Wed, 7 Jan 2026 13:41:06 +0000 (14:41 +0100)
committerWilliam Lallemand <wlallemand@irq6.net>
Wed, 7 Jan 2026 13:51:26 +0000 (14:51 +0100)
New gcc and clang versions from fedora rawhide seems to use the C23
standard by default. This version changes the definition of some
string.h functions, which now return a const char * instead of a char *.

src/tools.c: In function ‘fgets_from_mem’:
src/tools.c:7200:17: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 7200 |         new_pos = memchr(*position, '\n', size);
      |                 ^

Strangely, -Wdiscarded-qualifiers does not seem to catch all the
memchr.

Should fix issue #3228.

This could be backported in previous versions.

src/tools.c

index 50101bc634038f40e48abff64e8880446af3da56..460a34e18f88d3c6bcf99aa554ffb548b50b36ce 100644 (file)
@@ -7182,7 +7182,7 @@ REGISTER_PER_THREAD_INIT(init_tools_per_thread);
  */
 char *fgets_from_mem(char* buf, int size, const char **position, const char *end)
 {
-       char *new_pos;
+       const char *new_pos;
        int len = 0;
 
        /* keep fgets behaviour */