Skip to content

Commit

Permalink
ipv6: exthdrs: use swap() instead of open coding it
Browse files Browse the repository at this point in the history
Address the following coccicheck warning:
net/ipv6/exthdrs.c:620:44-45: WARNING opportunity for swap()

by using swap() for the swapping of variable values and drop
the tmp (`addr`) variable that is not needed any more.

Signed-off-by: Guo Zhengkui <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Guo Zhengkui authored and davem330 committed Apr 13, 2022
1 parent 816cda9 commit 5ee6ad1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions net/ipv6/exthdrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
struct net *net = dev_net(skb->dev);
struct inet6_dev *idev;
struct ipv6hdr *oldhdr;
struct in6_addr addr;
unsigned char *buf;
int accept_rpl_seg;
int i, err;
Expand Down Expand Up @@ -616,9 +615,7 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
return -1;
}

addr = ipv6_hdr(skb)->daddr;
ipv6_hdr(skb)->daddr = ohdr->rpl_segaddr[i];
ohdr->rpl_segaddr[i] = addr;
swap(ipv6_hdr(skb)->daddr, ohdr->rpl_segaddr[i]);

ipv6_rpl_srh_compress(chdr, ohdr, &ipv6_hdr(skb)->daddr, n);

Expand Down

0 comments on commit 5ee6ad1

Please sign in to comment.