linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it
@ 2023-01-31  6:34 Jiapeng Chong
  2023-01-31 12:55 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jiapeng Chong @ 2023-01-31  6:34 UTC (permalink / raw)
  To: davem
  Cc: yoshfuji, dsahern, edumazet, kuba, pabeni, netdev, linux-kernel,
	Jiapeng Chong, Abaci Robot

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().

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3896
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 net/ipv6/icmp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 79c769c0d113..c9346515e24d 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -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);
 		}
 	}
 }
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it
  2023-01-31  6:34 [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it Jiapeng Chong
@ 2023-01-31 12:55 ` Simon Horman
  2023-01-31 16:03 ` David Ahern
  2023-02-02  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2023-01-31 12:55 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: davem, yoshfuji, dsahern, edumazet, kuba, pabeni, netdev,
	linux-kernel, Abaci Robot

On Tue, Jan 31, 2023 at 02:34:56PM +0800, Jiapeng Chong 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().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3896
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it
  2023-01-31  6:34 [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it Jiapeng Chong
  2023-01-31 12:55 ` Simon Horman
@ 2023-01-31 16:03 ` David Ahern
  2023-02-02  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2023-01-31 16:03 UTC (permalink / raw)
  To: Jiapeng Chong, davem
  Cc: yoshfuji, edumazet, kuba, pabeni, netdev, linux-kernel, Abaci Robot

On 1/30/23 11:34 PM, Jiapeng Chong 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().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3896
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  net/ipv6/icmp.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it
  2023-01-31  6:34 [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it Jiapeng Chong
  2023-01-31 12:55 ` Simon Horman
  2023-01-31 16:03 ` David Ahern
@ 2023-02-02  4:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-02  4:00 UTC (permalink / raw)
  To: Jiapeng Chong
  Cc: davem, yoshfuji, dsahern, edumazet, kuba, pabeni, netdev,
	linux-kernel, abaci

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

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().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3896
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it
  2022-01-13 16:17 Jiapeng Chong
@ 2022-01-14  4:30 ` David Ahern
  0 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2022-01-14  4:30 UTC (permalink / raw)
  To: Jiapeng Chong, davem
  Cc: yoshfuji, dsahern, kuba, netdev, linux-kernel, Abaci Robot

On 1/13/22 9:17 AM, Jiapeng Chong wrote:
> Clean the following coccicheck warning:
> 
> ./net/ipv6/icmp.c:348:25-26: WARNING opportunity for swap().
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  net/ipv6/icmp.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 

looks fine to me but net-next is closed; resubmit when it opens.

Also, you need to add the tree to the subject line so in this case:

[PATCH net-next] ipv6: ICMPV6: Use swap() instead of open coding it

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it
@ 2022-01-13 16:17 Jiapeng Chong
  2022-01-14  4:30 ` David Ahern
  0 siblings, 1 reply; 6+ messages in thread
From: Jiapeng Chong @ 2022-01-13 16:17 UTC (permalink / raw)
  To: davem
  Cc: yoshfuji, dsahern, kuba, netdev, linux-kernel, Jiapeng Chong,
	Abaci Robot

Clean the following coccicheck warning:

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

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 net/ipv6/icmp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 96c5cc0f30ce..8d2ab5f2f8b6 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -336,7 +336,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) {
@@ -344,9 +343,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);
 		}
 	}
 }
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-02  4:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31  6:34 [PATCH] ipv6: ICMPV6: Use swap() instead of open coding it Jiapeng Chong
2023-01-31 12:55 ` Simon Horman
2023-01-31 16:03 ` David Ahern
2023-02-02  4:00 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2022-01-13 16:17 Jiapeng Chong
2022-01-14  4:30 ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).