diff mbox series

[net-next] ipv6: exthdrs: Replace opencoded swap() implementation

Message ID 20230807020947.1991716-1-william.xuanziyang@huawei.com (mailing list archive)
State Accepted
Commit 794529c448008d8bc24d6e06c7528b7dbec99dfd
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ipv6: exthdrs: Replace opencoded swap() implementation | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ziyang Xuan (William) Aug. 7, 2023, 2:09 a.m. UTC
Get a coccinelle warning as follows:
net/ipv6/exthdrs.c:800:29-30: WARNING opportunity for swap()

Use swap() to replace opencoded implementation.

Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 net/ipv6/exthdrs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Pavan Chebbi Aug. 7, 2023, 4:37 a.m. UTC | #1
On Mon, Aug 7, 2023 at 7:40 AM Ziyang Xuan
<william.xuanziyang@huawei.com> wrote:
>
> Get a coccinelle warning as follows:
> net/ipv6/exthdrs.c:800:29-30: WARNING opportunity for swap()
>
> Use swap() to replace opencoded implementation.
>
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> ---
>  net/ipv6/exthdrs.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>

Looks good to me.
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Kuniyuki Iwashima Aug. 7, 2023, 7:58 p.m. UTC | #2
From: Ziyang Xuan <william.xuanziyang@huawei.com>
Date: Mon, 7 Aug 2023 10:09:47 +0800
> Get a coccinelle warning as follows:
> net/ipv6/exthdrs.c:800:29-30: WARNING opportunity for swap()
> 
> Use swap() to replace opencoded implementation.
> 
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>


> ---
>  net/ipv6/exthdrs.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
> index f4bfccae003c..4952ae792450 100644
> --- a/net/ipv6/exthdrs.c
> +++ b/net/ipv6/exthdrs.c
> @@ -648,7 +648,6 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
>  	struct inet6_dev *idev = __in6_dev_get(skb->dev);
>  	struct inet6_skb_parm *opt = IP6CB(skb);
>  	struct in6_addr *addr = NULL;
> -	struct in6_addr daddr;
>  	int n, i;
>  	struct ipv6_rt_hdr *hdr;
>  	struct rt0_hdr *rthdr;
> @@ -796,9 +795,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
>  		return -1;
>  	}
>  
> -	daddr = *addr;
> -	*addr = ipv6_hdr(skb)->daddr;
> -	ipv6_hdr(skb)->daddr = daddr;
> +	swap(*addr, ipv6_hdr(skb)->daddr);
>  
>  	ip6_route_input(skb);
>  	if (skb_dst(skb)->error) {
> -- 
> 2.25.1
patchwork-bot+netdevbpf@kernel.org Aug. 8, 2023, 11 p.m. UTC | #3
Hello:

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

On Mon, 7 Aug 2023 10:09:47 +0800 you wrote:
> Get a coccinelle warning as follows:
> net/ipv6/exthdrs.c:800:29-30: WARNING opportunity for swap()
> 
> Use swap() to replace opencoded implementation.
> 
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> 
> [...]

Here is the summary with links:
  - [net-next] ipv6: exthdrs: Replace opencoded swap() implementation
    https://git.kernel.org/netdev/net-next/c/794529c44800

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index f4bfccae003c..4952ae792450 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -648,7 +648,6 @@  static int ipv6_rthdr_rcv(struct sk_buff *skb)
 	struct inet6_dev *idev = __in6_dev_get(skb->dev);
 	struct inet6_skb_parm *opt = IP6CB(skb);
 	struct in6_addr *addr = NULL;
-	struct in6_addr daddr;
 	int n, i;
 	struct ipv6_rt_hdr *hdr;
 	struct rt0_hdr *rthdr;
@@ -796,9 +795,7 @@  static int ipv6_rthdr_rcv(struct sk_buff *skb)
 		return -1;
 	}
 
-	daddr = *addr;
-	*addr = ipv6_hdr(skb)->daddr;
-	ipv6_hdr(skb)->daddr = daddr;
+	swap(*addr, ipv6_hdr(skb)->daddr);
 
 	ip6_route_input(skb);
 	if (skb_dst(skb)->error) {