aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/xsk.c
diff options
context:
space:
mode:
authorGuo Zhengkui <guozhengkui@vivo.com>2022-03-06 10:34:26 +0800
committerAndrii Nakryiko <andrii@kernel.org>2022-03-07 22:13:00 -0800
commit04b6de649e124f2ea9693a25a744e646c1203ff9 (patch)
tree5e354cdeb5061ecb23248d53b6bebbbb6503e528 /tools/lib/bpf/xsk.c
parentbpf: Replace strncpy() with strscpy() (diff)
downloadlinux-04b6de649e124f2ea9693a25a744e646c1203ff9.tar.xz
linux-04b6de649e124f2ea9693a25a744e646c1203ff9.zip
libbpf: Fix array_size.cocci warning
Fix the following coccicheck warning: tools/lib/bpf/bpf.c:114:31-32: WARNING: Use ARRAY_SIZE tools/lib/bpf/xsk.c:484:34-35: WARNING: Use ARRAY_SIZE tools/lib/bpf/xsk.c:485:35-36: WARNING: Use ARRAY_SIZE It has been tested with gcc (Debian 8.3.0-6) 8.3.0 on x86_64. Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220306023426.19324-1-guozhengkui@vivo.com
Diffstat (limited to 'tools/lib/bpf/xsk.c')
-rw-r--r--tools/lib/bpf/xsk.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 32a2f5749c71..af136f73b09d 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -481,8 +481,8 @@ static int xsk_load_xdp_prog(struct xsk_socket *xsk)
BPF_EMIT_CALL(BPF_FUNC_redirect_map),
BPF_EXIT_INSN(),
};
- size_t insns_cnt[] = {sizeof(prog) / sizeof(struct bpf_insn),
- sizeof(prog_redirect_flags) / sizeof(struct bpf_insn),
+ size_t insns_cnt[] = {ARRAY_SIZE(prog),
+ ARRAY_SIZE(prog_redirect_flags),
};
struct bpf_insn *progs[] = {prog, prog_redirect_flags};
enum xsk_prog option = get_xsk_prog();