Skip to contentSkip to conversation

bpftool: fix -Wcast-qual warning

PATCH Applied Denys Zagorui 3 participants 3 messages Sep 7, 2023 – Sep 8, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bpftool: fix -Wcast-qual warning

This cast was made by purpose for older libbpf where the bpf_object_skeleton field is void * instead of const void * to eliminate a warning (as i understand -Wincompatible-pointer-types-discards-qualifiers) but this cast introduces another warning (-Wcast-qual) for libbpf where data field is const void *

It makes sense for bpftool to be in sync with libbpf from kernel sources

---
 tools/bpf/bpftool/gen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/bpftool/gen.c +1 -1
index 2883660d6b67..04c47745b3ea 100644
@@ -1209,7 +1209,7 @@ static int do_skeleton(int argc, char **argv)
 	codegen("\
 		\n\
 									    \n\
-			s->data = (void *)%2$s__elf_bytes(&s->data_sz);	    \n\
+			s->data = %2$s__elf_bytes(&s->data_sz);		    \n\
 									    \n\
 			obj->skeleton = s;				    \n\
 			return 0;					    \n\
Signature · 1 line
2.35.6
Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Denys Zagorui

This cast was made by purpose for older libbpf where the bpf_object_skeleton field is void * instead of const void * to eliminate a warning (as i understand -Wincompatible-pointer-types-discards-qualifiers) but this cast introduces another warning (-Wcast-qual) for libbpf where data field is const void *

It makes sense for bpftool to be in sync with libbpf from kernel sources

#2 lore raw
In reply to Denys Zagorui
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 8 lines · On Thu, 7 Sep 2023 02:02:10 -0700 you wrote:

This cast was made by purpose for older libbpf where the bpf_object_skeleton field is void * instead of const void * to eliminate a warning (as i understand -Wincompatible-pointer-types-discards-qualifiers) but this cast introduces another warning (-Wcast-qual) for libbpf where data field is const void *

[...]

Here is the summary with links:
- [v2] bpftool: fix -Wcast-qual warning

    https://git.kernel.org/bpf/bpf-next/c/52f8e1648394

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html