[Devel] [PATCH RHEL10 COMMIT] ms/libbpf: Fix -Wdiscarded-qualifiers under C23

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 12 15:05:12 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-55.52.1.5.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-55.52.1.5.22.vz10
------>
commit 5b9278b1bf5c51fc3712125a7d7d20d20fae8883
Author: Mikhail Gavrilov <mikhail.v.gavrilov at gmail.com>
Date:   Mon Apr 27 19:20:40 2026 +0300

    ms/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 at redhat.com>
    Suggested-by: Andrii Nakryiko <andrii at kernel.org>
    Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov at gmail.com>
    Link: https://lore.kernel.org/r/20251206092825.1471385-1-mikhail.v.gavrilov@gmail.com
    Signed-off-by: Alexei Starovoitov <ast at kernel.org>
    
    Backport changes: the hunk in avail_kallsyms_cb() has been dropped -
    no appropriate code to be changed yet there.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-129993
    Feature: fix ms/C23
    
    (cherry picked from commit d70f79fef65810faf64dbae1f3a1b5623cdb2345)
    Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
 tools/lib/bpf/libbpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 219facd0e66e8..bf8a29ce63e2a 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8115,7 +8115,7 @@ static int kallsyms_cb(unsigned long long sym_addr, char sym_type,
 	struct bpf_object *obj = ctx;
 	const struct btf_type *t;
 	struct extern_desc *ext;
-	char *res;
+	const char *res;
 
 	res = strstr(sym_name, ".llvm.");
 	if (sym_type == 'd' && res)
@@ -11912,7 +11912,7 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
 		if (!search_paths[i])
 			continue;
 		for (s = search_paths[i]; s != NULL; s = strchr(s, ':')) {
-			char *next_path;
+			const char *next_path;
 			int seg_len;
 
 			if (s[0] == ':')


More information about the Devel mailing list