Skip to content

Commit 0720887

Browse files
anakryikoborkmann
authored andcommitted
libbpf: Remove callback-based type/string BTF field visitor helpers
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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Tested-by: Alan Maguire <[email protected]> Acked-by: Eduard Zingerman <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent e1a8630 commit 0720887

File tree

2 files changed

+0
-132
lines changed

2 files changed

+0
-132
lines changed

tools/lib/bpf/btf.c

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,136 +5035,6 @@ struct btf *btf__load_module_btf(const char *module_name, struct btf *vmlinux_bt
50355035
return btf__parse_split(path, vmlinux_btf);
50365036
}
50375037

5038-
int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx)
5039-
{
5040-
int i, n, err;
5041-
5042-
switch (btf_kind(t)) {
5043-
case BTF_KIND_INT:
5044-
case BTF_KIND_FLOAT:
5045-
case BTF_KIND_ENUM:
5046-
case BTF_KIND_ENUM64:
5047-
return 0;
5048-
5049-
case BTF_KIND_FWD:
5050-
case BTF_KIND_CONST:
5051-
case BTF_KIND_VOLATILE:
5052-
case BTF_KIND_RESTRICT:
5053-
case BTF_KIND_PTR:
5054-
case BTF_KIND_TYPEDEF:
5055-
case BTF_KIND_FUNC:
5056-
case BTF_KIND_VAR:
5057-
case BTF_KIND_DECL_TAG:
5058-
case BTF_KIND_TYPE_TAG:
5059-
return visit(&t->type, ctx);
5060-
5061-
case BTF_KIND_ARRAY: {
5062-
struct btf_array *a = btf_array(t);
5063-
5064-
err = visit(&a->type, ctx);
5065-
err = err ?: visit(&a->index_type, ctx);
5066-
return err;
5067-
}
5068-
5069-
case BTF_KIND_STRUCT:
5070-
case BTF_KIND_UNION: {
5071-
struct btf_member *m = btf_members(t);
5072-
5073-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5074-
err = visit(&m->type, ctx);
5075-
if (err)
5076-
return err;
5077-
}
5078-
return 0;
5079-
}
5080-
5081-
case BTF_KIND_FUNC_PROTO: {
5082-
struct btf_param *m = btf_params(t);
5083-
5084-
err = visit(&t->type, ctx);
5085-
if (err)
5086-
return err;
5087-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5088-
err = visit(&m->type, ctx);
5089-
if (err)
5090-
return err;
5091-
}
5092-
return 0;
5093-
}
5094-
5095-
case BTF_KIND_DATASEC: {
5096-
struct btf_var_secinfo *m = btf_var_secinfos(t);
5097-
5098-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5099-
err = visit(&m->type, ctx);
5100-
if (err)
5101-
return err;
5102-
}
5103-
return 0;
5104-
}
5105-
5106-
default:
5107-
return -EINVAL;
5108-
}
5109-
}
5110-
5111-
int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx)
5112-
{
5113-
int i, n, err;
5114-
5115-
err = visit(&t->name_off, ctx);
5116-
if (err)
5117-
return err;
5118-
5119-
switch (btf_kind(t)) {
5120-
case BTF_KIND_STRUCT:
5121-
case BTF_KIND_UNION: {
5122-
struct btf_member *m = btf_members(t);
5123-
5124-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5125-
err = visit(&m->name_off, ctx);
5126-
if (err)
5127-
return err;
5128-
}
5129-
break;
5130-
}
5131-
case BTF_KIND_ENUM: {
5132-
struct btf_enum *m = btf_enum(t);
5133-
5134-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5135-
err = visit(&m->name_off, ctx);
5136-
if (err)
5137-
return err;
5138-
}
5139-
break;
5140-
}
5141-
case BTF_KIND_ENUM64: {
5142-
struct btf_enum64 *m = btf_enum64(t);
5143-
5144-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5145-
err = visit(&m->name_off, ctx);
5146-
if (err)
5147-
return err;
5148-
}
5149-
break;
5150-
}
5151-
case BTF_KIND_FUNC_PROTO: {
5152-
struct btf_param *m = btf_params(t);
5153-
5154-
for (i = 0, n = btf_vlen(t); i < n; i++, m++) {
5155-
err = visit(&m->name_off, ctx);
5156-
if (err)
5157-
return err;
5158-
}
5159-
break;
5160-
}
5161-
default:
5162-
break;
5163-
}
5164-
5165-
return 0;
5166-
}
5167-
51685038
int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t, enum btf_field_iter_kind iter_kind)
51695039
{
51705040
it->p = NULL;

tools/lib/bpf/libbpf_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,6 @@ __u32 *btf_field_iter_next(struct btf_field_iter *it);
535535

536536
typedef int (*type_id_visit_fn)(__u32 *type_id, void *ctx);
537537
typedef int (*str_off_visit_fn)(__u32 *str_off, void *ctx);
538-
int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx);
539-
int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx);
540538
int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx);
541539
int btf_ext_visit_str_offs(struct btf_ext *btf_ext, str_off_visit_fn visit, void *ctx);
542540
__s32 btf__find_by_name_kind_own(const struct btf *btf, const char *type_name,

0 commit comments

Comments
 (0)