* [PATCH bpf-next] libbpf: Fix build with gcc-8
@ 2019-04-11 1:36 Andrey Ignatov
2019-04-11 4:20 ` Yonghong Song
2019-04-11 7:45 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Andrey Ignatov @ 2019-04-11 1:36 UTC (permalink / raw)
To: netdev; +Cc: Andrey Ignatov, ast, daniel, kernel-team
Reported in [1].
With gcc 8.3.0 the following error is issued:
cc -Ibpf@sta -I. -I.. -I.././include -I.././include/uapi
-fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer
-pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -g -fPIC -g -O2
-Werror -Wall -Wno-pointer-arith -Wno-sign-compare -MD -MQ
'bpf@sta/src_libbpf.c.o' -MF 'bpf@sta/src_libbpf.c.o.d' -o
'bpf@sta/src_libbpf.c.o' -c ../src/libbpf.c
../src/libbpf.c: In function 'bpf_object__elf_collect':
../src/libbpf.c:947:18: error: 'map_def_sz' may be used uninitialized in this
function [-Werror=maybe-uninitialized]
if (map_def_sz <= sizeof(struct bpf_map_def)) {
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/libbpf.c:827:18: note: 'map_def_sz' was declared here
int i, map_idx, map_def_sz, nr_syms, nr_maps = 0, nr_maps_glob = 0;
^~~~~~~~~~
According to [2] -Wmaybe-uninitialized is enabled by -Wall.
Same error is generated by clang's -Wconditional-uninitialized.
[1] https://github.com/libbpf/libbpf/pull/29#issuecomment-481902601
[2] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
Fixes: d859900c4c56 ("bpf, libbpf: support global data/bss/rodata sections")
Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
Signed-off-by: Andrey Ignatov <rdna@fb.com>
---
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index e2a457e7c318..67484cf32b2e 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -824,7 +824,7 @@ bpf_object__init_internal_map(struct bpf_object *obj, struct bpf_map *map,
static int
bpf_object__init_maps(struct bpf_object *obj, int flags)
{
- int i, map_idx, map_def_sz, nr_syms, nr_maps = 0, nr_maps_glob = 0;
+ int i, map_idx, map_def_sz = 0, nr_syms, nr_maps = 0, nr_maps_glob = 0;
bool strict = !(flags & MAPS_RELAX_COMPAT);
Elf_Data *symbols = obj->efile.symbols;
Elf_Data *data = NULL;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: Fix build with gcc-8
2019-04-11 1:36 [PATCH bpf-next] libbpf: Fix build with gcc-8 Andrey Ignatov
@ 2019-04-11 4:20 ` Yonghong Song
2019-04-11 7:45 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2019-04-11 4:20 UTC (permalink / raw)
To: Andrey Ignatov, netdev@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, Kernel Team
On 4/10/19 6:36 PM, Andrey Ignatov wrote:
> Reported in [1].
>
> With gcc 8.3.0 the following error is issued:
>
> cc -Ibpf@sta -I. -I.. -I.././include -I.././include/uapi
> -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer
> -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -g -fPIC -g -O2
> -Werror -Wall -Wno-pointer-arith -Wno-sign-compare -MD -MQ
> 'bpf@sta/src_libbpf.c.o' -MF 'bpf@sta/src_libbpf.c.o.d' -o
> 'bpf@sta/src_libbpf.c.o' -c ../src/libbpf.c
> ../src/libbpf.c: In function 'bpf_object__elf_collect':
> ../src/libbpf.c:947:18: error: 'map_def_sz' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> if (map_def_sz <= sizeof(struct bpf_map_def)) {
> ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../src/libbpf.c:827:18: note: 'map_def_sz' was declared here
> int i, map_idx, map_def_sz, nr_syms, nr_maps = 0, nr_maps_glob = 0;
> ^~~~~~~~~~
>
> According to [2] -Wmaybe-uninitialized is enabled by -Wall.
> Same error is generated by clang's -Wconditional-uninitialized.
>
> [1] https://github.com/libbpf/libbpf/pull/29#issuecomment-481902601
> [2] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
>
> Fixes: d859900c4c56 ("bpf, libbpf: support global data/bss/rodata sections")
> Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
> Signed-off-by: Andrey Ignatov <rdna@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> tools/lib/bpf/libbpf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index e2a457e7c318..67484cf32b2e 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -824,7 +824,7 @@ bpf_object__init_internal_map(struct bpf_object *obj, struct bpf_map *map,
> static int
> bpf_object__init_maps(struct bpf_object *obj, int flags)
> {
> - int i, map_idx, map_def_sz, nr_syms, nr_maps = 0, nr_maps_glob = 0;
> + int i, map_idx, map_def_sz = 0, nr_syms, nr_maps = 0, nr_maps_glob = 0;
> bool strict = !(flags & MAPS_RELAX_COMPAT);
> Elf_Data *symbols = obj->efile.symbols;
> Elf_Data *data = NULL;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: Fix build with gcc-8
2019-04-11 1:36 [PATCH bpf-next] libbpf: Fix build with gcc-8 Andrey Ignatov
2019-04-11 4:20 ` Yonghong Song
@ 2019-04-11 7:45 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-04-11 7:45 UTC (permalink / raw)
To: Andrey Ignatov, netdev; +Cc: ast, kernel-team
On 04/11/2019 03:36 AM, Andrey Ignatov wrote:
> Reported in [1].
>
> With gcc 8.3.0 the following error is issued:
>
> cc -Ibpf@sta -I. -I.. -I.././include -I.././include/uapi
> -fdiagnostics-color=always -fsanitize=address,undefined -fno-omit-frame-pointer
> -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -g -fPIC -g -O2
> -Werror -Wall -Wno-pointer-arith -Wno-sign-compare -MD -MQ
> 'bpf@sta/src_libbpf.c.o' -MF 'bpf@sta/src_libbpf.c.o.d' -o
> 'bpf@sta/src_libbpf.c.o' -c ../src/libbpf.c
> ../src/libbpf.c: In function 'bpf_object__elf_collect':
> ../src/libbpf.c:947:18: error: 'map_def_sz' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> if (map_def_sz <= sizeof(struct bpf_map_def)) {
> ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../src/libbpf.c:827:18: note: 'map_def_sz' was declared here
> int i, map_idx, map_def_sz, nr_syms, nr_maps = 0, nr_maps_glob = 0;
> ^~~~~~~~~~
>
> According to [2] -Wmaybe-uninitialized is enabled by -Wall.
> Same error is generated by clang's -Wconditional-uninitialized.
>
> [1] https://github.com/libbpf/libbpf/pull/29#issuecomment-481902601
> [2] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
>
> Fixes: d859900c4c56 ("bpf, libbpf: support global data/bss/rodata sections")
> Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
> Signed-off-by: Andrey Ignatov <rdna@fb.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-11 7:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-11 1:36 [PATCH bpf-next] libbpf: Fix build with gcc-8 Andrey Ignatov
2019-04-11 4:20 ` Yonghong Song
2019-04-11 7:45 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).