All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v1] libbpf: fix build failure from uninitialized variable warning
@ 2020-08-31  0:03 Tony Ambardar
  2020-08-31 14:59 ` Daniel Borkmann
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Ambardar @ 2020-08-31  0:03 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Tony Ambardar, Andrii Nakryiko, netdev, bpf

While compiling libbpf, some GCC versions (at least 8.4.0) have difficulty
determining control flow and a emit warning for potentially uninitialized
usage of 'map', which results in a build error if using "-Werror":

In file included from libbpf.c:56:
libbpf.c: In function '__bpf_object__open':
libbpf_internal.h:59:2: warning: 'map' may be used uninitialized in this function [-Wmaybe-uninitialized]
  libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
  ^~~~~~~~~~~~
libbpf.c:5032:18: note: 'map' was declared here
  struct bpf_map *map, *targ_map;
                  ^~~

The warning/error is false based on code inspection, so silence it with a
NULL initialization.

Fixes: 646f02ffdd49 ("libbpf: Add BTF-defined map-in-map support")
Ref: 063e68813391 ("libbpf: Fix false uninitialized variable warning")

Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.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 b688aadf09c5..46d727b45c81 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -5804,8 +5804,8 @@ static int bpf_object__collect_map_relos(struct bpf_object *obj,
 	int i, j, nrels, new_sz;
 	const struct btf_var_secinfo *vi = NULL;
 	const struct btf_type *sec, *var, *def;
+	struct bpf_map *map = NULL, *targ_map;
 	const struct btf_member *member;
-	struct bpf_map *map, *targ_map;
 	const char *name, *mname;
 	Elf_Data *symbols;
 	unsigned int moff;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf v1] libbpf: fix build failure from uninitialized variable warning
  2020-08-31  0:03 [PATCH bpf v1] libbpf: fix build failure from uninitialized variable warning Tony Ambardar
@ 2020-08-31 14:59 ` Daniel Borkmann
  2020-09-02  7:39   ` Tony Ambardar
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2020-08-31 14:59 UTC (permalink / raw)
  To: Tony Ambardar, Alexei Starovoitov; +Cc: Andrii Nakryiko, netdev, bpf

On 8/31/20 2:03 AM, Tony Ambardar wrote:
> While compiling libbpf, some GCC versions (at least 8.4.0) have difficulty
> determining control flow and a emit warning for potentially uninitialized
> usage of 'map', which results in a build error if using "-Werror":
> 
> In file included from libbpf.c:56:
> libbpf.c: In function '__bpf_object__open':
> libbpf_internal.h:59:2: warning: 'map' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
>    ^~~~~~~~~~~~
> libbpf.c:5032:18: note: 'map' was declared here
>    struct bpf_map *map, *targ_map;
>                    ^~~
> 
> The warning/error is false based on code inspection, so silence it with a
> NULL initialization.
> 
> Fixes: 646f02ffdd49 ("libbpf: Add BTF-defined map-in-map support")
> Ref: 063e68813391 ("libbpf: Fix false uninitialized variable warning")
> 
> Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf v1] libbpf: fix build failure from uninitialized variable warning
  2020-08-31 14:59 ` Daniel Borkmann
@ 2020-09-02  7:39   ` Tony Ambardar
  0 siblings, 0 replies; 3+ messages in thread
From: Tony Ambardar @ 2020-09-02  7:39 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: Alexei Starovoitov, Andrii Nakryiko, netdev, bpf

On Mon, 31 Aug 2020 at 07:59, Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 8/31/20 2:03 AM, Tony Ambardar wrote:
> > While compiling libbpf, some GCC versions (at least 8.4.0) have difficulty
> > determining control flow and a emit warning for potentially uninitialized
> > usage of 'map', which results in a build error if using "-Werror":
> >
> > In file included from libbpf.c:56:
> > libbpf.c: In function '__bpf_object__open':
> > libbpf_internal.h:59:2: warning: 'map' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >    libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__); \
> >    ^~~~~~~~~~~~
> > libbpf.c:5032:18: note: 'map' was declared here
> >    struct bpf_map *map, *targ_map;
> >                    ^~~
> >
> > The warning/error is false based on code inspection, so silence it with a
> > NULL initialization.
> >
> > Fixes: 646f02ffdd49 ("libbpf: Add BTF-defined map-in-map support")
> > Ref: 063e68813391 ("libbpf: Fix false uninitialized variable warning")
> >
> > Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
>
> Applied, thanks!

Thanks, Daniel. I forgot to ask/confirm whether this will get applied
to the 5.8.x stable branch, since it was first encountered there.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-02  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31  0:03 [PATCH bpf v1] libbpf: fix build failure from uninitialized variable warning Tony Ambardar
2020-08-31 14:59 ` Daniel Borkmann
2020-09-02  7:39   ` Tony Ambardar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.