Skip to contentSkip to conversation

ipv6: ICMPV6: Use swap() instead of open coding it

PATCH Applied Jiapeng Chong 4 participants 4 messages Jan 31, 2023 – Feb 2, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: ICMPV6: Use swap() instead of open coding it

Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.

./net/ipv6/icmp.c:344:25-26: WARNING opportunity for swap().

---
 net/ipv6/icmp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
net/ipv6/icmp.c +1 -4
index 79c769c0d113..c9346515e24d 100644
@@ -332,7 +332,6 @@ static void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt
 {
 	struct ipv6hdr *iph = ipv6_hdr(skb);
 	struct ipv6_destopt_hao *hao;
-	struct in6_addr tmp;
 	int off;
 
 	if (opt->dsthao) {
@@ -340,9 +339,7 @@ static void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt
 		if (likely(off >= 0)) {
 			hao = (struct ipv6_destopt_hao *)
 					(skb_network_header(skb) + off);
-			tmp = iph->saddr;
-			iph->saddr = hao->addr;
-			hao->addr = tmp;
+			swap(iph->saddr, hao->addr);
 		}
 	}
 }
Signature · 1 line
2.20.1.7.g153144c
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Jiapeng Chong
Quoted 12 lines · Jiapeng Chong

Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.

./net/ipv6/icmp.c:344:25-26: WARNING opportunity for swap().

---
 net/ipv6/icmp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
#3 lore raw
In reply to Jiapeng Chong
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 31 Jan 2023 14:34:56 +0800 you wrote:

Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.

./net/ipv6/icmp.c:344:25-26: WARNING opportunity for swap().

[...]

Here is the summary with links:
- ipv6: ICMPV6: Use swap() instead of open coding it

    https://git.kernel.org/netdev/net-next/c/bc61761394ce

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html