2024-04-08 07:46:05

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 1/2] ipv6: fib: hide unused 'pn' variable

From: Arnd Bergmann <[email protected]>

When CONFIG_IPV6_SUBTREES is disabled, the only user is hidden, causing
a 'make W=1' warning:

net/ipv6/ip6_fib.c: In function 'fib6_add':
net/ipv6/ip6_fib.c:1388:32: error: variable 'pn' set but not used [-Werror=unused-but-set-variable]

Add another #ifdef around the variable declaration, matching the other
uses in this file.

Fixes: 66729e18df08 ("[IPV6] ROUTE: Make sure we have fn->leaf when adding a node on subtree.")
Link: https://lore.kernel.org/netdev/[email protected]/
Reviewed-by: David Ahern <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
---
net/ipv6/ip6_fib.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index ddd8e3c2df4a..31d77885bcae 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1386,7 +1386,10 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
struct nl_info *info, struct netlink_ext_ack *extack)
{
struct fib6_table *table = rt->fib6_table;
- struct fib6_node *fn, *pn = NULL;
+ struct fib6_node *fn;
+#ifdef CONFIG_IPV6_SUBTREES
+ struct fib6_node *pn = NULL;
+#endif
int err = -ENOMEM;
int allow_create = 1;
int replace_required = 0;
@@ -1410,9 +1413,9 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
goto out;
}

+#ifdef CONFIG_IPV6_SUBTREES
pn = fn;

-#ifdef CONFIG_IPV6_SUBTREES
if (rt->fib6_src.plen) {
struct fib6_node *sn;

--
2.39.2



2024-04-08 07:52:24

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH 2/2] 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")
Reviewed-by: David Ahern <[email protected]>
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-04-08 08:50:03

by Eric Dumazet

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

On Mon, Apr 8, 2024 at 9:42 AM Arnd Bergmann <[email protected]> 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")
> Reviewed-by: David Ahern <[email protected]>
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---

A Fixes: tag like this seems overkill, I doubt W=1 was the norm for
old kernels...

Reviewed-by: Eric Dumazet <[email protected]>

Thanks.

2024-04-08 08:58:04

by Eric Dumazet

[permalink] [raw]
Subject: Re: [PATCH 1/2] ipv6: fib: hide unused 'pn' variable

On Mon, Apr 8, 2024 at 9:42 AM Arnd Bergmann <[email protected]> wrote:
>
> From: Arnd Bergmann <[email protected]>
>
> When CONFIG_IPV6_SUBTREES is disabled, the only user is hidden, causing
> a 'make W=1' warning:
>
> net/ipv6/ip6_fib.c: In function 'fib6_add':
> net/ipv6/ip6_fib.c:1388:32: error: variable 'pn' set but not used [-Werror=unused-but-set-variable]
>
> Add another #ifdef around the variable declaration, matching the other
> uses in this file.
>
> Fixes: 66729e18df08 ("[IPV6] ROUTE: Make sure we have fn->leaf when adding a node on subtree.")
> Link: https://lore.kernel.org/netdev/[email protected]/
> Reviewed-by: David Ahern <[email protected]>
> Signed-off-by: Arnd Bergmann <[email protected]>

It is unfortunate we add an #ifdef just to avoid a warning.

Reviewed-by: Eric Dumazet <[email protected]>

2024-04-09 14:00:38

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH 1/2] ipv6: fib: hide unused 'pn' variable

Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

On Mon, 8 Apr 2024 09:42:02 +0200 you wrote:
> From: Arnd Bergmann <[email protected]>
>
> When CONFIG_IPV6_SUBTREES is disabled, the only user is hidden, causing
> a 'make W=1' warning:
>
> net/ipv6/ip6_fib.c: In function 'fib6_add':
> net/ipv6/ip6_fib.c:1388:32: error: variable 'pn' set but not used [-Werror=unused-but-set-variable]
>
> [...]

Here is the summary with links:
- [1/2] ipv6: fib: hide unused 'pn' variable
https://git.kernel.org/netdev/net/c/74043489fcb5
- [2/2] ipv4/route: avoid unused-but-set-variable warning
https://git.kernel.org/netdev/net/c/cf1b7201df59

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html