Thread (13 messages) 13 messages, 3 authors, 2021-07-21

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

From: Andrii Nakryiko <hidden>
Date: 2021-07-16 04:36:04
Also in: bpf

On Wed, Jul 14, 2021 at 7:15 AM Quentin Monnet [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 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;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help