[Devel] [PATCH 1/2] libbpf: Fix -Wdiscarded-qualifiers under C23

Konstantin Khorenko khorenko at virtuozzo.com
Mon Apr 27 16:54:44 MSK 2026


Please,

* use "cherry-pick -sx" when porting commits from mainstream, it will add automatically lines like

   (cherry picked from commit d70f79fef65810faf64dbae1f3a1b5623cdb2345)
   Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

* add jira bug id, please. No bug? File it.
* add "Feature:" tag, see
   git log rh10-6.12.0-55.52.1.el10..HEAD | grep Feature | sort -u | grep -i ms

   find something appropriate.

* we have several products based on RHEL7/RHEL9/RHEL10, so when sending a patch use prefix like
   [PATCH vz10 1/2] (vz7, vz9 - what is appropriate)

Thank you.

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 4/26/26 23:02, Eva Kurchatova wrote:
> 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, next_path).
> 
> Adapted from upstream commit d70f79fef65810faf64dbae1f3a1b5623cdb2345,
> which does not apply cleanly (sym_sfx was introduced in 6.14 tree)
> ---
>   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 219facd0e66e..bf8a29ce63e2 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