Skip to content

Commit bc61761

Browse files
Jiapeng Chongkuba-moo
authored andcommitted
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(). 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> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20230131063456.76302-1-jiapeng.chong@linux.alibaba.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 074dd3b commit bc61761

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

net/ipv6/icmp.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,14 @@ static void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt
332332
{
333333
struct ipv6hdr *iph = ipv6_hdr(skb);
334334
struct ipv6_destopt_hao *hao;
335-
struct in6_addr tmp;
336335
int off;
337336

338337
if (opt->dsthao) {
339338
off = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO);
340339
if (likely(off >= 0)) {
341340
hao = (struct ipv6_destopt_hao *)
342341
(skb_network_header(skb) + off);
343-
tmp = iph->saddr;
344-
iph->saddr = hao->addr;
345-
hao->addr = tmp;
342+
swap(iph->saddr, hao->addr);
346343
}
347344
}
348345
}

0 commit comments

Comments
 (0)