xref: /linux/tools/testing/selftests/bpf/progs/snprintf_btf_void.c (revision 1329a7aa33848c6f7e01eec9b9985086a44647d2)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "btf_ptr.h"
3 #include <bpf/bpf_helpers.h>
4 
5 __u32 type_id;
6 /* A buffer we own to render the selected type from, kept in bounds. */
7 char obj[256];
8 char out[64];
9 long ret;
10 
11 SEC("raw_tp/sys_enter")
12 int dump_type(void *ctx)
13 {
14 	struct btf_ptr ptr = {
15 		.ptr = obj,
16 		.type_id = type_id,
17 		.flags = 0,
18 	};
19 
20 	ret = bpf_snprintf_btf(out, sizeof(out), &ptr, sizeof(ptr), 0);
21 	return 0;
22 }
23 
24 char _license[] SEC("license") = "GPL";
25