Re: [PATCH bpf-next 2/6] libbpf: rename btf__get_from_id() as btf__load_from_kernel_by_id()

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

 



On Wed, Jul 14, 2021 at 7:15 AM Quentin Monnet <quentin@xxxxxxxxxxxxx> wrote:
>
> Rename function btf__get_from_id() as btf__load_from_kernel_by_id() to
> better indicate what the function does.
>
> The other tools calling the deprecated btf__get_from_id() function will
> be updated in a future commit.
>
> References:
>
> - https://github.com/libbpf/libbpf/issues/278
> - https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#btfh-apis
>
> Signed-off-by: Quentin Monnet <quentin@xxxxxxxxxxxxx>
> ---
>  tools/lib/bpf/btf.c      | 4 +++-
>  tools/lib/bpf/btf.h      | 1 +
>  tools/lib/bpf/libbpf.c   | 2 +-
>  tools/lib/bpf/libbpf.map | 1 +
>  4 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 7e0de560490e..05b63b63083a 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -1383,7 +1383,7 @@ struct btf *btf_get_from_fd(int btf_fd, struct btf *base_btf)
>         return btf;
>  }
>
> -int btf__get_from_id(__u32 id, struct btf **btf)
> +int btf__load_from_kernel_by_id(__u32 id, struct btf **btf)

we can't change existing btf__get_from_id(), but for the new
btf__load_from_kernel_by_id() let's keep them in line with other BTF
"constructor" APIs (btf__new and btf__parse) and return resulting
struct btf, instead of passing it in output argument. With the new
libbpf error reporting strategy (NULL on error + errno for those who
care about specific error code), it has a better usability and will
just be more consistent.

>  {
>         struct btf *res;
>         int err, btf_fd;



[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