]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
libbpf: Remove callback-based type/string BTF field visitor helpers
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 5 Jun 2024 00:16:29 +0000 (17:16 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 5 Jun 2024 14:54:45 +0000 (16:54 +0200)
Now that all libbpf/bpftool code switched to btf_field_iter, remove
btf_type_visit_type_ids() and btf_type_visit_str_offs() callback-based
helpers as not needed anymore.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20240605001629.4061937-6-andrii@kernel.org
tools/lib/bpf/btf.c
tools/lib/bpf/libbpf_internal.h

index 0190fd819f58b68abcb10af1bdeeac73281aef71..775ca55a541caadb053e8743954210d6eca5826f 100644 (file)
@@ -5035,136 +5035,6 @@ struct btf *btf__load_module_btf(const char *module_name, struct btf *vmlinux_bt
        return btf__parse_split(path, vmlinux_btf);
 }
 
-int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx)
-{
-       int i, n, err;
-
-       switch (btf_kind(t)) {
-       case BTF_KIND_INT:
-       case BTF_KIND_FLOAT:
-       case BTF_KIND_ENUM:
-       case BTF_KIND_ENUM64:
-               return 0;
-
-       case BTF_KIND_FWD:
-       case BTF_KIND_CONST:
-       case BTF_KIND_VOLATILE:
-       case BTF_KIND_RESTRICT:
-       case BTF_KIND_PTR:
-       case BTF_KIND_TYPEDEF:
-       case BTF_KIND_FUNC:
-       case BTF_KIND_VAR:
-       case BTF_KIND_DECL_TAG:
-       case BTF_KIND_TYPE_TAG:
-               return visit(&t->type, ctx);
-
-       case BTF_KIND_ARRAY: {
-               struct btf_array *a = btf_array(t);
-
-               err = visit(&a->type, ctx);
-               err = err ?: visit(&a->index_type, ctx);
-               return err;
-       }
-
-       case BTF_KIND_STRUCT:
-       case BTF_KIND_UNION: {
-               struct btf_member *m = btf_members(t);
-
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->type, ctx);
-                       if (err)
-                               return err;
-               }
-               return 0;
-       }
-
-       case BTF_KIND_FUNC_PROTO: {
-               struct btf_param *m = btf_params(t);
-
-               err = visit(&t->type, ctx);
-               if (err)
-                       return err;
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->type, ctx);
-                       if (err)
-                               return err;
-               }
-               return 0;
-       }
-
-       case BTF_KIND_DATASEC: {
-               struct btf_var_secinfo *m = btf_var_secinfos(t);
-
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->type, ctx);
-                       if (err)
-                               return err;
-               }
-               return 0;
-       }
-
-       default:
-               return -EINVAL;
-       }
-}
-
-int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx)
-{
-       int i, n, err;
-
-       err = visit(&t->name_off, ctx);
-       if (err)
-               return err;
-
-       switch (btf_kind(t)) {
-       case BTF_KIND_STRUCT:
-       case BTF_KIND_UNION: {
-               struct btf_member *m = btf_members(t);
-
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->name_off, ctx);
-                       if (err)
-                               return err;
-               }
-               break;
-       }
-       case BTF_KIND_ENUM: {
-               struct btf_enum *m = btf_enum(t);
-
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->name_off, ctx);
-                       if (err)
-                               return err;
-               }
-               break;
-       }
-       case BTF_KIND_ENUM64: {
-               struct btf_enum64 *m = btf_enum64(t);
-
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->name_off, ctx);
-                       if (err)
-                               return err;
-               }
-               break;
-       }
-       case BTF_KIND_FUNC_PROTO: {
-               struct btf_param *m = btf_params(t);
-
-               for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
-                       err = visit(&m->name_off, ctx);
-                       if (err)
-                               return err;
-               }
-               break;
-       }
-       default:
-               break;
-       }
-
-       return 0;
-}
-
 int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t, enum btf_field_iter_kind iter_kind)
 {
        it->p = NULL;
index 96c0b0993f8bc674eb798225781dc90238238bd2..e2f06609c6244aefca02ea97615577bcea19f992 100644 (file)
@@ -535,8 +535,6 @@ __u32 *btf_field_iter_next(struct btf_field_iter *it);
 
 typedef int (*type_id_visit_fn)(__u32 *type_id, void *ctx);
 typedef int (*str_off_visit_fn)(__u32 *str_off, void *ctx);
-int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx);
-int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx);
 int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx);
 int btf_ext_visit_str_offs(struct btf_ext *btf_ext, str_off_visit_fn visit, void *ctx);
 __s32 btf__find_by_name_kind_own(const struct btf *btf, const char *type_name,