bpftool: Switch to new btf__type_cnt API
Replace the call to btf__get_nr_types with new API btf__type_cnt. The old API will be deprecated in libbpf v0.7+. No functionality change. Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211022130623.1548429-5-hengqi.chen@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
2d8f09fafc
commit
58fc155b0e
@@ -329,7 +329,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
|
||||
printf("\n\ttype_id=%u offset=%u size=%u",
|
||||
v->type, v->offset, v->size);
|
||||
|
||||
if (v->type <= btf__get_nr_types(btf)) {
|
||||
if (v->type < btf__type_cnt(btf)) {
|
||||
vt = btf__type_by_id(btf, v->type);
|
||||
printf(" (%s '%s')",
|
||||
btf_kind_str[btf_kind_safe(btf_kind(vt))],
|
||||
@@ -390,14 +390,14 @@ static int dump_btf_raw(const struct btf *btf,
|
||||
}
|
||||
} else {
|
||||
const struct btf *base;
|
||||
int cnt = btf__get_nr_types(btf);
|
||||
int cnt = btf__type_cnt(btf);
|
||||
int start_id = 1;
|
||||
|
||||
base = btf__base_btf(btf);
|
||||
if (base)
|
||||
start_id = btf__get_nr_types(base) + 1;
|
||||
start_id = btf__type_cnt(base);
|
||||
|
||||
for (i = start_id; i <= cnt; i++) {
|
||||
for (i = start_id; i < cnt; i++) {
|
||||
t = btf__type_by_id(btf, i);
|
||||
dump_btf_type(btf, i, t);
|
||||
}
|
||||
@@ -440,9 +440,9 @@ static int dump_btf_c(const struct btf *btf,
|
||||
goto done;
|
||||
}
|
||||
} else {
|
||||
int cnt = btf__get_nr_types(btf);
|
||||
int cnt = btf__type_cnt(btf);
|
||||
|
||||
for (i = 1; i <= cnt; i++) {
|
||||
for (i = 1; i < cnt; i++) {
|
||||
err = btf_dump__dump_type(d, i);
|
||||
if (err)
|
||||
goto done;
|
||||
|
||||
Reference in New Issue
Block a user