blob: c1124be5cab0f0fe193f2613b011e52a68e07d07 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3Date: Wed, 6 May 2020 15:33:05 -0600
4Subject: [PATCH] wireguard: selftests: initalize ipv6 members to NULL to
5 squelch clang warning
6
7commit 4fed818ef54b08d4b29200e416cce65546ad5312 upstream.
8
9Without setting these to NULL, clang complains in certain
10configurations that have CONFIG_IPV6=n:
11
12In file included from drivers/net/wireguard/ratelimiter.c:223:
13drivers/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 ^~~~
16drivers/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
20drivers/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 ^~~~
23drivers/net/wireguard/selftest/ratelimiter.c:125:22: note: initialize the variable 'hdr6' to silence this warning
24 struct ipv6hdr *hdr6;
25 ^
26
27We silence this warning by setting the variables to NULL as the warning
28suggests.
29
30Reported-by: Arnd Bergmann <arnd@arndb.de>
31Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
32Signed-off-by: David S. Miller <davem@davemloft.net>
33Signed-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;