From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Stringer Subject: [PATCH bpf-next] selftests/bpf: Fix uninitialized duration warning Date: Fri, 9 Nov 2018 10:18:16 -0800 Message-ID: <20181109181816.22622-1-joe@wand.net.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org To: daniel@iogearbox.net Return-path: Received: from mail-pl1-f193.google.com ([209.85.214.193]:41392 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728108AbeKJEAG (ORCPT ); Fri, 9 Nov 2018 23:00:06 -0500 Received: by mail-pl1-f193.google.com with SMTP id p16-v6so1282966plr.8 for ; Fri, 09 Nov 2018 10:18:22 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: 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 --- 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