diff options
author | Linkui Xiao <xiaolinkui@kylinos.cn> | 2022-07-12 10:23:02 +0300 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-07-14 07:43:52 +0300 |
commit | b1fc28b338860b6c06a7a5881005a1ca9b108ba2 (patch) | |
tree | 4fc19e93557bd3e2b98f1768970f8fae7ad1ff8b /samples/bpf/fds_example.c | |
parent | 8ab4cdcf03d0b060fbf73f76460f199bbd759ff7 (diff) | |
download | linux-b1fc28b338860b6c06a7a5881005a1ca9b108ba2.tar.xz |
samples: 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: Linkui Xiao <xiaolinkui@kylinos.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20220712072302.13761-1-xiaolinkui@kylinos.cn
Diffstat (limited to 'samples/bpf/fds_example.c')
-rw-r--r-- | samples/bpf/fds_example.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c index 16dbf49e0f19..88a26f3ce201 100644 --- a/samples/bpf/fds_example.c +++ b/samples/bpf/fds_example.c @@ -17,6 +17,7 @@ #include <bpf/libbpf.h> #include "bpf_insn.h" #include "sock_example.h" +#include "bpf_util.h" #define BPF_F_PIN (1 << 0) #define BPF_F_GET (1 << 1) @@ -52,7 +53,7 @@ static int bpf_prog_create(const char *object) BPF_MOV64_IMM(BPF_REG_0, 1), BPF_EXIT_INSN(), }; - size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn); + size_t insns_cnt = ARRAY_SIZE(insns); struct bpf_object *obj; int err; |