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

"d.hourtoulle" <[email protected]>
Newsgroups org.kernel.vger.dwarves
Message-ID <[email protected]>
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]>
---
 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] == ':')
-- 
2.53.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.