summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c
diff options
context:
space:
mode:
authorFeng Yang <yangfeng@kylinos.cn>2024-09-03 15:25:59 +0800
committerAndrii Nakryiko <andrii@kernel.org>2024-09-04 12:58:46 -0700
commit23457b37ec3f9bb373d43cca61db371303726a1e (patch)
treeb26b9769bd65c527e17aa2b77d645278bfde6af8 /tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c
parent6fee7a7e9ad8613251d74472fb5bd2c6464f234a (diff)
selftests: bpf: Replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE
The ARRAY_SIZE macro is more compact and more formal in linux source. Signed-off-by: Feng Yang <yangfeng@kylinos.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20240903072559.292607-1-yangfeng59949@163.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c b/tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c
index 0adf8d9475cb..472f4f9fa95f 100644
--- a/tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c
+++ b/tools/testing/selftests/bpf/prog_tests/unpriv_bpf_disabled.c
@@ -7,6 +7,7 @@
#include "test_unpriv_bpf_disabled.skel.h"
#include "cap_helpers.h"
+#include "bpf_util.h"
/* Using CAP_LAST_CAP is risky here, since it can get pulled in from
* an old /usr/include/linux/capability.h and be < CAP_BPF; as a result
@@ -146,7 +147,7 @@ static void test_unpriv_bpf_disabled_negative(struct test_unpriv_bpf_disabled *s
BPF_MOV64_IMM(BPF_REG_0, 0),
BPF_EXIT_INSN(),
};
- const size_t prog_insn_cnt = sizeof(prog_insns) / sizeof(struct bpf_insn);
+ const size_t prog_insn_cnt = ARRAY_SIZE(prog_insns);
LIBBPF_OPTS(bpf_prog_load_opts, load_opts);
struct bpf_map_info map_info = {};
__u32 map_info_len = sizeof(map_info);