Skip to content

Commit db09e0e

Browse files
arndbsmb49
authored andcommitted
ipv4/route: avoid unused-but-set-variable warning
BugLink: https://bugs.launchpad.net/bugs/2065857 [ Upstream commit cf1b7201df59fb936f40f4a807433fe3f2ce310a ] 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: 30038fc ("net: ip_rt_send_redirect() optimization") Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20240408074219.3030256-2-arnd@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent c31205e commit db09e0e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/ipv4/route.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,13 +933,11 @@ void ip_rt_send_redirect(struct sk_buff *skb)
933933
icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, gw);
934934
peer->rate_last = jiffies;
935935
++peer->n_redirects;
936-
#ifdef CONFIG_IP_ROUTE_VERBOSE
937-
if (log_martians &&
936+
if (IS_ENABLED(CONFIG_IP_ROUTE_VERBOSE) && log_martians &&
938937
peer->n_redirects == ip_rt_redirect_number)
939938
net_warn_ratelimited("host %pI4/if%d ignores redirects for %pI4 to %pI4\n",
940939
&ip_hdr(skb)->saddr, inet_iif(skb),
941940
&ip_hdr(skb)->daddr, &gw);
942-
#endif
943941
}
944942
out_put_peer:
945943
inet_putpeer(peer);

0 commit comments

Comments
 (0)