tree-wide: Fix constness issues with newer glibc (#39896)

Latest glibc uses _Generic to have strstr() and other functions return
const char* or char* based on whether the input is a const char* or a
char*. This causes build failures as we previously always expected a
char*.

Let's fix the compilation failures and add our own macros similar to
glibc's to have string functions that return a mutable or const pointer
depending on the input.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-11-26 00:32:54 +01:00
committed by GitHub
27 changed files with 109 additions and 89 deletions
+2 -6
View File
@@ -1156,9 +1156,7 @@ static const char* extract_multiplier(const char *p, usec_t *ret) {
assert(ret);
FOREACH_ELEMENT(i, table) {
char *e;
e = startswith(p, i->suffix);
const char *e = startswith(p, i->suffix);
if (e) {
*ret = i->usec;
return e;
@@ -1334,9 +1332,7 @@ static const char* extract_nsec_multiplier(const char *p, nsec_t *ret) {
assert(ret);
FOREACH_ELEMENT(i, table) {
char *e;
e = startswith(p, i->suffix);
const char *e = startswith(p, i->suffix);
if (e) {
*ret = i->nsec;
return e;