util/u_printf: Fix const correctness in util_printf_next_spec_pos

Fix compiler error:

../src/util/u_printf.c:75:13: error: initializing 'char *' with an
expression of type 'const char *' discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
   75 |       char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%");
      |             ^          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

glibc now provides C23-style type-generic string functions. strpbrk
returns const char * when passed a const char * argument. Update
spec_pos declaration to match.

Fixes: 6d263ff5a3 ("util: Convert util/u_printf.cpp to util/u_printf.c")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39059>
This commit is contained in:
Vinson Lee 2025-12-21 21:48:57 -08:00
parent 166923bf0e
commit c576d64801

View file

@ -72,7 +72,7 @@ size_t util_printf_next_spec_pos(const char *str, size_t pos)
continue;
}
char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%");
const char *spec_pos = strpbrk(str_found, "cdieEfFgGaAosuxXp%");
if (spec_pos == NULL) {
return -1;
} else if (*spec_pos == '%') {