Skip to content

Commit 58dccb1

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 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 <[email protected]> Suggested-by: Andrii Nakryiko <[email protected]> Signed-off-by: Mikhail Gavrilov <[email protected]>
1 parent 362a95a commit 58dccb1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 4 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)
@@ -11818,7 +11818,8 @@ static int avail_kallsyms_cb(unsigned long long sym_addr, char sym_type,
1181811818
*
1181911819
* [0] fb6a421fb615 ("kallsyms: Match symbols exactly with CONFIG_LTO_CLANG")
1182011820
*/
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;
1182211823

1182311824
if (!(sym_sfx = strstr(sym_name, ".llvm.")))
1182411825
return 0;
@@ -12401,7 +12402,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
1240112402
if (!search_paths[i])
1240212403
continue;
1240312404
for (s = search_paths[i]; s != NULL; s = strchr(s, ':')) {
12404-
char *next_path;
12405+
const char *next_path;
1240512406
int seg_len;
1240612407

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

0 commit comments

Comments
 (0)