Re: [PATCH 2/2] libbpf: fix discarded-qualifiers for strchr/strstr.

Alan Maguire <[email protected]>
Newsgroups org.kernel.vger.dwarves
Message-ID <[email protected]>
On 10/03/2026 13:28, d.hourtoulle wrote:
> From: Damien Hourtoulle <[email protected]>
> 
> Glibc 2.43 added C23 const-preserving overloads:
> https://sourceware.org/glibc/wiki/Release/2.43.
> 
> Fix three local variable declarations to use const char* instead of
> char*, removing the need to discard the const qualifier returned by
> strstr/strchr.
> 
> Signed-off-by: Damien Hourtoulle <[email protected]>

libbpf in pahole is a git submodule mirror of the kernel tree (bpf-next)
tools/lib/bpf; changes to libbpf should be submitted there. Thanks.

> ---
>  lib/bpf | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Submodule lib/bpf 374f780..6bba5da:
> diff --git a/lib/bpf/src/libbpf.c b/lib/bpf/src/libbpf.c
> index 617cfb9..9e88156 100644
> --- a/lib/bpf/src/libbpf.c
> +++ b/lib/bpf/src/libbpf.c
> @@ -8179,7 +8179,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)
> @@ -11482,8 +11482,8 @@ static int avail_kallsyms_cb(unsigned long long sym_addr, char sym_type,
>  		 *
>  		 *   [0] fb6a421fb615 ("kallsyms: Match symbols exactly with CONFIG_LTO_CLANG")
>  		 */
> -		char sym_trim[256], *psym_trim = sym_trim, *sym_sfx;
> -
> +		char sym_trim[256], *psym_trim = sym_trim;
> +		const char *sym_sfx;
>  		if (!(sym_sfx = strstr(sym_name, ".llvm.")))
>  			return 0;
>  
> @@ -12067,7 +12067,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] == ':')
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.