Skip to content

Commit f0d77ea

Browse files
NTManKernel Patches Daemon
authored andcommitted
tools/lib/bpf: fix -Wdiscarded-qualifiers under C23
glibc ≥ 2.42 (GCC 15) defaults to -std=gnu23, which promotes -Wdiscarded-qualifiers to an error in the default hardening flags of Fedora Rawhide, Arch Linux, openSUSE Tumbleweed, Gentoo, etc. In C23, strstr() and strchr() return "const char *" in most cases, making previous implicit casts invalid. This breaks the build of tools/bpf/resolve_btfids on pristine upstream kernel when using GCC 15 + glibc 2.42+. Fix the three remaining instances with explicit casts. No functional changes. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2417601 Suggested-by: Florian Weimer <[email protected]> Signed-off-by: Mikhail Gavrilov <[email protected]>
1 parent 8c83cb5 commit f0d77ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8484,7 +8484,7 @@ static int kallsyms_cb(unsigned long long sym_addr, char sym_type,
84848484
struct bpf_object *obj = ctx;
84858485
const struct btf_type *t;
84868486
struct extern_desc *ext;
8487-
char *res;
8487+
const char *res;
84888488

84898489
res = strstr(sym_name, ".llvm.");
84908490
if (sym_type == 'd' && res)
@@ -11822,7 +11822,7 @@ static int avail_kallsyms_cb(unsigned long long sym_addr, char sym_type,
1182211822
*/
1182311823
char sym_trim[256], *psym_trim = sym_trim, *sym_sfx;
1182411824

11825-
if (!(sym_sfx = strstr(sym_name, ".llvm.")))
11825+
if (!(sym_sfx = (char *)strstr(sym_name, ".llvm."))) /* needs mutation */
1182611826
return 0;
1182711827

1182811828
/* psym_trim vs sym_trim dance is done to avoid pointer vs array
@@ -12410,7 +12410,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
1241012410

1241112411
if (s[0] == ':')
1241212412
s++;
12413-
next_path = strchr(s, ':');
12413+
next_path = (char *)strchr(s, ':'); /* declared as char * above */
1241412414
seg_len = next_path ? next_path - s : strlen(s);
1241512415
if (!seg_len)
1241612416
continue;

0 commit comments

Comments
 (0)