From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: eddyz87@gmail.com, mykolal@fb.com, ast@kernel.org,
daniel@iogearbox.net, song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, jolsa@kernel.org, shuah@kernel.org,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Abaci Robot <abaci@linux.alibaba.com>,
andrii@kernel.org
Subject: Re: [PATCH] selftests/bpf: Use ARRAY_SIZE for array length
Date: Fri, 2 Feb 2024 13:50:35 -0800 [thread overview]
Message-ID: <b7a0b41e-569d-4d70-957d-0bb8e3556b32@linux.dev> (raw)
In-Reply-To: <20240202090652.11294-1-jiapeng.chong@linux.alibaba.com>
On 2/2/24 1:06 AM, Jiapeng Chong wrote:
> Use of macro ARRAY_SIZE to calculate array size minimizes
> the redundant code and improves code reusability.
>
> ./tools/testing/selftests/bpf/progs/syscall.c:122:26-27: WARNING: Use ARRAY_SIZE.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=8170
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> tools/testing/selftests/bpf/progs/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/syscall.c b/tools/testing/selftests/bpf/progs/syscall.c
> index 3d3cafdebe72..297a34f224c3 100644
> --- a/tools/testing/selftests/bpf/progs/syscall.c
> +++ b/tools/testing/selftests/bpf/progs/syscall.c
> @@ -119,7 +119,7 @@ int load_prog(struct args *ctx)
> static __u64 value = 34;
> static union bpf_attr prog_load_attr = {
> .prog_type = BPF_PROG_TYPE_XDP,
> - .insn_cnt = sizeof(insns) / sizeof(insns[0]),
> + .insn_cnt = ARRAY_SIZE(insns)
This does not even compile:
https://github.com/kernel-patches/bpf/actions/runs/7761734279/job/21170796228
The existing code here is fine.
> };
> int ret;
>
prev parent reply other threads:[~2024-02-02 21:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 9:06 [PATCH] selftests/bpf: Use ARRAY_SIZE for array length Jiapeng Chong
2024-02-02 21:50 ` Martin KaFai Lau [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b7a0b41e-569d-4d70-957d-0bb8e3556b32@linux.dev \
--to=martin.lau@linux.dev \
--cc=abaci@linux.alibaba.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mykolal@fb.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox