[PATCH] ipv4/route: avoid unused-but-set-variable warning

Arnd Bergmann posted 1 patch 1 year, 10 months ago
net/ipv4/route.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] ipv4/route: avoid unused-but-set-variable warning
Posted by Arnd Bergmann 1 year, 10 months ago
From: Arnd Bergmann <arnd@arndb.de>

The log_martians variable is only used in an #ifdef, causing a 'make W=1'
warning with gcc:

net/ipv4/route.c: In function 'ip_rt_send_redirect':
net/ipv4/route.c:880:13: error: variable 'log_martians' set but not used [-Werror=unused-but-set-variable]

Change the #ifdef to an equivalent IS_ENABLED() to let the compiler
see where the variable is used.

Fixes: 30038fc61adf ("net: ip_rt_send_redirect() optimization")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/ipv4/route.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index c8f76f56dc16..d36ace160d42 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -926,13 +926,11 @@ void ip_rt_send_redirect(struct sk_buff *skb)
 		icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, gw);
 		peer->rate_last = jiffies;
 		++peer->n_redirects;
-#ifdef CONFIG_IP_ROUTE_VERBOSE
-		if (log_martians &&
+		if (IS_ENABLED(CONFIG_IP_ROUTE_VERBOSE) && log_martians &&
 		    peer->n_redirects == ip_rt_redirect_number)
 			net_warn_ratelimited("host %pI4/if%d ignores redirects for %pI4 to %pI4\n",
 					     &ip_hdr(skb)->saddr, inet_iif(skb),
 					     &ip_hdr(skb)->daddr, &gw);
-#endif
 	}
 out_put_peer:
 	inet_putpeer(peer);
-- 
2.39.2
Re: [PATCH] ipv4/route: avoid unused-but-set-variable warning
Posted by David Ahern 1 year, 10 months ago
On 3/22/24 7:18 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The log_martians variable is only used in an #ifdef, causing a 'make W=1'
> warning with gcc:
> 
> net/ipv4/route.c: In function 'ip_rt_send_redirect':
> net/ipv4/route.c:880:13: error: variable 'log_martians' set but not used [-Werror=unused-but-set-variable]
> 
> Change the #ifdef to an equivalent IS_ENABLED() to let the compiler
> see where the variable is used.
> 
> Fixes: 30038fc61adf ("net: ip_rt_send_redirect() optimization")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  net/ipv4/route.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>
Re: [PATCH] ipv4/route: avoid unused-but-set-variable warning
Posted by Simon Horman 1 year, 10 months ago
On Fri, Mar 22, 2024 at 02:18:12PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The log_martians variable is only used in an #ifdef, causing a 'make W=1'
> warning with gcc:
> 
> net/ipv4/route.c: In function 'ip_rt_send_redirect':
> net/ipv4/route.c:880:13: error: variable 'log_martians' set but not used [-Werror=unused-but-set-variable]
> 
> Change the #ifdef to an equivalent IS_ENABLED() to let the compiler
> see where the variable is used.
> 
> Fixes: 30038fc61adf ("net: ip_rt_send_redirect() optimization")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

## Form letter - net-next-closed

(text from Jakub)

The merge window for v6.9 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We are currently accepting bug fixes only.

Please repost when net-next reopens after March 25th.

RFC patches sent for review only are welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer