linux/tools/lib
Xu Kuohai 4226961b00 libbpf: Skip forward declaration when counting duplicated type names
Currently if a declaration appears in the BTF before the definition, the
definition is dumped as a conflicting name, e.g.:

    $ bpftool btf dump file vmlinux format raw | grep "'unix_sock'"
    [81287] FWD 'unix_sock' fwd_kind=struct
    [89336] STRUCT 'unix_sock' size=1024 vlen=14

    $ bpftool btf dump file vmlinux format c | grep "struct unix_sock"
    struct unix_sock;
    struct unix_sock___2 {	<--- conflict, the "___2" is unexpected
		    struct unix_sock___2 *unix_sk;

This causes a compilation error if the dump output is used as a header file.

Fix it by skipping declaration when counting duplicated type names.

Fixes: 351131b51c ("libbpf: add btf_dump API for BTF-to-C conversion")
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20220301053250.1464204-2-xukuohai@huawei.com
2022-03-01 13:40:57 +01:00
..
api
bpf libbpf: Skip forward declaration when counting duplicated type names 2022-03-01 13:40:57 +01:00
perf libperf: Fix perf_cpu_map__for_each_cpu macro 2022-02-16 13:49:25 -03:00
subcmd libsubcmd: Fix use-after-free for realloc(..., 0) 2022-02-16 13:49:25 -03:00
symbol
traceevent
argv_split.c
bitmap.c
ctype.c
find_bit.c
hweight.c
list_sort.c
rbtree.c
str_error_r.c
string.c
vsprintf.c
zalloc.c