]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Remove any use of reallocarray() in libbpf
authorAndrii Nakryiko <andriin@fb.com>
Wed, 19 Aug 2020 01:36:04 +0000 (18:36 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 19 Aug 2020 01:38:25 +0000 (18:38 -0700)
commite535fbd01ef4cb62b7107354d3c4533479163b60
tree15b1b7ecf8e298c62341d0d81578763d69216511
parentc6e3fd140eb61b6ad26c0132cfec33a054fc43df
libbpf: Remove any use of reallocarray() in libbpf

Re-implement glibc's reallocarray() for libbpf internal-only use.
reallocarray(), unfortunately, is not available in all versions of glibc, so
requires extra feature detection and using reallocarray() stub from
<tools/libc_compat.h> and COMPAT_NEED_REALLOCARRAY. All this complicates build
of libbpf unnecessarily and is just a maintenance burden. Instead, it's
trivial to implement libbpf-specific internal version and use it throughout
libbpf.

Which is what this patch does, along with converting some realloc() uses that
should really have been reallocarray() in the first place.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200819013607.3607269-2-andriin@fb.com
tools/lib/bpf/Makefile
tools/lib/bpf/btf.c
tools/lib/bpf/btf_dump.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h
tools/lib/bpf/ringbuf.c