提交 c41d81bf 编写于 作者: D Dmitrii Banshchikov 提交者: Daniel Borkmann

selftests/bpf: Fix a compiler warning in global func test

Add an explicit 'const void *' cast to pass program ctx pointer type into
a global function that expects pointer to structure.

warning: incompatible pointer types
passing 'struct __sk_buff *' to parameter of type 'const struct S *'
[-Wincompatible-pointer-types]
        return foo(skb);
                   ^~~
progs/test_global_func11.c:10:36: note: passing argument to parameter 's' here
__noinline int foo(const struct S *s)
                                   ^

Fixes: 8b08807d ("selftests/bpf: Add unit tests for pointers in global functions")
Signed-off-by: NDmitrii Banshchikov <me@ubique.spb.ru>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210223082211.302596-1-me@ubique.spb.ru
上级 f4eda8b6
...@@ -15,5 +15,5 @@ __noinline int foo(const struct S *s) ...@@ -15,5 +15,5 @@ __noinline int foo(const struct S *s)
SEC("cgroup_skb/ingress") SEC("cgroup_skb/ingress")
int test_cls(struct __sk_buff *skb) int test_cls(struct __sk_buff *skb)
{ {
return foo(skb); return foo((const void *)skb);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册