aboutsummaryrefslogtreecommitdiff
path: root/samples/bpf/sock_example.c
diff options
context:
space:
mode:
authorLinkui Xiao2022-07-12 15:23:02 +0800
committerAndrii Nakryiko2022-07-13 21:43:52 -0700
commitb1fc28b338860b6c06a7a5881005a1ca9b108ba2 (patch)
tree4fc19e93557bd3e2b98f1768970f8fae7ad1ff8b /samples/bpf/sock_example.c
parent8ab4cdcf03d0b060fbf73f76460f199bbd759ff7 (diff)
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/sock_example.c')
-rw-r--r--samples/bpf/sock_example.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/samples/bpf/sock_example.c b/samples/bpf/sock_example.c
index a88f69504c08..5b66f2401b96 100644
--- a/samples/bpf/sock_example.c
+++ b/samples/bpf/sock_example.c
@@ -29,6 +29,7 @@
#include <bpf/bpf.h>
#include "bpf_insn.h"
#include "sock_example.h"
+#include "bpf_util.h"
char bpf_log_buf[BPF_LOG_BUF_SIZE];
@@ -58,7 +59,7 @@ static int test_sock(void)
BPF_MOV64_IMM(BPF_REG_0, 0), /* r0 = 0 */
BPF_EXIT_INSN(),
};
- size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
+ size_t insns_cnt = ARRAY_SIZE(prog);
LIBBPF_OPTS(bpf_prog_load_opts, opts,
.log_buf = bpf_log_buf,
.log_size = BPF_LOG_BUF_SIZE,