Skip to contentSkip to conversation

net: decnet: dn_nsp_in: use swap macro in dn_nsp_rx_packet

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Oct 28, 2017 – Nov 1, 2017

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

PATCH 1/1 net: decnet: dn_nsp_in: use swap macro in dn_nsp_rx_packet

Make use of the swap macro and remove unnecessary variable tmp. This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

---
 net/decnet/dn_nsp_in.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/decnet/dn_nsp_in.c +2 -6
index 7ac086d..1b212064 100644
@@ -776,12 +776,8 @@ static int dn_nsp_rx_packet(struct net *net, struct sock *sk2,
 	 * Swap src & dst and look up in the normal way.
 	 */
 	if (unlikely(cb->rt_flags & DN_RT_F_RTS)) {
-		__le16 tmp = cb->dst_port;
-		cb->dst_port = cb->src_port;
-		cb->src_port = tmp;
-		tmp = cb->dst;
-		cb->dst = cb->src;
-		cb->src = tmp;
+		swap(cb->dst_port, cb->src_port);
+		swap(cb->dst, cb->src);
 	}
 
 	/*
Signature · 1 line
2.7.4