]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.10/ipv4-route-avoid-unused-but-set-variable-warning.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.10 / ipv4-route-avoid-unused-but-set-variable-warning.patch
1 From e7fb60a18ff9b60ae60063381a08a76263c46958 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 8 Apr 2024 09:42:03 +0200
4 Subject: ipv4/route: avoid unused-but-set-variable warning
5
6 From: Arnd Bergmann <arnd@arndb.de>
7
8 [ Upstream commit cf1b7201df59fb936f40f4a807433fe3f2ce310a ]
9
10 The log_martians variable is only used in an #ifdef, causing a 'make W=1'
11 warning with gcc:
12
13 net/ipv4/route.c: In function 'ip_rt_send_redirect':
14 net/ipv4/route.c:880:13: error: variable 'log_martians' set but not used [-Werror=unused-but-set-variable]
15
16 Change the #ifdef to an equivalent IS_ENABLED() to let the compiler
17 see where the variable is used.
18
19 Fixes: 30038fc61adf ("net: ip_rt_send_redirect() optimization")
20 Reviewed-by: David Ahern <dsahern@kernel.org>
21 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
22 Reviewed-by: Eric Dumazet <edumazet@google.com>
23 Link: https://lore.kernel.org/r/20240408074219.3030256-2-arnd@kernel.org
24 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
26 ---
27 net/ipv4/route.c | 4 +---
28 1 file changed, 1 insertion(+), 3 deletions(-)
29
30 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
31 index d360c7d70e8a2..b7cba4bdc5786 100644
32 --- a/net/ipv4/route.c
33 +++ b/net/ipv4/route.c
34 @@ -955,13 +955,11 @@ void ip_rt_send_redirect(struct sk_buff *skb)
35 icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, gw);
36 peer->rate_last = jiffies;
37 ++peer->n_redirects;
38 -#ifdef CONFIG_IP_ROUTE_VERBOSE
39 - if (log_martians &&
40 + if (IS_ENABLED(CONFIG_IP_ROUTE_VERBOSE) && log_martians &&
41 peer->n_redirects == ip_rt_redirect_number)
42 net_warn_ratelimited("host %pI4/if%d ignores redirects for %pI4 to %pI4\n",
43 &ip_hdr(skb)->saddr, inet_iif(skb),
44 &ip_hdr(skb)->daddr, &gw);
45 -#endif
46 }
47 out_put_peer:
48 inet_putpeer(peer);
49 --
50 2.43.0
51