From c0cf45c77c8ff72b141605a0d7ec79d2cd577ee8 Mon Sep 17 00:00:00 2001 From: Kui-Feng Lee Date: Wed, 26 Jan 2022 11:20:39 -0800 Subject: [PATCH] libbpf: Update libbpf to the latest git HEAD Replace deprecated APIs with new ones. Signed-off-by: Kui-Feng Lee Acked-by: Andrii Nakryiko Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: bpf@vger.kernel.org Cc: dwarves@vger.kernel.org Link: https://lore.kernel.org/r/20220126192039.2840752-5-kuifeng@fb.com Signed-off-by: Arnaldo Carvalho de Melo --- Upstream commit 73383b3a39afe86b22e098773e47b8546c48a649 not strictly required but fixes incompatibilities when building with libbpf 0.7.0 btf_encoder.c | 20 ++++++++++---------- btf_loader.c | 2 +- lib/bpf | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/btf_encoder.c b/btf_encoder.c index 9d015f304e92..4aa003b6aa54 100644 --- a/btf_encoder.c +++ b/btf_encoder.c @@ -172,7 +172,7 @@ __attribute ((format (printf, 5, 6))) static void btf__log_err(const struct btf *btf, int kind, const char *name, bool output_cr, const char *fmt, ...) { - fprintf(stderr, "[%u] %s %s", btf__get_nr_types(btf) + 1, + fprintf(stderr, "[%u] %s %s", btf__type_cnt(btf), btf_kind_str[kind], name ?: "(anon)"); if (fmt && *fmt) { @@ -203,7 +203,7 @@ static void btf_encoder__log_type(const struct btf_encoder *encoder, const struc out = err ? stderr : stdout; fprintf(out, "[%u] %s %s", - btf__get_nr_types(btf), btf_kind_str[kind], + btf__type_cnt(btf) - 1, btf_kind_str[kind], btf__printable_name(btf, t->name_off)); if (fmt && *fmt) { @@ -449,10 +449,10 @@ static int btf_encoder__add_field(struct btf_encoder *encoder, const char *name, int err; err = btf__add_field(btf, name, type, offset, bitfield_size); - t = btf__type_by_id(btf, btf__get_nr_types(btf)); + t = btf__type_by_id(btf, btf__type_cnt(btf) - 1); if (err) { fprintf(stderr, "[%u] %s %s's field '%s' offset=%u bit_size=%u type=%u Error emitting field\n", - btf__get_nr_types(btf), btf_kind_str[btf_kind(t)], + btf__type_cnt(btf) - 1, btf_kind_str[btf_kind(t)], btf__printable_name(btf, t->name_off), name, offset, bitfield_size, type); } else { @@ -899,9 +899,9 @@ static int btf_encoder__write_raw_file(struct btf_encoder *encoder) const void *raw_btf_data; int fd, err; - raw_btf_data = btf__get_raw_data(encoder->btf, &raw_btf_size); + raw_btf_data = btf__raw_data(encoder->btf, &raw_btf_size); if (raw_btf_data == NULL) { - fprintf(stderr, "%s: btf__get_raw_data failed!\n", __func__); + fprintf(stderr, "%s: btf__raw_data failed!\n", __func__); return -1; } @@ -976,7 +976,7 @@ static int btf_encoder__write_elf(struct btf_encoder *encoder) } } - raw_btf_data = btf__get_raw_data(btf, &raw_btf_size); + raw_btf_data = btf__raw_data(btf, &raw_btf_size); if (btf_data) { /* Existing .BTF section found */ @@ -1043,10 +1043,10 @@ int btf_encoder__encode(struct btf_encoder *encoder) btf_encoder__add_datasec(encoder, PERCPU_SECTION); /* Empty file, nothing to do, so... done! */ - if (btf__get_nr_types(encoder->btf) == 0) + if (btf__type_cnt(encoder->btf) == 1) return 0; - if (btf__dedup(encoder->btf, NULL, NULL)) { + if (btf__dedup(encoder->btf, NULL)) { fprintf(stderr, "%s: btf__dedup failed!\n", __func__); return -1; } @@ -1403,7 +1403,7 @@ void btf_encoder__delete(struct btf_encoder *encoder) int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu) { - uint32_t type_id_off = btf__get_nr_types(encoder->btf); + uint32_t type_id_off = btf__type_cnt(encoder->btf) - 1; struct llvm_annotation *annot; int btf_type_id, tag_type_id; uint32_t core_id; diff --git a/btf_loader.c b/btf_loader.c index 7a5b16ff393e..c7d69ccea4d3 100644 --- a/btf_loader.c +++ b/btf_loader.c @@ -399,7 +399,7 @@ static int btf__load_types(struct btf *btf, struct cu *cu) uint32_t type_index; int err; - for (type_index = 1; type_index <= btf__get_nr_types(btf); type_index++) { + for (type_index = 1; type_index < btf__type_cnt(btf); type_index++) { const struct btf_type *type_ptr = btf__type_by_id(btf, type_index); uint32_t type = btf_kind(type_ptr); -- 2.35.1