Re: [PATCH] selftests/bpf: fix array_size.cocci warning

From: Guo Zhengkui
Date: Thu Nov 18 2021 - 02:12:53 EST


> No need for the extra include. test_progs.h already includes bpf_util.h, please check
> such trivialities before submission. Simple grep would have revealed use of ARRAY_SIZE()
> in various places under tools/testing/selftests/bpf/prog_tests/.

Actually, ARRAY_SIZE() in ./include/linux/kernel.h is diffrent from the one defined in bpf_util.h:

./include/linux/kernel.h
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))

./tools/testing/selftests/bpf/bpf_util.h
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

__must_be_array() ensures arr is an array, which is better than the one defined in bpf_util.h

> here are many more similar occurrences. Please just send one cleanup patch to reduce churn in the git log.

Yes, I will commit another patch.