[v5,28/32] examples: replace use of fixed size rte_memcpy

Message ID 20240522033009.143100-29-stephen@networkplumber.org (mailing list archive)
State Changes Requested
Delegated to: Thomas Monjalon
Headers
Series replace use of rte_memcpy() with fixed size |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Stephen Hemminger May 22, 2024, 3:27 a.m. UTC
  Automatically generated by devtools/cocci/rte_memcpy.cocci
Use structure assignment where possible.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/bbdev_app/main.c                         |  2 +-
 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                          |  4 +---
 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 -
 .../client_server_mp/mp_server/init.c             |  1 -
 .../client_server_mp/mp_server/main.c             |  1 -
 examples/multi_process/symmetric_mp/main.c        |  1 -
 examples/ptpclient/ptpclient.c                    | 11 +++++------
 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 -
 examples/vhost/main.c                             |  6 +++---
 examples/vmdq/main.c                              |  7 +++----
 examples/vmdq_dcb/main.c                          | 15 +++++----------
 24 files changed, 18 insertions(+), 45 deletions(-)
  

Patch

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 46f20238db..772963fc9b 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -360,7 +360,7 @@  add_ether_hdr(struct rte_mbuf *pkt_src, struct rte_mbuf *pkt_dst)
 	eth_to = rte_pktmbuf_mtod(pkt_dst, struct rte_ether_hdr *);
 
 	/* copy header */
-	rte_memcpy(eth_to, eth_from, sizeof(struct rte_ether_hdr));
+	memcpy(eth_to, eth_from, sizeof(struct rte_ether_hdr));
 }
 
 static inline void
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 736eae6f05..e1f27498c0 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 c7019078f7..e770ade798 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 00e4cde48b..d1689fca29 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>
 
@@ -314,8 +313,7 @@  parse_l3ca(const char *l3ca)
 		if (cmask != 0 && is_contiguous(cmask) == 0)
 			goto err;
 
-		rte_memcpy(&m_config[idx].cpumask,
-			&cpuset, sizeof(rte_cpuset_t));
+		memcpy(&m_config[idx].cpumask, &cpuset, sizeof(rte_cpuset_t));
 
 		if (cmask != 0) {
 			m_config[idx].cdp = 1;
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 c3ead9e8b7..010d727086 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 294ee113e3..2088115fb1 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 fba11da7ca..fc0f6b21ec 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 ad28ba9d2e..d16d21f956 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/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/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/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index afb61bba51..7edf235bfb 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -362,9 +362,9 @@  parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, uint16_t rx_tstamp_idx)
 	ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
 	if (ptp_data->ptpset == 0) {
-		rte_memcpy(&ptp_data->master_clock_id,
-				&ptp_hdr->source_port_id.clock_id,
-				sizeof(struct clock_id));
+		memcpy(&ptp_data->master_clock_id,
+		       &ptp_hdr->source_port_id.clock_id,
+		       sizeof(struct clock_id));
 		ptp_data->ptpset = 1;
 	}
 
@@ -469,9 +469,8 @@  parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
 		client_clkid->id[6] = eth_hdr->src_addr.addr_bytes[4];
 		client_clkid->id[7] = eth_hdr->src_addr.addr_bytes[5];
 
-		rte_memcpy(&ptp_data->client_clock_id,
-			   client_clkid,
-			   sizeof(struct clock_id));
+		memcpy(&ptp_data->client_clock_id, client_clkid,
+		       sizeof(struct clock_id));
 
 		/* Enable flag for hardware timestamping. */
 		created_pkt->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST;
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 75ff0ea532..8cb1b33111 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>
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 4391d88c3d..876b09f515 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -405,9 +405,9 @@  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(&eth_conf->rx_adv_conf.vmdq_rx_conf, &conf,
-		   sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf)));
+	memcpy(eth_conf, &vmdq_conf_default, sizeof(*eth_conf));
+	memcpy(&eth_conf->rx_adv_conf.vmdq_rx_conf, &conf,
+	       sizeof(eth_conf->rx_adv_conf.vmdq_rx_conf));
 	return 0;
 }
 
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(&eth_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 |
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 4ccc2fe4b0..f93eca5936 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,11 @@  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(&eth_conf->rx_adv_conf.vmdq_dcb_conf, &conf,
-			  sizeof(conf)));
-	(void)(rte_memcpy(&eth_conf->rx_adv_conf.dcb_rx_conf, &dcb_conf,
-			  sizeof(dcb_conf)));
-	(void)(rte_memcpy(&eth_conf->rx_adv_conf.vmdq_rx_conf, &vmdq_conf,
-			  sizeof(vmdq_conf)));
-	(void)(rte_memcpy(&eth_conf->tx_adv_conf.vmdq_dcb_tx_conf, &tx_conf,
-			  sizeof(tx_conf)));
+	(void)(memcpy(eth_conf, &vmdq_dcb_conf_default, sizeof(*eth_conf)));
+	(void)(memcpy(&eth_conf->rx_adv_conf.vmdq_dcb_conf, &conf, sizeof(conf)));
+	(void)(memcpy(&eth_conf->rx_adv_conf.dcb_rx_conf, &dcb_conf, sizeof(dcb_conf)));
+	(void)(memcpy(&eth_conf->rx_adv_conf.vmdq_rx_conf, &vmdq_conf, sizeof(vmdq_conf)));
+	(void)(memcpy(&eth_conf->tx_adv_conf.vmdq_dcb_tx_conf, &tx_conf, sizeof(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 |