bpftool: Make skeleton C code compilable with C++ compiler
authorAndrii Nakryiko <andriin@fb.com>
Thu, 26 Dec 2019 21:02:53 +0000 (13:02 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 27 Dec 2019 09:11:05 +0000 (10:11 +0100)
commit7c8dce4b166113743adad131b5a24c4acc12f92c
tree90b8cb27d1ec83d9086fac9b4d8fee846bfbc3d5
parent1162f844030ac1ac7321b5e8f6c9badc7a11428f
bpftool: Make skeleton C code compilable with C++ compiler

When auto-generated BPF skeleton C code is included from C++ application, it
triggers compilation error due to void * being implicitly casted to whatever
target pointer type. This is supported by C, but not C++. To solve this
problem, add explicit casts, where necessary.

To ensure issues like this are captured going forward, add skeleton usage in
test_cpp test.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191226210253.3132060-1-andriin@fb.com
tools/bpf/bpftool/gen.c
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/test_cpp.cpp