[v4,30/30] examples: replace use of fixed size rte_memcpy

Message ID 20240405165518.367503-31-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series replace use of rte_memcpy with fixed sizes |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS

Commit Message

Stephen Hemminger April 5, 2024, 4:53 p.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 16599ae9ce..52c8eabba7 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -359,7 +359,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 8528abf675..a10fc8c92d 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 744a1aa9b4..d800d314a1 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 bd0b1d31de..b23c2b0942 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 6d0a8501ef..8f135a5a96 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 2653db4735..e3e02b751e 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 1463cef0fc..52bcc91790 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 a5d7a84828..529489e10d 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 96fb33196f..d928c957c3 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 f4adcf41b5..9db9de806e 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 8d32ae1dd5..d77aa8c62c 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 a8423d5d2a..d726d5c3b5 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 f54bb8b75a..df1bac37d0 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 1ff85875df..ebf546db84 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 059c470afb..3b8d9d50e8 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 fd72882e3a..0cd17a9ca3 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 3fc1b151d1..41df424565 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 |