All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning
@ 2018-11-09 18:18 Joe Stringer
  2018-11-12 23:51 ` Martin Lau
  2018-11-17  1:44 ` Alexei Starovoitov
  0 siblings, 2 replies; 3+ messages in thread
From: Joe Stringer @ 2018-11-09 18:18 UTC (permalink / raw)
  To: daniel; +Cc: netdev

Daniel Borkmann reports:

test_progs.c: In function ‘main’:
test_progs.c:81:3: warning: ‘duration’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   printf("%s:PASS:%s %d nsec\n", __func__, tag, duration);\
   ^~~~~~
test_progs.c:1706:8: note: ‘duration’ was declared here
  __u32 duration;
        ^~~~~~~~

Signed-off-by: Joe Stringer <joe@wand.net.nz>
---

I'm actually not able to reproduce this with GCC 7.3 or 8.2, so I'll
rely on review to establish that this patch works as intended.
---
 tools/testing/selftests/bpf/test_progs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 2d3c04f45530..c1e688f61061 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -1703,7 +1703,7 @@ static void test_reference_tracking()
 	const char *file = "./test_sk_lookup_kern.o";
 	struct bpf_object *obj;
 	struct bpf_program *prog;
-	__u32 duration;
+	__u32 duration = 0;
 	int err = 0;
 
 	obj = bpf_object__open(file);
-- 
2.17.1

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

* Re: [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning
  2018-11-09 18:18 [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning Joe Stringer
@ 2018-11-12 23:51 ` Martin Lau
  2018-11-17  1:44 ` Alexei Starovoitov
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Lau @ 2018-11-12 23:51 UTC (permalink / raw)
  To: Joe Stringer; +Cc: daniel, netdev

On Fri, Nov 09, 2018 at 10:18:16AM -0800, Joe Stringer wrote:
> Daniel Borkmann reports:
> 
> test_progs.c: In function ‘main’:
> test_progs.c:81:3: warning: ‘duration’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    printf("%s:PASS:%s %d nsec\n", __func__, tag, duration);\
>    ^~~~~~
> test_progs.c:1706:8: note: ‘duration’ was declared here
>   __u32 duration;
>         ^~~~~~~~
> 
> Signed-off-by: Joe Stringer <joe@wand.net.nz>
I can repro with my locally compiled gcc 7.3.  It fixed the warning.

Acked-by: Martin KaFai Lau <kafai@fb.com>

> ---
> 
> I'm actually not able to reproduce this with GCC 7.3 or 8.2, so I'll
> rely on review to establish that this patch works as intended.
> ---
>  tools/testing/selftests/bpf/test_progs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index 2d3c04f45530..c1e688f61061 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -1703,7 +1703,7 @@ static void test_reference_tracking()
>  	const char *file = "./test_sk_lookup_kern.o";
>  	struct bpf_object *obj;
>  	struct bpf_program *prog;
> -	__u32 duration;
> +	__u32 duration = 0;
>  	int err = 0;
>  
>  	obj = bpf_object__open(file);
> -- 
> 2.17.1
> 

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

* Re: [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning
  2018-11-09 18:18 [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning Joe Stringer
  2018-11-12 23:51 ` Martin Lau
@ 2018-11-17  1:44 ` Alexei Starovoitov
  1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2018-11-17  1:44 UTC (permalink / raw)
  To: Joe Stringer; +Cc: Daniel Borkmann, Network Development

On Fri, Nov 9, 2018 at 6:20 PM Joe Stringer <joe@wand.net.nz> wrote:
>
> Daniel Borkmann reports:
>
> test_progs.c: In function ‘main’:
> test_progs.c:81:3: warning: ‘duration’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>    printf("%s:PASS:%s %d nsec\n", __func__, tag, duration);\
>    ^~~~~~
> test_progs.c:1706:8: note: ‘duration’ was declared here
>   __u32 duration;
>         ^~~~~~~~
>
> Signed-off-by: Joe Stringer <joe@wand.net.nz>

Applied, thanks.

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

end of thread, other threads:[~2018-11-17 11:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09 18:18 [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning Joe Stringer
2018-11-12 23:51 ` Martin Lau
2018-11-17  1:44 ` Alexei Starovoitov

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.