summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYogesh Tyagi <yogesh.tyagi@intel.com>2026-03-13 23:42:43 +0800
committerYogesh Tyagi <yogesh.tyagi@intel.com>2026-03-13 23:45:44 +0800
commit1610818c25713c700f48c5428c151d0d02e4aa94 (patch)
tree799fb43bb9ca177af582831d141b21ffc36e35e5
parentea36e10468ac23868a6e065c877dc761982238bb (diff)
downloadmeta-intel-1610818c25713c700f48c5428c151d0d02e4aa94.tar.gz
perf: Fix const qualifier warnings in libbpf.c
Fix compilation warnings when building perf with -Werror where const qualifiers are discarded from pointers returned by strstr() and strchr() functions in libbpf.c. Both strstr() and strchr() return 'const char *' when given 'const char *' input parameters. The receiving variables must preserve this const qualification to maintain const-correctness and avoid compiler warnings. Errors fixed: libbpf.c:8179:13: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] libbpf.c:11967:35: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] This is a workaround for kernel 6.12.x. The issue is already fixed upstream in kernel 6.13+ and can be removed when the kernel is updated. Signed-off-by: Yogesh Tyagi <yogesh.tyagi@intel.com>
-rw-r--r--recipes-kernel/perf/perf.bbappend17
1 files changed, 17 insertions, 0 deletions
diff --git a/recipes-kernel/perf/perf.bbappend b/recipes-kernel/perf/perf.bbappend
new file mode 100644
index 00000000..54ad4dd9
--- /dev/null
+++ b/recipes-kernel/perf/perf.bbappend
@@ -0,0 +1,17 @@
1# Fix const qualifier warnings in libbpf.c when building with -Werror
2# This is a workaround for older kernel versions (6.12.x) that don't have
3# the upstream fix yet. The issue is already fixed in kernel 6.13+.
4
5# remove at next version upgrade or when output changes
6PR = "r3"
7HASHEQUIV_HASH_VERSION .= ".3"
8
9do_configure:prepend () {
10 # Apply libbpf const qualifier fixes
11 if [ -e "${S}/tools/lib/bpf/libbpf.c" ]; then
12 # Fix kallsyms_cb function - change 'char *res' to 'const char *res'
13 sed -i 's/^\(\s*\)char \*res;/\1const char *res;/' "${S}/tools/lib/bpf/libbpf.c"
14 # Fix resolve_full_path function - change 'char *next_path' to 'const char *next_path'
15 sed -i 's/^\(\s*\)char \*next_path;/\1const char *next_path;/' "${S}/tools/lib/bpf/libbpf.c"
16 fi
17}