BUILD: tools: memchr definition changed in C23

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.
This commit is contained in:
William Lallemand 2026-01-07 14:41:06 +01:00
parent 5322bd3785
commit 4aff6d1c25

View 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 */