Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Update btf_dump__new() uses to v1.0+ variant

Update to-be-deprecated forms of btf_dump__new().

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211111053624.190580-8-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Alexei Starovoitov
60ba87bb 0b52a5f4

+15 -26
+1 -3
tools/testing/selftests/bpf/btf_helpers.c
··· 238 238 static char buf[16 * 1024]; 239 239 FILE *buf_file; 240 240 struct btf_dump *d = NULL; 241 - struct btf_dump_opts opts = {}; 242 241 int err, i; 243 242 244 243 buf_file = fmemopen(buf, sizeof(buf) - 1, "w"); ··· 246 247 return NULL; 247 248 } 248 249 249 - opts.ctx = buf_file; 250 - d = btf_dump__new(btf, NULL, &opts, btf_dump_printf); 250 + d = btf_dump__new(btf, btf_dump_printf, buf_file, NULL); 251 251 if (libbpf_get_error(d)) { 252 252 fprintf(stderr, "Failed to create btf_dump instance: %ld\n", libbpf_get_error(d)); 253 253 goto err_out;
+13 -20
tools/testing/selftests/bpf/prog_tests/btf_dump.c
··· 13 13 const char *name; 14 14 const char *file; 15 15 bool known_ptr_sz; 16 - struct btf_dump_opts opts; 17 16 } btf_dump_test_cases[] = { 18 - {"btf_dump: syntax", "btf_dump_test_case_syntax", true, {}}, 19 - {"btf_dump: ordering", "btf_dump_test_case_ordering", false, {}}, 20 - {"btf_dump: padding", "btf_dump_test_case_padding", true, {}}, 21 - {"btf_dump: packing", "btf_dump_test_case_packing", true, {}}, 22 - {"btf_dump: bitfields", "btf_dump_test_case_bitfields", true, {}}, 23 - {"btf_dump: multidim", "btf_dump_test_case_multidim", false, {}}, 24 - {"btf_dump: namespacing", "btf_dump_test_case_namespacing", false, {}}, 17 + {"btf_dump: syntax", "btf_dump_test_case_syntax", true}, 18 + {"btf_dump: ordering", "btf_dump_test_case_ordering", false}, 19 + {"btf_dump: padding", "btf_dump_test_case_padding", true}, 20 + {"btf_dump: packing", "btf_dump_test_case_packing", true}, 21 + {"btf_dump: bitfields", "btf_dump_test_case_bitfields", true}, 22 + {"btf_dump: multidim", "btf_dump_test_case_multidim", false}, 23 + {"btf_dump: namespacing", "btf_dump_test_case_namespacing", false}, 25 24 }; 26 25 27 - static int btf_dump_all_types(const struct btf *btf, 28 - const struct btf_dump_opts *opts) 26 + static int btf_dump_all_types(const struct btf *btf, void *ctx) 29 27 { 30 28 size_t type_cnt = btf__type_cnt(btf); 31 29 struct btf_dump *d; 32 30 int err = 0, id; 33 31 34 - d = btf_dump__new(btf, NULL, opts, btf_dump_printf); 32 + d = btf_dump__new(btf, btf_dump_printf, ctx, NULL); 35 33 err = libbpf_get_error(d); 36 34 if (err) 37 35 return err; ··· 86 88 goto done; 87 89 } 88 90 89 - t->opts.ctx = f; 90 - err = btf_dump_all_types(btf, &t->opts); 91 + err = btf_dump_all_types(btf, f); 91 92 fclose(f); 92 93 close(fd); 93 94 if (CHECK(err, "btf_dump", "failure during C dumping: %d\n", err)) { ··· 134 137 { 135 138 struct btf *btf = NULL; 136 139 struct btf_dump *d = NULL; 137 - struct btf_dump_opts opts; 138 140 int id, err, i; 139 141 140 142 dump_buf_file = open_memstream(&dump_buf, &dump_buf_sz); ··· 142 146 btf = btf__new_empty(); 143 147 if (!ASSERT_OK_PTR(btf, "new_empty")) 144 148 goto err_out; 145 - opts.ctx = dump_buf_file; 146 - d = btf_dump__new(btf, NULL, &opts, btf_dump_printf); 149 + d = btf_dump__new(btf, btf_dump_printf, dump_buf_file, NULL); 147 150 if (!ASSERT_OK(libbpf_get_error(d), "btf_dump__new")) 148 151 goto err_out; 149 152 ··· 810 815 static void test_btf_dump_datasec_data(char *str) 811 816 { 812 817 struct btf *btf; 813 - struct btf_dump_opts opts = { .ctx = str }; 814 818 char license[4] = "GPL"; 815 819 struct btf_dump *d; 816 820 ··· 817 823 if (!ASSERT_OK_PTR(btf, "xdping_kern.o BTF not found")) 818 824 return; 819 825 820 - d = btf_dump__new(btf, NULL, &opts, btf_dump_snprintf); 826 + d = btf_dump__new(btf, btf_dump_snprintf, str, NULL); 821 827 if (!ASSERT_OK_PTR(d, "could not create BTF dump")) 822 828 goto out; 823 829 ··· 831 837 832 838 void test_btf_dump() { 833 839 char str[STRSIZE]; 834 - struct btf_dump_opts opts = { .ctx = str }; 835 840 struct btf_dump *d; 836 841 struct btf *btf; 837 842 int i; ··· 850 857 if (!ASSERT_OK_PTR(btf, "no kernel BTF found")) 851 858 return; 852 859 853 - d = btf_dump__new(btf, NULL, &opts, btf_dump_snprintf); 860 + d = btf_dump__new(btf, btf_dump_snprintf, str, NULL); 854 861 if (!ASSERT_OK_PTR(d, "could not create BTF dump")) 855 862 return; 856 863
+1 -3
tools/testing/selftests/bpf/prog_tests/btf_split.c
··· 13 13 } 14 14 15 15 void test_btf_split() { 16 - struct btf_dump_opts opts; 17 16 struct btf_dump *d = NULL; 18 17 const struct btf_type *t; 19 18 struct btf *btf1, *btf2; ··· 67 68 dump_buf_file = open_memstream(&dump_buf, &dump_buf_sz); 68 69 if (!ASSERT_OK_PTR(dump_buf_file, "dump_memstream")) 69 70 return; 70 - opts.ctx = dump_buf_file; 71 - d = btf_dump__new(btf2, NULL, &opts, btf_dump_printf); 71 + d = btf_dump__new(btf2, btf_dump_printf, dump_buf_file, NULL); 72 72 if (!ASSERT_OK_PTR(d, "btf_dump__new")) 73 73 goto cleanup; 74 74 for (i = 1; i < btf__type_cnt(btf2); i++) {