> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 83fe79ffc..64502b3ef 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
[ ... ]
> +int btf__find_by_glob_kind(const struct btf *btf, __u32 kind,
> + const char *allow_pattern, const char *deny_pattern,
> + __u32 **__ids)
> +{
> + __u32 i, nr_types = btf__type_cnt(btf);
> + int cnt = 0, alloc = 0;
> + __u32 *ids = NULL;
> +
> + for (i = 1; i < nr_types; i++) {
> + const struct btf_type *t = btf__type_by_id(btf, i);
> + const char *name;
> + __u32 *p;
> +
> + if (btf_kind(t) != kind)
> + continue;
> + name = btf__name_by_offset(btf, t->name_off);
> + if (!name)
> + continue;
> +
> + if (deny_pattern && glob_match(name, deny_pattern))
> + continue;
> + if (allow_pattern && !glob_match(name, allow_pattern))
> + continue;
> +
> + if (cnt == alloc) {
> + alloc = max(16, alloc * 3 / 2);
> + p = libbpf_reallocarray(ids, alloc, sizeof(__u32));
> + if (!p) {
> + free(ids);
> + return -ENOMEM;
Should this use libbpf_err(-ENOMEM) to set errno for userspace callers?
Other similar functions in btf.c like btf_find_by_name_kind() use
libbpf_err() for their error returns:
return libbpf_err(-ENOENT);
> + }
> + ids = p;
> + }
> + ids[cnt] = i;
> + cnt++;
> + }
> +
> + *__ids = ids;
> + return cnt;
> +}
> diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> index b30008c26..d7b47bb0b 100644
> --- a/tools/lib/bpf/btf.h
> +++ b/tools/lib/bpf/btf.h
[ ... ]
> +int btf__find_by_glob_kind(const struct btf *btf, __u32 kind,
> + const char *allow_pattern, const char *deny_pattern,
> + __u32 **__ids);
Is this intended to be a public API? The btf__ prefix and placement in btf.h
suggest it should be public, but it is missing:
1) The LIBBPF_API macro that all other btf__* functions in this header have,
for example:
LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf,
const char *type_name, __u32 kind);
2) An entry in libbpf.map to export the symbol from the shared library.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21625440628
AI-authorship-score: low
AI-authorship-explanation: The code and commit message follow established
kernel and libbpf conventions without telltale signs of AI generation, and Jiri
Olsa is a well-known BPF kernel maintainer.
issues-found: 2
issue-severity-score: low
issue-severity-explanation: Missing libbpf_err wrapper and incomplete public
API declaration are API consistency issues that do not cause crashes or
security problems.