diff options
| author | Feng Yang <yangfeng@kylinos.cn> | 2024-09-03 15:25:59 +0800 |
|---|---|---|
| committer | Andrii Nakryiko <andrii@kernel.org> | 2024-09-04 12:58:46 -0700 |
| commit | 23457b37ec3f9bb373d43cca61db371303726a1e (patch) | |
| tree | b26b9769bd65c527e17aa2b77d645278bfde6af8 /tools/testing/selftests/bpf/prog_tests/log_buf.c | |
| parent | 6fee7a7e9ad8613251d74472fb5bd2c6464f234a (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/log_buf.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/log_buf.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/log_buf.c b/tools/testing/selftests/bpf/prog_tests/log_buf.c index 0f7ea4d7d9f6..46611040dec3 100644 --- a/tools/testing/selftests/bpf/prog_tests/log_buf.c +++ b/tools/testing/selftests/bpf/prog_tests/log_buf.c @@ -5,6 +5,7 @@ #include <bpf/btf.h> #include "test_log_buf.skel.h" +#include "bpf_util.h" static size_t libbpf_log_pos; static char libbpf_log_buf[1024 * 1024]; @@ -143,11 +144,11 @@ static void bpf_prog_load_log_buf(void) BPF_MOV64_IMM(BPF_REG_0, 0), BPF_EXIT_INSN(), }; - const size_t good_prog_insn_cnt = sizeof(good_prog_insns) / sizeof(struct bpf_insn); + const size_t good_prog_insn_cnt = ARRAY_SIZE(good_prog_insns); const struct bpf_insn bad_prog_insns[] = { BPF_EXIT_INSN(), }; - size_t bad_prog_insn_cnt = sizeof(bad_prog_insns) / sizeof(struct bpf_insn); + size_t bad_prog_insn_cnt = ARRAY_SIZE(bad_prog_insns); LIBBPF_OPTS(bpf_prog_load_opts, opts); const size_t log_buf_sz = 1024 * 1024; char *log_buf; |