2024-03-22 13:18:32

by Arnd Bergmann

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

From: Arnd Bergmann <[email protected]>

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 <[email protected]>
---
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



2024-03-22 13:29:24

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH] ipv4/route: avoid unused-but-set-variable warning

On Fri, Mar 22, 2024 at 02:18:12PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> 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 <[email protected]>

## 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

2024-03-22 15:11:08

by David Ahern

[permalink] [raw]
Subject: Re: [PATCH] ipv4/route: avoid unused-but-set-variable warning

On 3/22/24 7:18 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> 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 <[email protected]>
> ---
> net/ipv4/route.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>

Reviewed-by: David Ahern <[email protected]>