Skip to contentSkip to conversation

IB/hfi1: Use skb_put_data() instead of skb_put/memcpy pair

PATCH Applied Shang XiaoJing 3 participants 3 messages Sep 27, 2022

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

PATCH 1/1 IB/hfi1: Use skb_put_data() instead of skb_put/memcpy pair

Use skb_put_data() instead of skb_put() and memcpy(), which is shorter and clear. Drop the tmp variable that is not needed any more.

---
 drivers/infiniband/hw/hfi1/ipoib_rx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/ipoib_rx.c +1 -4
index 3afa7545242c..629691a572ef 100644
@@ -11,13 +11,10 @@
 
 static void copy_ipoib_buf(struct sk_buff *skb, void *data, int size)
 {
-	void *dst_data;
-
 	skb_checksum_none_assert(skb);
 	skb->protocol = *((__be16 *)data);
 
-	dst_data = skb_put(skb, size);
-	memcpy(dst_data, data, size);
+	skb_put_data(skb, data, size);
 	skb->mac_header = HFI1_IPOIB_PSEUDO_LEN;
 	skb_pull(skb, HFI1_IPOIB_ENCAP_LEN);
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Shang XiaoJing

Use skb_put_data() instead of skb_put() and memcpy(), which is shorter and clear. Drop the tmp variable that is not needed any more.

---
 drivers/infiniband/hw/hfi1/ipoib_rx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/infiniband/hw/hfi1/ipoib_rx.c +0 -1
index 3afa7545242c..629691a572ef 100644
@@ -11,13 +11,10 @@
 
 static void copy_ipoib_buf(struct sk_buff *skb, void *data, int size)
 {
-	void *dst_data;

drivers/infiniband/hw/hfi1/ipoib_rx.c line 20

Quoted 10 lines
drivers/infiniband/hw/hfi1/ipoib_rx.c +1 -3
-
 	skb_checksum_none_assert(skb);
 	skb->protocol = *((__be16 *)data);
 
-	dst_data = skb_put(skb, size);
-	memcpy(dst_data, data, size);
+	skb_put_data(skb, data, size);
 	skb->mac_header = HFI1_IPOIB_PSEUDO_LEN;
 	skb_pull(skb, HFI1_IPOIB_ENCAP_LEN);
 }

Seems OK to me. Although I don't know that it's any more "clear". More appropriate commit message would say it removes the open coded way of doing things. Regardless...