Skip to content

Commit 3dedeee

Browse files
NTMangregkh
authored andcommitted
libbpf: Fix -Wdiscarded-qualifiers under C23
commit d70f79f upstream. glibc ≥ 2.42 (GCC 15) defaults to -std=gnu23, which promotes -Wdiscarded-qualifiers to an error. In C23, strstr() and strchr() return "const char *". Change variable types to const char * where the pointers are never modified (res, sym_sfx, next_path). Suggested-by: Florian Weimer <fweimer@redhat.com> Suggested-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com> Link: https://lore.kernel.org/r/20251206092825.1471385-1-mikhail.v.gavrilov@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> [ shung-hsi.yu: needed to fix kernel build failure due to libbpf since glibc 2.43+ (which adds 'const' qualifier to strstr). 'sym_sfx' hunk dropped because commit f8a0569 ("libbpf: Work around kernel inconsistently stripping '.llvm.' suffix") is not present. ] Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 70ba85e commit 3dedeee

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tools/lib/bpf/libbpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8174,7 +8174,7 @@ static int kallsyms_cb(unsigned long long sym_addr, char sym_type,
81748174
struct bpf_object *obj = ctx;
81758175
const struct btf_type *t;
81768176
struct extern_desc *ext;
8177-
char *res;
8177+
const char *res;
81788178

81798179
res = strstr(sym_name, ".llvm.");
81808180
if (sym_type == 'd' && res)
@@ -11959,7 +11959,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
1195911959
if (!search_paths[i])
1196011960
continue;
1196111961
for (s = search_paths[i]; s != NULL; s = strchr(s, ':')) {
11962-
char *next_path;
11962+
const char *next_path;
1196311963
int seg_len;
1196411964

1196511965
if (s[0] == ':')

0 commit comments

Comments
 (0)