* [PATCH 1/4] examples/vhost: replace memcpy with assignment
2026-01-21 17:04 [PATCH 0/4] examples: memcpy cleanups Stephen Hemminger
@ 2026-01-21 17:04 ` Stephen Hemminger
2026-01-21 17:04 ` [PATCH 2/4] examples/vmdq: replace memcpy with structure assignment Stephen Hemminger
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2026-01-21 17:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia
Better to use structure assignment to preserve type info.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/vhost/main.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 4391d88c3d..ac888348d2 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -405,9 +405,8 @@ get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_devices)
conf.pool_map[i].pools = (1UL << i);
}
- (void)(rte_memcpy(eth_conf, &vmdq_conf_default, sizeof(*eth_conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_rx_conf, &conf,
- sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf)));
+ *eth_conf = vmdq_conf_default;
+ eth_conf->rx_adv_conf.vmdq_rx_conf = conf;
return 0;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/4] examples/vmdq: replace memcpy with structure assignment
2026-01-21 17:04 [PATCH 0/4] examples: memcpy cleanups Stephen Hemminger
2026-01-21 17:04 ` [PATCH 1/4] examples/vhost: replace memcpy with assignment Stephen Hemminger
@ 2026-01-21 17:04 ` Stephen Hemminger
2026-01-21 17:04 ` [PATCH 3/4] examples/vmdq_dcb: replace memcpy with assignment Stephen Hemminger
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2026-01-21 17:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Better to keep type safety and use assignment rather than
rte_memcpy.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/vmdq/main.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 4a3ce6884c..12ef5bffc2 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -17,7 +17,6 @@
#include <rte_common.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
@@ -151,9 +150,9 @@ get_eth_conf(struct rte_eth_conf *eth_conf, uint32_t num_pools)
conf.pool_map[i].pools = (1UL << (i % num_pools));
}
- (void)(rte_memcpy(eth_conf, &vmdq_conf_default, sizeof(*eth_conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_rx_conf, &conf,
- sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf)));
+ *eth_conf = vmdq_conf_default;
+ eth_conf->rx_adv_conf.vmdq_rx_conf = conf;
+
if (rss_enable) {
eth_conf->rxmode.mq_mode = RTE_ETH_MQ_RX_VMDQ_RSS;
eth_conf->rx_adv_conf.rss_conf.rss_hf = RTE_ETH_RSS_IP |
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/4] examples/vmdq_dcb: replace memcpy with assignment
2026-01-21 17:04 [PATCH 0/4] examples: memcpy cleanups Stephen Hemminger
2026-01-21 17:04 ` [PATCH 1/4] examples/vhost: replace memcpy with assignment Stephen Hemminger
2026-01-21 17:04 ` [PATCH 2/4] examples/vmdq: replace memcpy with structure assignment Stephen Hemminger
@ 2026-01-21 17:04 ` Stephen Hemminger
2026-01-21 17:04 ` [PATCH 4/4] examples: remove unnecessary include Stephen Hemminger
2026-01-21 18:55 ` [PATCH 0/4] examples: memcpy cleanups Morten Brørup
4 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2026-01-21 17:04 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
Better to use structure assignment rather than memcpy.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/vmdq_dcb/main.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 4ccc2fe4b0..6eccee086d 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -17,7 +17,6 @@
#include <rte_common.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
@@ -161,15 +160,13 @@ get_eth_conf(struct rte_eth_conf *eth_conf)
tx_conf.dcb_tc[i] = i % num_tcs;
}
dcb_conf.nb_tcs = (enum rte_eth_nb_tcs)num_tcs;
- (void)(rte_memcpy(eth_conf, &vmdq_dcb_conf_default, sizeof(*eth_conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_dcb_conf, &conf,
- sizeof(conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.dcb_rx_conf, &dcb_conf,
- sizeof(dcb_conf)));
- (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_rx_conf, &vmdq_conf,
- sizeof(vmdq_conf)));
- (void)(rte_memcpy(ð_conf->tx_adv_conf.vmdq_dcb_tx_conf, &tx_conf,
- sizeof(tx_conf)));
+
+ *eth_conf = vmdq_dcb_conf_default;
+ eth_conf->rx_adv_conf.vmdq_dcb_conf = conf;
+ eth_conf->rx_adv_conf.dcb_rx_conf = dcb_conf;
+ eth_conf->rx_adv_conf.vmdq_rx_conf = vmdq_conf;
+ eth_conf->tx_adv_conf.vmdq_dcb_tx_conf = tx_conf;
+
if (rss_enable) {
eth_conf->rxmode.mq_mode = RTE_ETH_MQ_RX_VMDQ_DCB_RSS;
eth_conf->rx_adv_conf.rss_conf.rss_hf = RTE_ETH_RSS_IP |
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 4/4] examples: remove unnecessary include
2026-01-21 17:04 [PATCH 0/4] examples: memcpy cleanups Stephen Hemminger
` (2 preceding siblings ...)
2026-01-21 17:04 ` [PATCH 3/4] examples/vmdq_dcb: replace memcpy with assignment Stephen Hemminger
@ 2026-01-21 17:04 ` Stephen Hemminger
2026-02-17 17:43 ` Thomas Monjalon
2026-01-21 18:55 ` [PATCH 0/4] examples: memcpy cleanups Morten Brørup
4 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2026-01-21 17:04 UTC (permalink / raw)
To: dev
Cc: Stephen Hemminger, Chas Williams, Min Hu (Connor),
Konstantin Ananyev, Tomasz Kantecki, Sunil Kumar Kori,
Pavan Nikhilesh, Akhil Goyal, Bruce Richardson, Anatoly Burakov,
David Hunt, Sivaprasad Tummala, Cristian Dumitrescu, Byron Marohn,
Yipeng Wang
All these examples include rte_memcpy.h but do not use
that function.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
examples/bond/main.c | 1 -
examples/ip_fragmentation/main.c | 1 -
examples/ip_reassembly/main.c | 1 -
examples/ipv4_multicast/main.c | 1 -
examples/l2fwd-cat/cat.c | 1 -
examples/l2fwd-event/l2fwd_common.h | 1 -
examples/l2fwd-jobstats/main.c | 1 -
examples/l2fwd-keepalive/main.c | 1 -
examples/l2fwd-macsec/main.c | 1 -
examples/l2fwd/main.c | 1 -
examples/l3fwd-power/main.c | 1 -
examples/l3fwd/main.c | 1 -
examples/link_status_interrupt/main.c | 1 -
examples/multi_process/client_server_mp/mp_server/init.c | 1 -
examples/multi_process/client_server_mp/mp_server/main.c | 1 -
examples/multi_process/symmetric_mp/main.c | 1 -
examples/qos_sched/app_thread.c | 1 -
examples/qos_sched/main.c | 1 -
examples/server_node_efd/efd_server/init.c | 1 -
examples/server_node_efd/efd_server/main.c | 1 -
20 files changed, 20 deletions(-)
diff --git a/examples/bond/main.c b/examples/bond/main.c
index 9f38b63cbb..4e8eeb7a5e 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -21,7 +21,6 @@
#include <rte_common.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 1f84102844..2180682373 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -18,7 +18,6 @@
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index 25b904dbd4..520fbea1c2 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -19,7 +19,6 @@
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c
index 1eed645d02..bd4c3f335b 100644
--- a/examples/ipv4_multicast/main.c
+++ b/examples/ipv4_multicast/main.c
@@ -17,7 +17,6 @@
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c
index ac8feaec8e..5beee22159 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -12,7 +12,6 @@
#include <stdio.h>
#include <rte_common.h>
-#include <rte_memcpy.h>
#include <pqos.h>
diff --git a/examples/l2fwd-event/l2fwd_common.h b/examples/l2fwd-event/l2fwd_common.h
index 8cf91b919c..f4f1c45cd1 100644
--- a/examples/l2fwd-event/l2fwd_common.h
+++ b/examples/l2fwd-event/l2fwd_common.h
@@ -24,7 +24,6 @@
#include <rte_common.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 308b8edd20..a7cd5b4840 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -13,7 +13,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index bff2b99531..993e0bf9da 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -21,7 +21,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l2fwd-macsec/main.c b/examples/l2fwd-macsec/main.c
index 73e32fc197..98763440bc 100644
--- a/examples/l2fwd-macsec/main.c
+++ b/examples/l2fwd-macsec/main.c
@@ -21,7 +21,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index c6fafdd019..59ea3172ae 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -21,7 +21,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index ec12d1cc0b..02ec17d799 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -21,7 +21,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index a5626ff02d..4c64194794 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -22,7 +22,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index ac9c7f6217..aa33e71d7a 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -19,7 +19,6 @@
#include <rte_log.h>
#include <rte_malloc.h>
#include <rte_memory.h>
-#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_cycles.h>
diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
index 65713dbea8..f3b9b49380 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -24,7 +24,6 @@
#include <rte_ring.h>
#include <rte_log.h>
#include <rte_mempool.h>
-#include <rte_memcpy.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_ether.h>
diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
index ebfc2febc5..691d453d0e 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -24,7 +24,6 @@
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_mempool.h>
-#include <rte_memcpy.h>
#include <rte_mbuf.h>
#include <rte_ether.h>
#include <rte_interrupts.h>
diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index f7d8439cd4..7314a9c6ea 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -37,7 +37,6 @@
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_mempool.h>
-#include <rte_memcpy.h>
#include <rte_mbuf.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
diff --git a/examples/qos_sched/app_thread.c b/examples/qos_sched/app_thread.c
index e50cc33fde..e9db70bb3c 100644
--- a/examples/qos_sched/app_thread.c
+++ b/examples/qos_sched/app_thread.c
@@ -9,7 +9,6 @@
#include <rte_malloc.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
-#include <rte_memcpy.h>
#include <rte_byteorder.h>
#include <rte_branch_prediction.h>
#include <rte_sched.h>
diff --git a/examples/qos_sched/main.c b/examples/qos_sched/main.c
index b3c2c9ef23..e756ce0da2 100644
--- a/examples/qos_sched/main.c
+++ b/examples/qos_sched/main.c
@@ -10,7 +10,6 @@
#include <rte_malloc.h>
#include <rte_cycles.h>
#include <rte_ethdev.h>
-#include <rte_memcpy.h>
#include <rte_byteorder.h>
#include <rte_branch_prediction.h>
diff --git a/examples/server_node_efd/efd_server/init.c b/examples/server_node_efd/efd_server/init.c
index 9c89f6b60d..9a20831a0d 100644
--- a/examples/server_node_efd/efd_server/init.c
+++ b/examples/server_node_efd/efd_server/init.c
@@ -24,7 +24,6 @@
#include <rte_ring.h>
#include <rte_log.h>
#include <rte_mempool.h>
-#include <rte_memcpy.h>
#include <rte_mbuf.h>
#include <rte_interrupts.h>
#include <rte_ether.h>
diff --git a/examples/server_node_efd/efd_server/main.c b/examples/server_node_efd/efd_server/main.c
index 62c3f4a16d..70a7372d4a 100644
--- a/examples/server_node_efd/efd_server/main.c
+++ b/examples/server_node_efd/efd_server/main.c
@@ -26,7 +26,6 @@
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_mempool.h>
-#include <rte_memcpy.h>
#include <rte_mbuf.h>
#include <rte_ether.h>
#include <rte_interrupts.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 4/4] examples: remove unnecessary include
2026-01-21 17:04 ` [PATCH 4/4] examples: remove unnecessary include Stephen Hemminger
@ 2026-02-17 17:43 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2026-02-17 17:43 UTC (permalink / raw)
To: Stephen Hemminger
Cc: dev, Stephen Hemminger, Chas Williams, Min Hu (Connor),
Konstantin Ananyev, Tomasz Kantecki, Sunil Kumar Kori,
Pavan Nikhilesh, Akhil Goyal, Bruce Richardson, Anatoly Burakov,
David Hunt, Sivaprasad Tummala, Cristian Dumitrescu, Byron Marohn,
Yipeng Wang
21/01/2026 18:04, Stephen Hemminger:
> --- a/examples/l2fwd-cat/cat.c
> +++ b/examples/l2fwd-cat/cat.c
> @@ -12,7 +12,6 @@
> #include <stdio.h>
>
> #include <rte_common.h>
> -#include <rte_memcpy.h>
It breaks the build.
I add this:
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -10,6 +10,7 @@
#include <sched.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH 0/4] examples: memcpy cleanups
2026-01-21 17:04 [PATCH 0/4] examples: memcpy cleanups Stephen Hemminger
` (3 preceding siblings ...)
2026-01-21 17:04 ` [PATCH 4/4] examples: remove unnecessary include Stephen Hemminger
@ 2026-01-21 18:55 ` Morten Brørup
2026-02-17 17:49 ` Thomas Monjalon
4 siblings, 1 reply; 8+ messages in thread
From: Morten Brørup @ 2026-01-21 18:55 UTC (permalink / raw)
To: Stephen Hemminger, dev
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Wednesday, 21 January 2026 18.05
>
> Looking at examples and noticed stuff around use
> of rte_memcpy. Probably mostly copy/pasted.
>
> Stephen Hemminger (4):
> examples/vhost: replace memcpy with assignment
> examples/vmdq: replace memcpy with structure assignment
> examples/vmdq_dcb: replace memcpy with assignment
> examples: remove unnecessary include
>
Structure assignment is better than [rte_]memcpy().
And this is slow path only, so no need to discuss performance.
For the series,
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Thank you for cleaning this up.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 0/4] examples: memcpy cleanups
2026-01-21 18:55 ` [PATCH 0/4] examples: memcpy cleanups Morten Brørup
@ 2026-02-17 17:49 ` Thomas Monjalon
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2026-02-17 17:49 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Morten Brørup
21/01/2026 19:55, Morten Brørup:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Wednesday, 21 January 2026 18.05
> >
> > Looking at examples and noticed stuff around use
> > of rte_memcpy. Probably mostly copy/pasted.
> >
> > Stephen Hemminger (4):
> > examples/vhost: replace memcpy with assignment
> > examples/vmdq: replace memcpy with structure assignment
> > examples/vmdq_dcb: replace memcpy with assignment
> > examples: remove unnecessary include
> >
>
> Structure assignment is better than [rte_]memcpy().
> And this is slow path only, so no need to discuss performance.
>
> For the series,
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
>
> Thank you for cleaning this up.
Applied with a small fix as notified in this thread.
^ permalink raw reply [flat|nested] 8+ messages in thread