Skip to contentSkip to conversation

ethdev: replace rte_memcpy with assignment

PATCH In review Stephen Hemminger 2 participants 3 messages Sep 29 – Oct 1

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethdev: replace rte_memcpy with assignment

Can use structure assignment instead of rte_memcpy here.

---
 lib/ethdev/rte_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/ethdev/rte_ethdev.c +1 -2
index 7c57a9bb8f..6f5a957d00 100644
@@ -16,7 +16,6 @@
 #include <rte_log.h>
 #include <rte_interrupts.h>
 #include <rte_kvargs.h>
-#include <rte_memcpy.h>
 #include <rte_common.h>
 #include <rte_mempool.h>
 #include <rte_malloc.h>
@@ -631,7 +630,7 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)
 	rte_spinlock_lock(rte_mcfg_ethdev_get_lock());
 
 	if (eth_dev_shared_data_prepare() != NULL) {
-		rte_memcpy(owner, &ethdev->data->owner, sizeof(*owner));
+		*owner = ethdev->data->owner;
 		ret = 0;
 	} else {
 		ret = -ENOMEM;
Signature · 1 line
2.53.0
#1 lore raw
Quoted 1 line · Stephen Hemminger

Can use structure assignment instead of rte_memcpy here.

It would be useful to mention in the description or summary why it is better.

Right now the description say what is done, but it is obvious from the code change.

Quoted 27 lines
---
  lib/ethdev/rte_ethdev.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
lib/ethdev/rte_ethdev.c +1 -2
index 7c57a9bb8f..6f5a957d00 100644
@@ -16,7 +16,6 @@
  #include <rte_log.h>
  #include <rte_interrupts.h>
  #include <rte_kvargs.h>
-#include <rte_memcpy.h>
  #include <rte_common.h>
  #include <rte_mempool.h>
  #include <rte_malloc.h>
@@ -631,7 +630,7 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)
  	rte_spinlock_lock(rte_mcfg_ethdev_get_lock());
 
  	if (eth_dev_shared_data_prepare() != NULL) {
-		rte_memcpy(owner, &ethdev->data->owner, sizeof(*owner));
+		*owner = ethdev->data->owner;
  		ret = 0;
  	} else {
  		ret = -ENOMEM;
#2 lore raw
Quoted 8 lines · On Thu, 1 Oct 2026 11:14:13 +0300 Andrew Rybchenko…
Quoted 1 line · Stephen Hemminger

Can use structure assignment instead of rte_memcpy here.

It would be useful to mention in the description or summary why it is better.

Right now the description say what is done, but it is obvious from the code change.

I thought it was obvious, it is mentioned in AGENTS.md and there is a coccinelle script that finds places like this.