Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libbpf: Fix -Wdiscarded-qualifiers under C23

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>

authored by

Mikhail Gavrilov and committed by
Alexei Starovoitov
d70f79fe 639f58a0

+4 -3
+4 -3
tools/lib/bpf/libbpf.c
··· 8484 8484 struct bpf_object *obj = ctx; 8485 8485 const struct btf_type *t; 8486 8486 struct extern_desc *ext; 8487 - char *res; 8487 + const char *res; 8488 8488 8489 8489 res = strstr(sym_name, ".llvm."); 8490 8490 if (sym_type == 'd' && res) ··· 11818 11818 * 11819 11819 * [0] fb6a421fb615 ("kallsyms: Match symbols exactly with CONFIG_LTO_CLANG") 11820 11820 */ 11821 - char sym_trim[256], *psym_trim = sym_trim, *sym_sfx; 11821 + char sym_trim[256], *psym_trim = sym_trim; 11822 + const char *sym_sfx; 11822 11823 11823 11824 if (!(sym_sfx = strstr(sym_name, ".llvm."))) 11824 11825 return 0; ··· 12402 12401 if (!search_paths[i]) 12403 12402 continue; 12404 12403 for (s = search_paths[i]; s != NULL; s = strchr(s, ':')) { 12405 - char *next_path; 12404 + const char *next_path; 12406 12405 int seg_len; 12407 12406 12408 12407 if (s[0] == ':')