[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQJ6A-BUwa85-4Fg7vn1vWb9e_mVgvegtd6WKYM0Opysmw@mail.gmail.com>
Date: Mon, 24 Jun 2024 13:15:10 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Thorsten Blum <thorsten.blum@...lux.com>
Cc: Martin KaFai Lau <martin.lau@...ux.dev>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>, Eddy Z <eddyz87@...il.com>,
Song Liu <song@...nel.org>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>, bpf <bpf@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bpf, btf: Make if test explicit to fix Coccinelle error
On Mon, Jun 24, 2024 at 12:56 PM Thorsten Blum <thorsten.blum@...lux.com> wrote:
>
> Explicitly test the iterator variable i > 0 to fix the following
> Coccinelle/coccicheck error reported by itnull.cocci:
>
> ERROR: iterator variable bound on line 4688 cannot be NULL
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
> kernel/bpf/btf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 821063660d9f..7720f8967814 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -4687,7 +4687,7 @@ static void btf_datasec_show(const struct btf *btf,
> __btf_name_by_offset(btf, t->name_off));
> for_each_vsi(i, t, vsi) {
> var = btf_type_by_id(btf, vsi->type);
> - if (i)
> + if (i > 0)
> btf_show(show, ",");
Sorry, I don't think this is a sustainable approach.
We cannot fix such things all over the kernel.
Pls make cocci smarter instead.
pw-bot: cr
Powered by blists - more mailing lists