Re: [PATCH v3 bpf-next 5/6] selftests/bpf: Fix up __u16 vlen assumptions

Mykyta Yatsenko
2026-04-17T19:06:10Z

On 4/17/26 3:30 PM, Alan Maguire wrote:
> Fix up a few cases where we assume vlen is 16 bits.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---

Acked-by: Mykyta Yatsenko <yatsenko@meta.com>

> tools/testing/selftests/bpf/prog_tests/btf.c | 2 +-
> tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c | 3 +--
> tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c | 3 +--
> tools/testing/selftests/bpf/test_progs.c | 2 +-
> 4 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
> index 0cc347e32db3..a9de328a8697 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf.c
> @@ -8092,7 +8092,7 @@ static struct btf_dedup_test dedup_tests[] = {
> static int btf_type_size(const struct btf_type *t)
> {
> int base_size = sizeof(struct btf_type);
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> + __u32 vlen = BTF_INFO_VLEN(t->info);
> __u16 kind = BTF_INFO_KIND(t->info);
>
> switch (kind) {
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> index 5bc15bb6b7ce..6bc31236805c 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> @@ -487,9 +487,8 @@ static void test_split_module(void)
> for (i = 0; i < ARRAY_SIZE(mod_funcs); i++) {
> const struct btf_param *p;
> const struct btf_type *t;
> - __u16 vlen;
> + __u32 vlen, j;
> __u32 id;
> - int j;
>
> id = btf__find_by_name_kind(btf1, mod_funcs[i], BTF_KIND_FUNC);
> if (!ASSERT_GE(id, nr_base_types, "func_id"))
> diff --git a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
> index 469e92869523..5064aeb8fe67 100644
> --- a/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
> +++ b/tools/testing/selftests/bpf/prog_tests/ctx_rewrite.c
> @@ -253,8 +253,7 @@ static int find_field_offset_aux(struct btf *btf, int btf_id, char *field_name,
> {
> const struct btf_type *type = btf__type_by_id(btf, btf_id);
> const struct btf_member *m;
> - __u16 mnum;
> - int i;
> + __u32 mnum, i;
>
> if (!type) {
> PRINT_FAIL("Can't find btf_type for id %d\n", btf_id);
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index 7fe16b5131b1..cc14b13e23fe 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -1257,7 +1257,7 @@ int get_bpf_max_tramp_links_from(struct btf *btf)
> const struct btf_type *t;
> __u32 i, type_cnt;
> const char *name;
> - __u16 j, vlen;
> + __u32 j, vlen;
>
> for (i = 1, type_cnt = btf__type_cnt(btf); i < type_cnt; i++) {
> t = btf__type_by_id(btf, i);