On Tue, Jun 25, 2024 at 09:46:55AM +0100, Alan Maguire wrote: > On 25/06/2024 06:27, Jiri Olsa wrote: > > ARRAY_SIZE is used on multiple places, move its definition in > > bpf_misc.h header. > > > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > > good idea ; one very optional nit/suggestion below but > > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > > > --- > > tools/testing/selftests/bpf/progs/bpf_misc.h | 2 ++ > > tools/testing/selftests/bpf/progs/iters.c | 2 -- > > tools/testing/selftests/bpf/progs/kprobe_multi_session.c | 3 +-- > > tools/testing/selftests/bpf/progs/linked_list.c | 5 +---- > > tools/testing/selftests/bpf/progs/netif_receive_skb.c | 5 +---- > > tools/testing/selftests/bpf/progs/profiler.inc.h | 5 +---- > > tools/testing/selftests/bpf/progs/setget_sockopt.c | 5 +---- > > tools/testing/selftests/bpf/progs/test_bpf_ma.c | 4 ---- > > tools/testing/selftests/bpf/progs/test_sysctl_loop1.c | 5 +---- > > tools/testing/selftests/bpf/progs/test_sysctl_loop2.c | 5 +---- > > tools/testing/selftests/bpf/progs/test_sysctl_prog.c | 5 +---- > > .../testing/selftests/bpf/progs/test_tcp_custom_syncookie.c | 1 + > > .../testing/selftests/bpf/progs/test_tcp_custom_syncookie.h | 2 -- > > .../testing/selftests/bpf/progs/verifier_subprog_precision.c | 2 -- > > 14 files changed, 11 insertions(+), 40 deletions(-) > > > > diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h > > index c0280bd2f340..ac6ab1b977a1 100644 > > --- a/tools/testing/selftests/bpf/progs/bpf_misc.h > > +++ b/tools/testing/selftests/bpf/progs/bpf_misc.h > > @@ -140,4 +140,6 @@ > > /* make it look to compiler like value is read and written */ > > #define __sink(expr) asm volatile("" : "+g"(expr)) > > > > +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) > > nit: would it be worth bracketing the #define in an #ifndef > ARRAY_SIZE/#endif? A few cases you're replacing (like > progs/linked_list.c) have the #ifndef/#endif protection. sure, makes sense, will send v2 thanks, jirka