[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALOAHbDWvRAe=O-cG1nOMgant38g68u0t9HsDy4RDO7bh=hnUA@mail.gmail.com>
Date: Wed, 27 Apr 2022 00:14:07 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
john fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next 3/4] bpftool: Fix incorrect return in generated
detach helper
On Tue, Apr 26, 2022 at 2:47 PM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Sat, Apr 23, 2022 at 7:02 AM Yafang Shao <laoar.shao@...il.com> wrote:
> >
> > There is no return value of bpf_object__detach_skeleton(), so we'd
> > better not return it, that is formal.
> >
> > Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
> > Signed-off-by: Yafang Shao <laoar.shao@...il.com>
> > ---
> > tools/bpf/bpftool/gen.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> > index 7678af364793..8f76d8d9996c 100644
> > --- a/tools/bpf/bpftool/gen.c
> > +++ b/tools/bpf/bpftool/gen.c
> > @@ -1171,7 +1171,7 @@ static int do_skeleton(int argc, char **argv)
> > static inline void \n\
> > %1$s__detach(struct %1$s *obj) \n\
> > { \n\
> > - return bpf_object__detach_skeleton(obj->skeleton); \n\
> > + bpf_object__detach_skeleton(obj->skeleton); \n\
>
> It's not incorrect to return the result of void-returning function in
> another void-returning function. C compiler allows this and we rely on
> this property very explicitly in macros like BPF_PROG and BPF_KPROBE.
> So if anything, it's not a fix, at best improvement, but even then
> quite optional.
Right, the C compiler allows it.
I won't change it.
--
Regards
Yafang
Powered by blists - more mailing lists