c1124be5cab0f0fe193f2613b011e52a68e07d07
[openwrt/staging/981213.git] /
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3 Date: Wed, 6 May 2020 15:33:05 -0600
4 Subject: [PATCH] wireguard: selftests: initalize ipv6 members to NULL to
5 squelch clang warning
6
7 commit 4fed818ef54b08d4b29200e416cce65546ad5312 upstream.
8
9 Without setting these to NULL, clang complains in certain
10 configurations that have CONFIG_IPV6=n:
11
12 In file included from drivers/net/wireguard/ratelimiter.c:223:
13 drivers/net/wireguard/selftest/ratelimiter.c:173:34: error: variable 'skb6' is uninitialized when used here [-Werror,-Wuninitialized]
14 ret = timings_test(skb4, hdr4, skb6, hdr6, &test_count);
15 ^~~~
16 drivers/net/wireguard/selftest/ratelimiter.c:123:29: note: initialize the variable 'skb6' to silence this warning
17 struct sk_buff *skb4, *skb6;
18 ^
19 = NULL
20 drivers/net/wireguard/selftest/ratelimiter.c:173:40: error: variable 'hdr6' is uninitialized when used here [-Werror,-Wuninitialized]
21 ret = timings_test(skb4, hdr4, skb6, hdr6, &test_count);
22 ^~~~
23 drivers/net/wireguard/selftest/ratelimiter.c:125:22: note: initialize the variable 'hdr6' to silence this warning
24 struct ipv6hdr *hdr6;
25 ^
26
27 We silence this warning by setting the variables to NULL as the warning
28 suggests.
29
30 Reported-by: Arnd Bergmann <arnd@arndb.de>
31 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
32 Signed-off-by: David S. Miller <davem@davemloft.net>
33 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
34 ---
35 drivers/net/wireguard/selftest/ratelimiter.c | 4 ++--
36 1 file changed, 2 insertions(+), 2 deletions(-)
37
38 --- a/drivers/net/wireguard/selftest/ratelimiter.c
39 +++ b/drivers/net/wireguard/selftest/ratelimiter.c
40 @@ -120,9 +120,9 @@ bool __init wg_ratelimiter_selftest(void
41 enum { TRIALS_BEFORE_GIVING_UP = 5000 };
42 bool success = false;
43 int test = 0, trials;
44 - struct sk_buff *skb4, *skb6;
45 + struct sk_buff *skb4, *skb6 = NULL;
46 struct iphdr *hdr4;
47 - struct ipv6hdr *hdr6;
48 + struct ipv6hdr *hdr6 = NULL;
49
50 if (IS_ENABLED(CONFIG_KASAN) || IS_ENABLED(CONFIG_UBSAN))
51 return true;