Re: [PATCH bpf-next 08/15] libbpf: Refactor bpf_object__resolve_ksyms_btf_id

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

 



On Tue, Mar 16, 2021 at 12:02 AM Martin KaFai Lau <kafai@xxxxxx> wrote:
>
> This patch refactors most of the logic from
> bpf_object__resolve_ksyms_btf_id() into a new function
> bpf_object__resolve_ksym_var_btf_id().
> It is to get ready for a later patch adding
> bpf_object__resolve_ksym_func_btf_id() which resolves
> a kernel function to the running kernel btf_id.
>
> Signed-off-by: Martin KaFai Lau <kafai@xxxxxx>
> ---

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

>  tools/lib/bpf/libbpf.c | 125 ++++++++++++++++++++++-------------------
>  1 file changed, 68 insertions(+), 57 deletions(-)
>

[...]

> +static int bpf_object__resolve_ksyms_btf_id(struct bpf_object *obj)
> +{
> +       struct extern_desc *ext;
> +       int i, err;
> +
> +       for (i = 0; i < obj->nr_extern; i++) {
> +               ext = &obj->externs[i];
> +               if (ext->type != EXT_KSYM || !ext->ksym.type_id)
> +                       continue;
> +
> +               err = bpf_object__resolve_ksym_var_btf_id(obj, ext);
>

we usually put error checking right on the next line without empty
lines, please remove this distracting empty line


> -               ext->is_set = true;
> -               ext->ksym.kernel_btf_obj_fd = btf_fd;
> -               ext->ksym.kernel_btf_id = id;
> -               pr_debug("extern (ksym) '%s': resolved to [%d] %s %s\n",
> -                        ext->name, id, btf_kind_str(targ_var), targ_var_name);
> +               if (err)
> +                       return err;
>         }
>         return 0;
>  }
> --
> 2.30.2
>



[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