]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftest/bpf: Replace magic constants by macros
authorAnton Protopopov <aspsk@isovalent.com>
Fri, 13 Dec 2024 13:09:34 +0000 (13:09 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 13 Dec 2024 22:48:39 +0000 (14:48 -0800)
Replace magic constants in a BTF structure initialization code by
proper macros, as is done in other similar selftests.

Suggested-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Anton Protopopov <aspsk@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20241213130934.1087929-8-aspsk@isovalent.com
tools/testing/selftests/bpf/progs/syscall.c

index 0f4dfb770c326d2301dee5d32e91b483695e0668..b698cc62a3710db1c77a323244b4502d461ffc09 100644 (file)
@@ -76,9 +76,9 @@ static int btf_load(void)
                        .magic = BTF_MAGIC,
                        .version = BTF_VERSION,
                        .hdr_len = sizeof(struct btf_header),
-                       .type_len = sizeof(__u32) * 8,
-                       .str_off = sizeof(__u32) * 8,
-                       .str_len = sizeof(__u32),
+                       .type_len = sizeof(raw_btf.types),
+                       .str_off = offsetof(struct btf_blob, str) - offsetof(struct btf_blob, types),
+                       .str_len = sizeof(raw_btf.str),
                },
                .types = {
                        /* long */