selftests/bpf: Fix warning comparing pointer to 0
[linux-2.6-microblaze.git] / tools / testing / selftests / bpf / progs / test_global_func10.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <stddef.h>
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5
6 struct Small {
7         int x;
8 };
9
10 struct Big {
11         int x;
12         int y;
13 };
14
15 __noinline int foo(const struct Big *big)
16 {
17         if (!big)
18                 return 0;
19
20         return bpf_get_prandom_u32() < big->y;
21 }
22
23 SEC("cgroup_skb/ingress")
24 int test_cls(struct __sk_buff *skb)
25 {
26         const struct Small small = {.x = skb->len };
27
28         return foo((struct Big *)&small) ? 1 : 0;
29 }