Re: [PATCH v2 2/9] bpf/btf: tracing: Move finding func-proto API and getting func-param API to BTF

From: Google
Date: Mon Jul 17 2023 - 21:02:56 EST


On Mon, 17 Jul 2023 19:51:29 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> On Tue, 18 Jul 2023 08:46:34 +0900
> Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:
>
> > > > + * Get function parameter with the number of parameters.
> > > > + * This can return NULL if the function has no parameters.
> > >
> > > " It can return EINVAL if this function's parameters are NULL."
> >
> > No, as you can see the code, if btf_type_vlen(func_proto) returns 0 (means
> > the function proto type has no parameters), btf_get_func_param() returns
> > NULL. This is important point because user needs to use IS_ERR_OR_NULL(ret)
> > instead of IS_ERR(ret).
>
> I didn't mean to replace what you had, I meant you left that part out. In
> other words, you have to check for IS_ERR_OR_NULL(ret), not just "!ret".

Ah, got it! Let me update it.

Thank you!

>
> -- Steve
>
> > >
> > > > + */
> > > > +const struct btf_param *btf_get_func_param(const struct btf_type *func_proto, s32 *nr)
> > > > +{
> > > > + if (!func_proto || !nr)
> > > > + return ERR_PTR(-EINVAL);
> > > > +


--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>