* [PATCH] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only
@ 2025-01-12 9:05 Geert Uytterhoeven
2025-01-13 6:19 ` Kuniyuki Iwashima
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2025-01-12 9:05 UTC (permalink / raw)
To: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: netdev, linux-kernel, Geert Uytterhoeven, kernel test robot
if CONFIG_NET_IPGRE is enabled, but CONFIG_IPV6 is disabled:
net/ipv4/ip_gre.c: In function ‘ipgre_err’:
net/ipv4/ip_gre.c:144:22: error: variable ‘data_len’ set but not used [-Werror=unused-but-set-variable]
144 | unsigned int data_len = 0;
| ^~~~~~~~
Fix this by moving all data_len processing inside the IPV6-only section
that uses its result.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501121007.2GofXmh5-lkp@intel.com/
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
net/ipv4/ip_gre.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f1f31ebfc7934467..6f871af7bb5772b7 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -141,7 +141,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
const struct iphdr *iph;
const int type = icmp_hdr(skb)->type;
const int code = icmp_hdr(skb)->code;
- unsigned int data_len = 0;
struct ip_tunnel *t;
if (tpi->proto == htons(ETH_P_TEB))
@@ -182,7 +181,6 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
case ICMP_TIME_EXCEEDED:
if (code != ICMP_EXC_TTL)
return 0;
- data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */
break;
case ICMP_REDIRECT:
@@ -191,8 +189,9 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
#if IS_ENABLED(CONFIG_IPV6)
if (tpi->proto == htons(ETH_P_IPV6) &&
- !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len,
- type, data_len))
+ !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, type,
+ type == ICMP_TIME_EXCEEDED ?
+ icmp_hdr(skb)->un.reserved[1] * 4 /* RFC 4884 4.1 */ : 0))
return 0;
#endif
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only
2025-01-12 9:05 [PATCH] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only Geert Uytterhoeven
@ 2025-01-13 6:19 ` Kuniyuki Iwashima
0 siblings, 0 replies; 2+ messages in thread
From: Kuniyuki Iwashima @ 2025-01-13 6:19 UTC (permalink / raw)
To: geert
Cc: davem, dsahern, edumazet, horms, kuba, linux-kernel, lkp, netdev, pabeni
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Sun, 12 Jan 2025 10:05:10 +0100
> @@ -191,8 +189,9 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
>
> #if IS_ENABLED(CONFIG_IPV6)
> if (tpi->proto == htons(ETH_P_IPV6) &&
> - !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len,
> - type, data_len))
> + !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len, type,
> + type == ICMP_TIME_EXCEEDED ?
> + icmp_hdr(skb)->un.reserved[1] * 4 /* RFC 4884 4.1 */ : 0))
> return 0;
> #endif
No need to pack everything in a single line.
---8<---
#if IS_ENABLED(CONFIG_IPV6)
if (tpi->proto == htons(ETH_P_IPV6)) {
unsigned int data_len = 0;
if (type == ICMP_TIME_EXCEEDED)
data_len = icmp_hdr(skb)->un.reserved[1] * 4; /* RFC 4884 4.1 */
if (!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4 + tpi->hdr_len,
type, data_len)
return 0;
}
#endif
---8<---
For the future submission, please specify the target tree in Subject.
[PATCH net-next v2] ...
See: Documentation/process/maintainer-netdev.rst
Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-13 6:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-12 9:05 [PATCH] ipv4: ip_gre: Fix set but not used warning in ipgre_err() if IPv4-only Geert Uytterhoeven
2025-01-13 6:19 ` Kuniyuki Iwashima
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®