Re: [RFC bpf-next v2 1/9] bpf: add a get_helper_proto() utility function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2024-07-09 at 16:42 -0700, Andrii Nakryiko wrote:

[...]

> > @@ -10261,6 +10261,24 @@ static void update_loop_inline_state(struct bpf_verifier_env *env, u32 subprogno
> >                                  state->callback_subprogno == subprogno);
> >  }
> > 
> > +static int get_helper_proto(struct bpf_verifier_env *env, int func_id,
> > +                           const struct bpf_func_proto **ptr)
> > +{
> > +       const struct bpf_func_proto *result = NULL;
> > +
> > +       if (func_id < 0 || func_id >= __BPF_FUNC_MAX_ID)
> > +               return -ERANGE;
> > +
> > +       if (env->ops->get_func_proto)
> > +               result = env->ops->get_func_proto(func_id, env->prog);
> > +
> > +       if (!result)
> > +               return -EINVAL;
> 
> result is a bit unnecessary. We could do either
> 
> *ptr = NULL;
> if (env->ops->get_func_proto)
>     *ptr = env->ops->get_func_proto(func_id, env->prog);
> return *ptr ? 0 : -EINVAL;
> 
> 
> or just
> 
> if (!env->ops->get_func_proto)
>     return -EINVAL;
> 
> *ptr = env->ops->get_func_proto(func_id, env->prog);
> 
> return *ptr ? 0 : -EINVAL;

Ok, will change in v3.

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux