selftests: net: fix array_size.cocci warning
authorGuo Zhengkui <guozhengkui@vivo.com>
Sat, 5 Mar 2022 16:18:35 +0000 (00:18 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Mar 2022 12:23:27 +0000 (12:23 +0000)
Fit the following coccicheck warning:
tools/testing/selftests/net/reuseport_bpf_numa.c:89:28-29:
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: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/reuseport_bpf_numa.c

index b2eebf669b8cfe736a497b6087f46b6533f4c02f..c9ba36aa688e2520b4aaf3661db835ed2f8079a8 100644 (file)
@@ -86,7 +86,7 @@ static void attach_bpf(int fd)
 
        memset(&attr, 0, sizeof(attr));
        attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER;
-       attr.insn_cnt = sizeof(prog) / sizeof(prog[0]);
+       attr.insn_cnt = ARRAY_SIZE(prog);
        attr.insns = (unsigned long) &prog;
        attr.license = (unsigned long) &bpf_license;
        attr.log_buf = (unsigned long) &bpf_log_buf;