]> git.itanic.dy.fi Git - linux-stable/commitdiff
selftests/bpf: Test btf dump for struct with padding only fields
authorEduard Zingerman <eddyz87@gmail.com>
Sat, 1 Oct 2022 10:44:25 +0000 (13:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Apr 2023 09:23:52 +0000 (11:23 +0200)
[ Upstream commit d503f1176b14f722a40ea5110312614982f9a80b ]

Structures with zero regular fields but some padding constitute a
special case in btf_dump.c:btf_dump_emit_struct_def with regards to
newline before closing '}'.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221001104425.415768-2-eddyz87@gmail.com
Stable-dep-of: ea2ce1ba99aa ("libbpf: Fix BTF-to-C converter's padding logic")
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/progs/btf_dump_test_case_padding.c

index 35c512818a56b8928a4337208ae3ac28ea962d2d..db5458da618266da3bb34d8054eb3e8b8c53264c 100644 (file)
@@ -102,12 +102,21 @@ struct zone {
        struct zone_padding __pad__;
 };
 
+/* ----- START-EXPECTED-OUTPUT ----- */
+struct padding_wo_named_members {
+       long: 64;
+       long: 64;
+};
+
+/* ------ END-EXPECTED-OUTPUT ------ */
+
 int f(struct {
        struct padded_implicitly _1;
        struct padded_explicitly _2;
        struct padded_a_lot _3;
        struct padded_cache_line _4;
        struct zone _5;
+       struct padding_wo_named_members _6;
 } *_)
 {
        return 0;