DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 00/32] Use structure assignment instead of memcpy
@ 2025-02-08 20:21 Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 01/32] devtools/cocci: prefer structure assignment over memcpy Stephen Hemminger
                   ` (31 more replies)
  0 siblings, 32 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

This patch series reduces use of memcpy and rte_memcpy
in DPDK. It changes memcpy to a simple assignment operator
which easier to read, generates the same code, and
keeps type safety.

Historically memcpy was used in textbooks because there
was no structure assignement in original K&R C.

Stephen Hemminger (32):
  devtools/cocci: prefer structure assignment over memcpy
  app/testpmd: replace memcpy with assignment
  app/graph: replace memcpy with structure assignment
  crypto/dpaa_sec: replace memcpy with assignment
  dma/dpaa2: replace memcpy with assignment
  eventdev: replace memcpy with assignment
  event/dpaa2: replace memcpy with structure assignment
  event/dsw: replace memcpy with assignment
  ml/cnxk: replace memcpy with assignment
  examples: replace memcpy with assignment
  node: replace memcpy with assignment
  pipeline: replace memcpy with assignment
  sched: replace memcpy with structure assignment
  table: replace memcpy with structure assignment
  net/ntnic: replace memcpy with structure assignment
  net/bnxt: replace memcpy with structure assignment
  crypto/qat: replace memcpy with structure assignment
  mempool/cnxk: replace memcpy with structure assignment
  net/dpaa2: replace memcpy with assignment
  net/enic: replace memcpy with assignment
  net/intel/i40e: replace memcpy with structure assignment
  net/nfp: replace memcpy with assignment
  net/txgbe: replace memcpy with assignment
  net/bnx2x: replace memcpy with structure assignment
  net/dpaa2: replace memcpy with structure assignment
  net/bonding: replace memcpy with structure assignment
  net/cnxk: replace memcpy with structure assignment
  net/enic: replace memcpy with structure assignment
  net/iavf: replace memcpy with structure assignment
  net/ice: replace memcpy with structure assignment
  test: replace memcpy with structure assignment
  test/cryptodev: replace memcpy with structure assignment

 app/graph/ethdev.c                            |  2 +-
 app/test-pmd/cmdline_flow.c                   |  2 +-
 app/test/test_acl.c                           |  5 ++-
 app/test/test_compressdev.c                   | 36 +++++++------------
 app/test/test_cryptodev.c                     |  3 +-
 app/test/test_security_inline_proto.c         | 23 +++++-------
 devtools/cocci/struct-assign.cocci            | 15 ++++++++
 drivers/crypto/dpaa_sec/dpaa_sec.c            |  2 +-
 drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c  |  3 +-
 drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c  |  3 +-
 drivers/dma/dpaa2/dpaa2_qdma.c                |  4 +--
 drivers/event/dpaa2/dpaa2_eventdev.c          |  7 ++--
 drivers/event/dsw/dsw_event.c                 |  3 +-
 drivers/mempool/cnxk/cnxk_mempool_ops.c       |  2 +-
 drivers/ml/cnxk/cnxk_ml_ops.c                 |  2 +-
 drivers/net/bnx2x/bnx2x_stats.c               |  2 +-
 drivers/net/bnxt/bnxt_hwrm.c                  |  3 +-
 drivers/net/bnxt/tf_core/tf_rm.c              |  8 ++---
 drivers/net/bnxt/tf_ulp/ulp_tun.c             |  3 +-
 drivers/net/bonding/rte_eth_bond_pmd.c        |  2 +-
 drivers/net/cnxk/cnxk_ethdev_cman.c           |  2 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  5 ++-
 drivers/net/dpaa2/dpaa2_flow.c                |  9 ++---
 drivers/net/dpaa2/dpaa2_mux.c                 |  2 +-
 drivers/net/enic/enic_fm_flow.c               |  2 +-
 drivers/net/enic/enic_main.c                  |  2 +-
 drivers/net/intel/i40e/i40e_ethdev.c          |  6 ++--
 drivers/net/intel/i40e/i40e_fdir.c            |  3 +-
 drivers/net/intel/i40e/i40e_flow.c            |  3 +-
 drivers/net/intel/i40e/rte_pmd_i40e.c         |  3 +-
 drivers/net/intel/iavf/iavf_ipsec_crypto.c    |  3 +-
 drivers/net/intel/ice/ice_hash.c              |  6 ++--
 drivers/net/intel/ixgbe/ixgbe_flow.c          |  4 +--
 .../net/nfp/flower/nfp_flower_representor.c   |  2 +-
 .../net/ntnic/nthw/flow_api/flow_id_table.c   |  4 +--
 .../profile_inline/flow_api_profile_inline.c  |  2 +-
 drivers/net/txgbe/txgbe_flow.c                |  4 +--
 examples/bbdev_app/main.c                     |  2 +-
 examples/ip_pipeline/parser.c                 |  2 +-
 examples/l2fwd-cat/cat.c                      |  3 +-
 examples/ptpclient/ptpclient.c                |  4 +--
 lib/eventdev/rte_event_dma_adapter.c          |  2 +-
 lib/eventdev/rte_event_timer_adapter.c        |  2 +-
 lib/node/ethdev_rx.c                          |  2 +-
 lib/node/ip4_reassembly.c                     |  2 +-
 lib/node/kernel_rx.c                          |  2 +-
 lib/pipeline/rte_pipeline.c                   |  6 ++--
 lib/pipeline/rte_swx_ctl.c                    |  2 +-
 lib/pipeline/rte_swx_ipsec.c                  |  2 +-
 lib/pipeline/rte_swx_pipeline_spec.c          | 36 +++++++------------
 lib/sched/rte_sched.c                         |  2 +-
 lib/table/rte_swx_table_selector.c            |  2 +-
 52 files changed, 108 insertions(+), 155 deletions(-)
 create mode 100644 devtools/cocci/struct-assign.cocci

-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/32] devtools/cocci: prefer structure assignment over memcpy
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 02/32] app/testpmd: replace memcpy with assignment Stephen Hemminger
                   ` (30 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Prefer using simple structure assignment instead of memcpy.
Using a structure assignment preserves type information and
compiler checks types already.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 devtools/cocci/struct-assign.cocci | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 devtools/cocci/struct-assign.cocci

diff --git a/devtools/cocci/struct-assign.cocci b/devtools/cocci/struct-assign.cocci
new file mode 100644
index 0000000000..052ebf3340
--- /dev/null
+++ b/devtools/cocci/struct-assign.cocci
@@ -0,0 +1,15 @@
+//
+// prefer structure assignment over memcpy
+//
+@@
+type T;
+T *SRCP;
+T *DSTP;
+@@
+(
+- rte_memcpy(DSTP, SRCP, sizeof(T))
++ *DSTP = *SRCP
+|
+- memcpy(DSTP, SRCP, sizeof(T))
++ *DSTP = *SRCP
+)
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 02/32] app/testpmd: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 01/32] devtools/cocci: prefer structure assignment over memcpy Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 03/32] app/graph: replace memcpy with structure assignment Stephen Hemminger
                   ` (29 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ori Kam, Aman Singh

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-pmd/cmdline_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index e1720e54d7..9a2cd86821 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -13934,7 +13934,7 @@ cmd_set_raw_parsed_sample(const struct buffer *in)
 			fprintf(stderr, "Error - Not supported action\n");
 			return;
 		}
-		rte_memcpy(data, action, sizeof(struct rte_flow_action));
+		*data = *action;
 		data++;
 	}
 }
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 03/32] app/graph: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 01/32] devtools/cocci: prefer structure assignment over memcpy Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 02/32] app/testpmd: replace memcpy with assignment Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 04/32] crypto/dpaa_sec: replace memcpy with assignment Stephen Hemminger
                   ` (28 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Sunil Kumar Kori, Rakesh Kudurumalla

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/graph/ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c
index d343235dae..2f4cf65c96 100644
--- a/app/graph/ethdev.c
+++ b/app/graph/ethdev.c
@@ -422,7 +422,7 @@ ethdev_process(const char *name, struct ethdev_config *params)
 	}
 
 	/* Port */
-	memcpy(&port_conf, &port_conf_default, sizeof(struct rte_eth_conf));
+	port_conf = port_conf_default;
 	if (rss) {
 		uint64_t rss_hf = RTE_ETH_RSS_IP | RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP;
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 04/32] crypto/dpaa_sec: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (2 preceding siblings ...)
  2025-02-08 20:21 ` [PATCH 03/32] app/graph: replace memcpy with structure assignment Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 05/32] dma/dpaa2: " Stephen Hemminger
                   ` (27 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 3fa88ca968..af605d2025 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -680,7 +680,7 @@ dpaa_sec_dump(struct dpaa_sec_op_ctx *ctx, struct dpaa_sec_qp *qp, FILE *f)
 	}
 
 	cdb = &sess->cdb;
-	rte_memcpy(&c_cdb, cdb, sizeof(struct sec_cdb));
+	c_cdb = *cdb;
 #ifdef RTE_LIB_SECURITY
 	fprintf(f, "\nsession protocol type = %d\n", sess->proto_alg);
 #endif
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 05/32] dma/dpaa2: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (3 preceding siblings ...)
  2025-02-08 20:21 ` [PATCH 04/32] crypto/dpaa_sec: replace memcpy with assignment Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 06/32] eventdev: " Stephen Hemminger
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Gagandeep Singh, Hemant Agrawal

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/dma/dpaa2/dpaa2_qdma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c
index 3c9a7b5485..c0e0a44e84 100644
--- a/drivers/dma/dpaa2/dpaa2_qdma.c
+++ b/drivers/dma/dpaa2/dpaa2_qdma.c
@@ -171,9 +171,7 @@ dpaa2_qdma_multi_eq(struct qdma_virt_queue *qdma_vq)
 	if (unlikely(num_tx != qdma_vq->fd_idx)) {
 		dst_idx = 0;
 		for (idx = num_tx; idx < qdma_vq->fd_idx; idx++) {
-			rte_memcpy(&qdma_vq->fd[dst_idx],
-				&qdma_vq->fd[idx],
-				sizeof(struct qbman_fd));
+			qdma_vq->fd[dst_idx] = qdma_vq->fd[idx];
 			dst_idx++;
 		}
 	}
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 06/32] eventdev: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (4 preceding siblings ...)
  2025-02-08 20:21 ` [PATCH 05/32] dma/dpaa2: " Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:21 ` [PATCH 07/32] event/dpaa2: replace memcpy with structure assignment Stephen Hemminger
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Amit Prakash Shukla, Jerin Jacob,
	Erik Gabriel Carrillo

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eventdev/rte_event_dma_adapter.c   | 2 +-
 lib/eventdev/rte_event_timer_adapter.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eventdev/rte_event_dma_adapter.c b/lib/eventdev/rte_event_dma_adapter.c
index 165374d195..70a208620a 100644
--- a/lib/eventdev/rte_event_dma_adapter.c
+++ b/lib/eventdev/rte_event_dma_adapter.c
@@ -449,7 +449,7 @@ rte_event_dma_adapter_create(uint8_t id, uint8_t evdev_id, struct rte_event_port
 	if (pc == NULL)
 		return -ENOMEM;
 
-	rte_memcpy(pc, port_config, sizeof(struct rte_event_port_conf));
+	*pc = *port_config;
 	ret = rte_event_dma_adapter_create_ext(id, evdev_id, edma_default_config_cb, mode, pc);
 	if (ret != 0)
 		rte_free(pc);
diff --git a/lib/eventdev/rte_event_timer_adapter.c b/lib/eventdev/rte_event_timer_adapter.c
index 5886965d14..871cfba576 100644
--- a/lib/eventdev/rte_event_timer_adapter.c
+++ b/lib/eventdev/rte_event_timer_adapter.c
@@ -549,7 +549,7 @@ event_buffer_add(struct event_buffer *bufp, struct rte_event *eventp)
 	/* Instead of modulus, bitwise AND with mask to get head_idx. */
 	head_idx = bufp->head & EVENT_BUFFER_MASK;
 	buf_eventp = &bufp->events[head_idx];
-	rte_memcpy(buf_eventp, eventp, sizeof(struct rte_event));
+	*buf_eventp = *eventp;
 
 	/* Wrap automatically when overflow occurs. */
 	bufp->head++;
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 07/32] event/dpaa2: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (5 preceding siblings ...)
  2025-02-08 20:21 ` [PATCH 06/32] eventdev: " Stephen Hemminger
@ 2025-02-08 20:21 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 08/32] event/dsw: replace memcpy with assignment Stephen Hemminger
                   ` (24 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:21 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/dpaa2/dpaa2_eventdev.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c b/drivers/event/dpaa2/dpaa2_eventdev.c
index 6c8ed3ff6b..95d9154b11 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -224,7 +224,7 @@ static void dpaa2_eventdev_process_parallel(struct qbman_swp *swp,
 
 	RTE_SET_USED(rxq);
 
-	rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
+	*ev = *ev_temp;
 	rte_free(ev_temp);
 
 	qbman_swp_dqrr_consume(swp, dq);
@@ -243,7 +243,7 @@ static void dpaa2_eventdev_process_atomic(struct qbman_swp *swp,
 	RTE_SET_USED(swp);
 	RTE_SET_USED(rxq);
 
-	rte_memcpy(ev, ev_temp, sizeof(struct rte_event));
+	*ev = *ev_temp;
 	rte_free(ev_temp);
 	*dpaa2_seqn(ev->mbuf) = dqrr_index + 1;
 	DPAA2_PER_LCORE_DQRR_SIZE++;
@@ -588,8 +588,7 @@ dpaa2_eventdev_port_link(struct rte_eventdev *dev, void *port,
 
 	for (i = 0; i < nb_links; i++) {
 		evq_info = &priv->evq_info[queues[i]];
-		memcpy(&dpaa2_portal->evq_info[queues[i]], evq_info,
-			   sizeof(struct dpaa2_eventq));
+		dpaa2_portal->evq_info[queues[i]] = *evq_info;
 		dpaa2_portal->evq_info[queues[i]].event_port = port;
 		dpaa2_portal->num_linked_evq++;
 	}
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 08/32] event/dsw: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (6 preceding siblings ...)
  2025-02-08 20:21 ` [PATCH 07/32] event/dpaa2: replace memcpy with structure assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 09/32] ml/cnxk: " Stephen Hemminger
                   ` (23 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Mattias Rönnblom

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/event/dsw/dsw_event.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/event/dsw/dsw_event.c b/drivers/event/dsw/dsw_event.c
index e68fb19890..399d9f050e 100644
--- a/drivers/event/dsw/dsw_event.c
+++ b/drivers/event/dsw/dsw_event.c
@@ -1078,8 +1078,7 @@ dsw_port_stash_any_migrating_events(struct dsw_port *port,
 			offset++;
 		} else if (offset > 0) {
 			struct rte_event *out_event = &events[i - offset];
-			rte_memcpy(out_event, in_event,
-				   sizeof(struct rte_event));
+			*out_event = *in_event;
 		}
 	}
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 09/32] ml/cnxk: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (7 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 08/32] event/dsw: replace memcpy with assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 10/32] examples: " Stephen Hemminger
                   ` (22 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Srikanth Yalavarthi

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/ml/cnxk/cnxk_ml_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ml/cnxk/cnxk_ml_ops.c b/drivers/ml/cnxk/cnxk_ml_ops.c
index d93c31535d..9958945670 100644
--- a/drivers/ml/cnxk/cnxk_ml_ops.c
+++ b/drivers/ml/cnxk/cnxk_ml_ops.c
@@ -1398,7 +1398,7 @@ cnxk_ml_model_info_get(struct rte_ml_dev *dev, uint16_t model_id,
 	}
 
 	info = (struct rte_ml_model_info *)model->info;
-	rte_memcpy(model_info, info, sizeof(struct rte_ml_model_info));
+	*model_info = *info;
 	model_info->input_info = info->input_info;
 	model_info->output_info = info->output_info;
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 10/32] examples: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (8 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 09/32] ml/cnxk: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 11/32] node: " Stephen Hemminger
                   ` (21 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Nicolas Chautru, Tomasz Kantecki, Kirill Rybalchenko

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/bbdev_app/main.c      | 2 +-
 examples/l2fwd-cat/cat.c       | 3 +--
 examples/ptpclient/ptpclient.c | 4 +---
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 46f20238db..03f15f91cc 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));
+	*eth_to = *eth_from;
 }
 
 static inline void
diff --git a/examples/l2fwd-cat/cat.c b/examples/l2fwd-cat/cat.c
index 00e4cde48b..ac8feaec8e 100644
--- a/examples/l2fwd-cat/cat.c
+++ b/examples/l2fwd-cat/cat.c
@@ -314,8 +314,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));
+		m_config[idx].cpumask = cpuset;
 
 		if (cmask != 0) {
 			m_config[idx].cdp = 1;
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index def8de29ff..2f9764bf07 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -470,9 +470,7 @@ parse_fup(struct ptpv2_time_receiver_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));
+		ptp_data->client_clock_id = *client_clkid;
 
 		/* Enable flag for hardware timestamping. */
 		created_pkt->ol_flags |= RTE_MBUF_F_TX_IEEE1588_TMST;
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 11/32] node: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (9 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 10/32] examples: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 12/32] pipeline: " Stephen Hemminger
                   ` (20 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Nithin Dabilpuram, Pavan Nikhilesh

Prefer structure assignment over memcpy.
Found by cocci/rte_memcpy.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/node/ethdev_rx.c      | 2 +-
 lib/node/ip4_reassembly.c | 2 +-
 lib/node/kernel_rx.c      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/node/ethdev_rx.c b/lib/node/ethdev_rx.c
index 475eff6abe..bcd192cc0c 100644
--- a/lib/node/ethdev_rx.c
+++ b/lib/node/ethdev_rx.c
@@ -186,7 +186,7 @@ ethdev_rx_node_init(const struct rte_graph *graph, struct rte_node *node)
 	while (elem) {
 		if (elem->nid == node->id) {
 			/* Update node specific context */
-			memcpy(ctx, &elem->ctx, sizeof(ethdev_rx_node_ctx_t));
+			*ctx = elem->ctx;
 			break;
 		}
 		elem = elem->next;
diff --git a/lib/node/ip4_reassembly.c b/lib/node/ip4_reassembly.c
index eb5f391114..c8072e6e50 100644
--- a/lib/node/ip4_reassembly.c
+++ b/lib/node/ip4_reassembly.c
@@ -157,7 +157,7 @@ ip4_reassembly_node_init(const struct rte_graph *graph, struct rte_node *node)
 	while (elem) {
 		if (elem->node_id == node->id) {
 			/* Update node specific context */
-			memcpy(ctx, &elem->ctx, sizeof(ip4_reassembly_ctx_t));
+			*ctx = elem->ctx;
 			break;
 		}
 		elem = elem->next;
diff --git a/lib/node/kernel_rx.c b/lib/node/kernel_rx.c
index 6c20cdbb1e..461330414f 100644
--- a/lib/node/kernel_rx.c
+++ b/lib/node/kernel_rx.c
@@ -198,7 +198,7 @@ kernel_rx_node_init(const struct rte_graph *graph, struct rte_node *node)
 	while (elem) {
 		if (elem->nid == node->id) {
 			/* Update node specific context */
-			memcpy(ctx, &elem->ctx, sizeof(kernel_rx_node_ctx_t));
+			*ctx = elem->ctx;
 			break;
 		}
 		elem = elem->next;
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 12/32] pipeline: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (10 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 11/32] node: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 13/32] sched: replace memcpy with structure assignment Stephen Hemminger
                   ` (19 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ip_pipeline/parser.c        |  2 +-
 lib/pipeline/rte_pipeline.c          |  6 ++---
 lib/pipeline/rte_swx_ctl.c           |  2 +-
 lib/pipeline/rte_swx_ipsec.c         |  2 +-
 lib/pipeline/rte_swx_pipeline_spec.c | 36 ++++++++++------------------
 5 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/examples/ip_pipeline/parser.c b/examples/ip_pipeline/parser.c
index dfca026be5..8baa70e1f4 100644
--- a/examples/ip_pipeline/parser.c
+++ b/examples/ip_pipeline/parser.c
@@ -407,7 +407,7 @@ parse_mac_addr(const char *token, struct rte_ether_addr *addr)
 	if (tmp == NULL)
 		return -1;
 
-	memcpy(addr, tmp, sizeof(struct rte_ether_addr));
+	*addr = *tmp;
 	return 0;
 }
 
diff --git a/lib/pipeline/rte_pipeline.c b/lib/pipeline/rte_pipeline.c
index a09a89f746..bad85341c9 100644
--- a/lib/pipeline/rte_pipeline.c
+++ b/lib/pipeline/rte_pipeline.c
@@ -368,7 +368,7 @@ rte_pipeline_table_create(struct rte_pipeline *p,
 	*table_id = id;
 
 	/* Save input parameters */
-	memcpy(&table->ops, params->ops, sizeof(struct rte_table_ops));
+	table->ops = *params->ops;
 	table->f_action_hit = params->f_action_hit;
 	table->f_action_miss = params->f_action_miss;
 	table->arg_ah = params->arg_ah;
@@ -831,7 +831,7 @@ rte_pipeline_port_in_create(struct rte_pipeline *p,
 	*port_id = id;
 
 	/* Save input parameters */
-	memcpy(&port->ops, params->ops, sizeof(struct rte_port_in_ops));
+	port->ops = *params->ops;
 	port->f_action = params->f_action;
 	port->arg_ah = params->arg_ah;
 	port->burst_size = params->burst_size;
@@ -881,7 +881,7 @@ rte_pipeline_port_out_create(struct rte_pipeline *p,
 	*port_id = id;
 
 	/* Save input parameters */
-	memcpy(&port->ops, params->ops, sizeof(struct rte_port_out_ops));
+	port->ops = *params->ops;
 	port->f_action = params->f_action;
 	port->arg_ah = params->arg_ah;
 
diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index 857770d297..db83c31c7c 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -832,7 +832,7 @@ selector_group_duplicate_to_pending(struct selector *s, uint32_t group_id)
 		if (!mp)
 			goto error;
 
-		memcpy(mp, m, sizeof(struct rte_swx_table_selector_member));
+		*mp = *m;
 
 		TAILQ_INSERT_TAIL(&gp->members, mp, node);
 	}
diff --git a/lib/pipeline/rte_swx_ipsec.c b/lib/pipeline/rte_swx_ipsec.c
index 17a9d2b98b..e710ba2f9d 100644
--- a/lib/pipeline/rte_swx_ipsec.c
+++ b/lib/pipeline/rte_swx_ipsec.c
@@ -366,7 +366,7 @@ rte_swx_ipsec_create(struct rte_swx_ipsec **ipsec_out,
 	ipsec->ring_out = ring_out;
 	ipsec->dev_id = (uint8_t)dev_id;
 	ipsec->qp_id = params->crypto_dev_queue_pair_id;
-	memcpy(&ipsec->bsz, &params->bsz, sizeof(struct rte_swx_ipsec_burst_size));
+	ipsec->bsz = params->bsz;
 	ipsec->n_sa_max = n_sa_max;
 
 	ipsec->crypto_wr_threshold = params->bsz.crypto_wr * 3 / 4;
diff --git a/lib/pipeline/rte_swx_pipeline_spec.c b/lib/pipeline/rte_swx_pipeline_spec.c
index 17419e7b85..986bbe5fd4 100644
--- a/lib/pipeline/rte_swx_pipeline_spec.c
+++ b/lib/pipeline/rte_swx_pipeline_spec.c
@@ -2985,7 +2985,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->structs = new_structs;
-			memcpy(&s->structs[s->n_structs], &struct_spec, sizeof(struct struct_spec));
+			s->structs[s->n_structs] = struct_spec;
 			s->n_structs++;
 			memset(&struct_spec, 0, sizeof(struct struct_spec));
 
@@ -3022,7 +3022,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->actions = new_actions;
-			memcpy(&s->actions[s->n_actions], &action_spec, sizeof(struct action_spec));
+			s->actions[s->n_actions] = action_spec;
 			s->n_actions++;
 			memset(&action_spec, 0, sizeof(struct action_spec));
 
@@ -3059,7 +3059,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->tables = new_tables;
-			memcpy(&s->tables[s->n_tables], &table_spec, sizeof(struct table_spec));
+			s->tables[s->n_tables] = table_spec;
 			s->n_tables++;
 			memset(&table_spec, 0, sizeof(struct table_spec));
 
@@ -3096,9 +3096,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->selectors = new_selectors;
-			memcpy(&s->selectors[s->n_selectors],
-			       &selector_spec,
-			       sizeof(struct selector_spec));
+			s->selectors[s->n_selectors] = selector_spec;
 			s->n_selectors++;
 			memset(&selector_spec, 0, sizeof(struct selector_spec));
 
@@ -3135,9 +3133,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->learners = new_learners;
-			memcpy(&s->learners[s->n_learners],
-			       &learner_spec,
-			       sizeof(struct learner_spec));
+			s->learners[s->n_learners] = learner_spec;
 			s->n_learners++;
 			memset(&learner_spec, 0, sizeof(struct learner_spec));
 
@@ -3173,7 +3169,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->apply = new_apply;
-			memcpy(&s->apply[s->n_apply], &apply_spec, sizeof(struct apply_spec));
+			s->apply[s->n_apply] = apply_spec;
 			s->n_apply++;
 			memset(&apply_spec, 0, sizeof(struct apply_spec));
 
@@ -3205,7 +3201,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->extobjs = new_extobjs;
-			memcpy(&s->extobjs[s->n_extobjs], &extobj_spec, sizeof(struct extobj_spec));
+			s->extobjs[s->n_extobjs] = extobj_spec;
 			s->n_extobjs++;
 			memset(&extobj_spec, 0, sizeof(struct extobj_spec));
 
@@ -3252,7 +3248,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->headers = new_headers;
-			memcpy(&s->headers[s->n_headers], &header_spec, sizeof(struct header_spec));
+			s->headers[s->n_headers] = header_spec;
 			s->n_headers++;
 			memset(&header_spec, 0, sizeof(struct header_spec));
 
@@ -3284,9 +3280,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->metadata = new_metadata;
-			memcpy(&s->metadata[s->n_metadata],
-			       &metadata_spec,
-			       sizeof(struct metadata_spec));
+			s->metadata[s->n_metadata] = metadata_spec;
 			s->n_metadata++;
 			memset(&metadata_spec, 0, sizeof(struct metadata_spec));
 
@@ -3378,9 +3372,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->regarrays = new_regarrays;
-			memcpy(&s->regarrays[s->n_regarrays],
-			       &regarray_spec,
-			       sizeof(struct regarray_spec));
+			s->regarrays[s->n_regarrays] = regarray_spec;
 			s->n_regarrays++;
 			memset(&regarray_spec, 0, sizeof(struct regarray_spec));
 
@@ -3412,9 +3404,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->metarrays = new_metarrays;
-			memcpy(&s->metarrays[s->n_metarrays],
-			       &metarray_spec,
-			       sizeof(struct metarray_spec));
+			s->metarrays[s->n_metarrays] = metarray_spec;
 			s->n_metarrays++;
 			memset(&metarray_spec, 0, sizeof(struct metarray_spec));
 
@@ -3446,9 +3436,7 @@ pipeline_spec_parse(FILE *spec,
 			}
 
 			s->rss = new_rss;
-			memcpy(&s->rss[s->n_rss],
-			       &rss_spec,
-			       sizeof(struct rss_spec));
+			s->rss[s->n_rss] = rss_spec;
 			s->n_rss++;
 			memset(&rss_spec, 0, sizeof(struct rss_spec));
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 13/32] sched: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (11 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 12/32] pipeline: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 14/32] table: " Stephen Hemminger
                   ` (18 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/sched/rte_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/sched/rte_sched.c b/lib/sched/rte_sched.c
index bbdb5d1d86..c9b955b8e8 100644
--- a/lib/sched/rte_sched.c
+++ b/lib/sched/rte_sched.c
@@ -1775,7 +1775,7 @@ rte_sched_queue_read_stats(struct rte_sched_port *port,
 	qe = s->queue_extra + subport_qindex;
 
 	/* Copy queue stats and clear */
-	memcpy(stats, &qe->stats, sizeof(struct rte_sched_queue_stats));
+	*stats = qe->stats;
 	memset(&qe->stats, 0, sizeof(struct rte_sched_queue_stats));
 
 	/* Queue length */
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 14/32] table: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (12 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 13/32] sched: replace memcpy with structure assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 15/32] net/ntnic: " Stephen Hemminger
                   ` (17 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Cristian Dumitrescu

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/table/rte_swx_table_selector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/table/rte_swx_table_selector.c b/lib/table/rte_swx_table_selector.c
index 18e021fe6f..da693cdba6 100644
--- a/lib/table/rte_swx_table_selector.c
+++ b/lib/table/rte_swx_table_selector.c
@@ -225,7 +225,7 @@ table_params_copy(struct table *t, struct rte_swx_table_selector_params *params)
 	if (selector_size < 8)
 		selector_size = 8;
 
-	memcpy(&t->params, params, sizeof(struct rte_swx_table_selector_params));
+	t->params = *params;
 	t->params.selector_size = selector_size;
 	t->params.selector_mask = NULL;
 	t->params.n_groups_max = rte_align32pow2(params->n_groups_max);
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 15/32] net/ntnic: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (13 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 14/32] table: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 16/32] net/bnxt: " Stephen Hemminger
                   ` (16 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Christian Koue Muf, Serhii Iliushyk

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ntnic/nthw/flow_api/flow_id_table.c               | 4 ++--
 .../nthw/flow_api/profile_inline/flow_api_profile_inline.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
index a63f5542d1..61cec41590 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
@@ -99,7 +99,7 @@ uint32_t ntnic_id_table_get_id(void *id_table, union flm_handles flm_h, uint8_t
 	struct ntnic_id_table_element *element = ntnic_id_table_array_find_element(handle, new_id);
 	element->caller_id = caller_id;
 	element->type = type;
-	memcpy(&element->handle, &flm_h, sizeof(union flm_handles));
+	element->handle = flm_h;
 
 	rte_spinlock_unlock(&handle->mtx);
 
@@ -139,7 +139,7 @@ void ntnic_id_table_find(void *id_table, uint32_t id, union flm_handles *flm_h,
 
 	*caller_id = element->caller_id;
 	*type = element->type;
-	memcpy(flm_h, &element->handle, sizeof(union flm_handles));
+	*flm_h = element->handle;
 
 	rte_spinlock_unlock(&handle->mtx);
 }
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index ff8eb502f4..5565a7857c 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -3099,7 +3099,7 @@ static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d
 	if (fh->type != FLOW_HANDLE_TYPE_FLOW)
 		return -1;
 
-	memcpy(&fh_copy, fh, sizeof(struct flow_handle));
+	fh_copy = *fh;
 	memset(fh, 0x0, sizeof(struct flow_handle));
 	fd = fh_copy.fd;
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 16/32] net/bnxt: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (14 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 15/32] net/ntnic: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 17/32] crypto/qat: " Stephen Hemminger
                   ` (15 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ajit Khaparde, Somnath Kotur

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt_hwrm.c      | 3 +--
 drivers/net/bnxt/tf_core/tf_rm.c  | 8 ++------
 drivers/net/bnxt/tf_ulp/ulp_tun.c | 3 +--
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index d015ba2b9c..b2f73207ae 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -3266,8 +3266,7 @@ int bnxt_hwrm_func_qstats(struct bnxt *bp, uint16_t fid,
 
 	HWRM_CHECK_RESULT();
 	if (func_qstats)
-		memcpy(func_qstats, resp,
-		       sizeof(struct hwrm_func_qstats_output));
+		*func_qstats = *resp;
 
 	if (!stats)
 		goto exit;
diff --git a/drivers/net/bnxt/tf_core/tf_rm.c b/drivers/net/bnxt/tf_core/tf_rm.c
index e9a2fbd851..18f46c0a0a 100644
--- a/drivers/net/bnxt/tf_core/tf_rm.c
+++ b/drivers/net/bnxt/tf_core/tf_rm.c
@@ -1265,9 +1265,7 @@ tf_rm_get_info(struct tf_rm_get_alloc_info_parms *parms)
 	if (cfg_type == TF_RM_ELEM_CFG_NULL)
 		return -ENOTSUP;
 
-	memcpy(parms->info,
-	       &rm_db->db[parms->subtype].alloc,
-	       sizeof(struct tf_rm_alloc_info));
+	*parms->info = rm_db->db[parms->subtype].alloc;
 
 	return 0;
 }
@@ -1299,9 +1297,7 @@ tf_rm_get_all_info(struct tf_rm_get_alloc_info_parms *parms, int size)
 			continue;
 		}
 
-		memcpy(info,
-		       &rm_db->db[i].alloc,
-		       sizeof(struct tf_rm_alloc_info));
+		*info = rm_db->db[i].alloc;
 		info++;
 	}
 
diff --git a/drivers/net/bnxt/tf_ulp/ulp_tun.c b/drivers/net/bnxt/tf_ulp/ulp_tun.c
index 7ebe81c4ea..b90b4bf252 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_tun.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_tun.c
@@ -40,8 +40,7 @@ ulp_app_tun_search_entry(struct bnxt_ulp_context *ulp_ctx,
 	}
 	if (free_entry >= 0) {
 		*tun_entry =  &tun_ent_list[free_entry];
-		memcpy(&tun_ent_list[free_entry].app_tunnel, app_tunnel,
-		       sizeof(struct rte_flow_tunnel));
+		tun_ent_list[free_entry].app_tunnel = *app_tunnel;
 		tun_ent_list[free_entry].ref_cnt = 1;
 		rc = 1;
 	} else {
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 17/32] crypto/qat: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (15 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 16/32] net/bnxt: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 18/32] mempool/cnxk: " Stephen Hemminger
                   ` (14 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Kai Ji

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c | 3 +--
 drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
index af664fb9b9..478e766b97 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
@@ -277,8 +277,7 @@ qat_sym_crypto_cap_get_gen3(struct qat_cryptodev_private *internals,
 				RTE_CRYPTO_CIPHER_DES_DOCSISBPI)))
 			continue;
 
-		memcpy(addr + curr_capa, capabilities + iter,
-			sizeof(struct rte_cryptodev_capabilities));
+		*(addr + curr_capa) = *(capabilities + iter);
 
 		if (internals->qat_dev->options.has_wireless_slice && (
 			check_auth_capa(&capabilities[iter],
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c
index e1302e9b36..7d2d234959 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen5.c
@@ -203,8 +203,7 @@ qat_sym_crypto_cap_get_gen5(struct qat_cryptodev_private *internals,
 			continue;
 		}
 
-		memcpy(addr + curr_capa, capabilities + iter,
-			sizeof(struct rte_cryptodev_capabilities));
+		*(addr + curr_capa) = *(capabilities + iter);
 		curr_capa++;
 	}
 	internals->qat_dev_capabilities = internals->capa_mz->addr;
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 18/32] mempool/cnxk: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (16 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 17/32] crypto/qat: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 19/32] net/dpaa2: replace memcpy with assignment Stephen Hemminger
                   ` (13 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ashwin Sekhar T K, Pavan Nikhilesh

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/mempool/cnxk/cnxk_mempool_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mempool/cnxk/cnxk_mempool_ops.c b/drivers/mempool/cnxk/cnxk_mempool_ops.c
index bb35e2d1d2..5c7fcea487 100644
--- a/drivers/mempool/cnxk/cnxk_mempool_ops.c
+++ b/drivers/mempool/cnxk/cnxk_mempool_ops.c
@@ -103,7 +103,7 @@ cnxk_mempool_alloc(struct rte_mempool *mp)
 		struct npa_aura_s *paura;
 
 		paura = CNXK_MEMPOOL_CONFIG(mp);
-		memcpy(&aura, paura, sizeof(struct npa_aura_s));
+		aura = *paura;
 	}
 
 	rc = roc_npa_pool_create(&aura_handle, block_size, block_count, &aura,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 19/32] net/dpaa2: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (17 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 18/32] mempool/cnxk: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 20/32] net/enic: " Stephen Hemminger
                   ` (12 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/dpaa2/dpaa2_mux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
index 2f124313fa..3f259cd16f 100644
--- a/drivers/net/dpaa2/dpaa2_mux.c
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -293,7 +293,7 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 				ret);
 			goto creation_error;
 		}
-		rte_memcpy(&s_kg_cfg, &kg_cfg, sizeof(struct dpkg_profile_cfg));
+		s_kg_cfg = kg_cfg;
 	} else {
 		if (memcmp(&s_kg_cfg, &kg_cfg,
 			sizeof(struct dpkg_profile_cfg))) {
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 20/32] net/enic: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (18 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 19/32] net/dpaa2: replace memcpy with assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 21/32] net/intel/i40e: replace memcpy with structure assignment Stephen Hemminger
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, John Daley, Hyong Youb Kim

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/enic/enic_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index b755b15d92..82abcde322 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1238,7 +1238,7 @@ int enic_set_rss_reta(struct enic *enic, union vnic_rss_cpu *rss_cpu)
 	if (!rss_cpu_buf_va)
 		return -ENOMEM;
 
-	rte_memcpy(rss_cpu_buf_va, rss_cpu, sizeof(union vnic_rss_cpu));
+	*rss_cpu_buf_va = *rss_cpu;
 
 	err = enic_set_rss_cpu(enic,
 		rss_cpu_buf_pa,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 21/32] net/intel/i40e: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (19 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 20/32] net/enic: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 22/32] net/nfp: replace memcpy with assignment Stephen Hemminger
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Ian Stokes, Bruce Richardson, Anatoly Burakov,
	Vladimir Medvedkin

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/intel/i40e/i40e_ethdev.c  | 6 ++----
 drivers/net/intel/i40e/i40e_fdir.c    | 3 +--
 drivers/net/intel/i40e/i40e_flow.c    | 3 +--
 drivers/net/intel/i40e/rte_pmd_i40e.c | 3 +--
 drivers/net/intel/ixgbe/ixgbe_flow.c  | 4 +---
 5 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
index bf5560ccc8..8a7afd6dbe 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -5987,8 +5987,7 @@ i40e_vsi_setup(struct i40e_pf *pf,
 			PMD_DRV_LOG(ERR, "Failed to get VSI params");
 			goto fail_msix_alloc;
 		}
-		rte_memcpy(&vsi->info, &ctxt.info,
-			sizeof(struct i40e_aqc_vsi_properties_data));
+		vsi->info = ctxt.info;
 		vsi->vsi_id = ctxt.vsi_number;
 		vsi->info.valid_sections = 0;
 
@@ -6005,8 +6004,7 @@ i40e_vsi_setup(struct i40e_pf *pf,
 			rte_cpu_to_le_16(I40E_AQ_VSI_PROP_VLAN_VALID);
 		vsi->info.port_vlan_flags = I40E_AQ_VSI_PVLAN_MODE_ALL |
 					I40E_AQ_VSI_PVLAN_EMOD_STR_BOTH;
-		rte_memcpy(&ctxt.info, &vsi->info,
-			sizeof(struct i40e_aqc_vsi_properties_data));
+		ctxt.info = vsi->info;
 		ret = i40e_vsi_config_tc_queue_mapping(vsi, &ctxt.info,
 						I40E_DEFAULT_TCMAP);
 		if (ret != I40E_SUCCESS) {
diff --git a/drivers/net/intel/i40e/i40e_fdir.c b/drivers/net/intel/i40e/i40e_fdir.c
index 349627a2ed..3d0ba25cba 100644
--- a/drivers/net/intel/i40e/i40e_fdir.c
+++ b/drivers/net/intel/i40e/i40e_fdir.c
@@ -1252,8 +1252,7 @@ i40e_flow_store_flex_mask(struct i40e_pf *pf,
 			  sizeof(struct i40e_fdir_flex_mask))))
 		return 1;
 
-	memcpy(&pf->fdir.flex_mask[pctype], &flex_mask,
-	       sizeof(struct i40e_fdir_flex_mask));
+	pf->fdir.flex_mask[pctype] = flex_mask;
 	return 0;
 }
 
diff --git a/drivers/net/intel/i40e/i40e_flow.c b/drivers/net/intel/i40e/i40e_flow.c
index cd598431e1..f130f53ae0 100644
--- a/drivers/net/intel/i40e/i40e_flow.c
+++ b/drivers/net/intel/i40e/i40e_flow.c
@@ -2364,8 +2364,7 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 			next_dst_off += raw_spec->length;
 			raw_id++;
 
-			memcpy(&filter->input.flow_ext.flex_pit[field_idx],
-			       &flex_pit, sizeof(struct i40e_fdir_flex_pit));
+			filter->input.flow_ext.flex_pit[field_idx] = flex_pit;
 			filter->input.flow_ext.layer_idx = layer_idx;
 			filter->input.flow_ext.raw_id = raw_id;
 			filter->input.flow_ext.is_flex_flow = true;
diff --git a/drivers/net/intel/i40e/rte_pmd_i40e.c b/drivers/net/intel/i40e/rte_pmd_i40e.c
index 9d39984ea1..e620731199 100644
--- a/drivers/net/intel/i40e/rte_pmd_i40e.c
+++ b/drivers/net/intel/i40e/rte_pmd_i40e.c
@@ -2961,8 +2961,7 @@ i40e_queue_region_get_all_info(struct i40e_pf *pf,
 {
 	struct i40e_queue_regions *info = &pf->queue_region;
 
-	rte_memcpy(regions_ptr, info,
-			sizeof(struct i40e_queue_regions));
+	*regions_ptr = *info;
 
 	return 0;
 }
diff --git a/drivers/net/intel/ixgbe/ixgbe_flow.c b/drivers/net/intel/ixgbe/ixgbe_flow.c
index 33da2f47ec..be8f3072fb 100644
--- a/drivers/net/intel/ixgbe/ixgbe_flow.c
+++ b/drivers/net/intel/ixgbe/ixgbe_flow.c
@@ -3142,9 +3142,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
 		if (fdir_rule.b_mask) {
 			if (!fdir_info->mask_added) {
 				/* It's the first time the mask is set. */
-				rte_memcpy(&fdir_info->mask,
-					&fdir_rule.mask,
-					sizeof(struct ixgbe_hw_fdir_mask));
+				*&fdir_info->mask = *&fdir_rule.mask;
 
 				if (fdir_rule.mask.flex_bytes_mask) {
 					ret = ixgbe_fdir_set_flexbytes_offset(dev,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 22/32] net/nfp: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (20 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 21/32] net/intel/i40e: replace memcpy with structure assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 23/32] net/txgbe: " Stephen Hemminger
                   ` (9 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chaoyong He

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/nfp/flower/nfp_flower_representor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 9601aa5f96..ae0f082eb9 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -318,7 +318,7 @@ nfp_flower_repr_stats_get(struct rte_eth_dev *ethdev,
 	struct nfp_flower_representor *repr;
 
 	repr = ethdev->data->dev_private;
-	rte_memcpy(stats, &repr->repr_stats, sizeof(struct rte_eth_stats));
+	*stats = repr->repr_stats;
 
 	return 0;
 }
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 23/32] net/txgbe: replace memcpy with assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (21 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 22/32] net/nfp: replace memcpy with assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 24/32] net/bnx2x: replace memcpy with structure assignment Stephen Hemminger
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Jiawen Wu, Jian Wang

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/txgbe/txgbe_flow.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/txgbe/txgbe_flow.c b/drivers/net/txgbe/txgbe_flow.c
index 5d2dd45368..9e446c80c3 100644
--- a/drivers/net/txgbe/txgbe_flow.c
+++ b/drivers/net/txgbe/txgbe_flow.c
@@ -2827,9 +2827,7 @@ txgbe_flow_create(struct rte_eth_dev *dev,
 		if (fdir_rule.b_mask) {
 			if (!fdir_info->mask_added) {
 				/* It's the first time the mask is set. */
-				rte_memcpy(&fdir_info->mask,
-					&fdir_rule.mask,
-					sizeof(struct txgbe_hw_fdir_mask));
+				fdir_info->mask = fdir_rule.mask;
 				fdir_info->flex_bytes_offset =
 					fdir_rule.flex_bytes_offset;
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 24/32] net/bnx2x: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (22 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 23/32] net/txgbe: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 25/32] net/dpaa2: " Stephen Hemminger
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Julien Aube

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnx2x/bnx2x_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bnx2x/bnx2x_stats.c b/drivers/net/bnx2x/bnx2x_stats.c
index 8adbe7e381..b14139c052 100644
--- a/drivers/net/bnx2x/bnx2x_stats.c
+++ b/drivers/net/bnx2x/bnx2x_stats.c
@@ -805,7 +805,7 @@ bnx2x_hw_stats_update(struct bnx2x_softc *sc)
 				  etherstatspktsover1522octets);
 	}
 
-	memcpy(old, new, sizeof(struct nig_stats));
+	*old = *new;
 
 	memcpy(RTE_PTR_ADD(estats, offsetof(struct bnx2x_eth_stats, rx_stat_ifhcinbadoctets_hi)),
 	       &pstats->mac_stx[1], sizeof(struct mac_stx));
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 25/32] net/dpaa2: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (23 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 24/32] net/bnx2x: replace memcpy with structure assignment Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 26/32] net/bonding: " Stephen Hemminger
                   ` (6 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Hemant Agrawal, Sachin Saxena

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 5 ++---
 drivers/net/dpaa2/dpaa2_flow.c   | 9 +++------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index a9bce854c3..452d58ae28 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -2539,8 +2539,7 @@ populate_mac_addr(struct fsl_mc_io *dpni_dev,
 					      ret);
 				goto cleanup;
 			}
-			memcpy(&prime_mac, &phy_mac,
-				sizeof(struct rte_ether_addr));
+			prime_mac = phy_mac;
 		}
 	} else if (rte_is_zero_ether_addr(&prime_mac)) {
 		/* In case phys and prime, both are zero, create random MAC */
@@ -2555,7 +2554,7 @@ populate_mac_addr(struct fsl_mc_io *dpni_dev,
 	}
 
 	/* prime_mac the final MAC address */
-	memcpy(mac_entry, &prime_mac, sizeof(struct rte_ether_addr));
+	*mac_entry = prime_mac;
 	return 0;
 
 cleanup:
diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
index c94eb51ba5..299c50dcdf 100644
--- a/drivers/net/dpaa2/dpaa2_flow.c
+++ b/drivers/net/dpaa2/dpaa2_flow.c
@@ -1008,8 +1008,7 @@ dpaa2_flow_faf_add_hdr(int faf_byte,
 	if (pos != dpkg->num_extracts) {
 		/* Not the last pos, must have IP address extract.*/
 		for (i = dpkg->num_extracts - 1; i >= pos; i--) {
-			memcpy(&extracts[i + 1],
-				&extracts[i], sizeof(struct dpkg_extract));
+			extracts[i + 1] = extracts[i];
 		}
 	}
 
@@ -1063,8 +1062,7 @@ dpaa2_flow_pr_add_hdr(uint32_t pr_offset,
 	if (pos != dpkg->num_extracts) {
 		/* Not the last pos, must have IP address extract.*/
 		for (i = dpkg->num_extracts - 1; i >= pos; i--) {
-			memcpy(&extracts[i + 1],
-				&extracts[i], sizeof(struct dpkg_extract));
+			extracts[i + 1] = extracts[i];
 		}
 	}
 
@@ -1118,8 +1116,7 @@ dpaa2_flow_extract_add_hdr(enum net_prot prot,
 	if (pos != dpkg->num_extracts) {
 		/* Not the last pos, must have IP address extract.*/
 		for (i = dpkg->num_extracts - 1; i >= pos; i--) {
-			memcpy(&extracts[i + 1],
-				&extracts[i], sizeof(struct dpkg_extract));
+			extracts[i + 1] = extracts[i];
 		}
 	}
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 26/32] net/bonding: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (24 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 25/32] net/dpaa2: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 27/32] net/cnxk: " Stephen Hemminger
                   ` (5 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Chas Williams, Min Hu (Connor)

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 467f7fe7ea..c8fcd4a172 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3222,7 +3222,7 @@ bond_ethdev_rss_hash_update(struct rte_eth_dev *dev,
 	struct bond_dev_private *internals = dev->data->dev_private;
 	struct rte_eth_rss_conf bond_rss_conf;
 
-	memcpy(&bond_rss_conf, rss_conf, sizeof(struct rte_eth_rss_conf));
+	bond_rss_conf = *rss_conf;
 
 	bond_rss_conf.rss_hf &= internals->flow_type_rss_offloads;
 
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 27/32] net/cnxk: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (25 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 26/32] net/bonding: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 28/32] net/enic: " Stephen Hemminger
                   ` (4 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Nithin Dabilpuram, Kiran Kumar K,
	Sunil Kumar Kori, Satha Rao, Harman Kalra

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/cnxk/cnxk_ethdev_cman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/cnxk/cnxk_ethdev_cman.c b/drivers/net/cnxk/cnxk_ethdev_cman.c
index a7ccdfb756..75cbad02c4 100644
--- a/drivers/net/cnxk/cnxk_ethdev_cman.c
+++ b/drivers/net/cnxk/cnxk_ethdev_cman.c
@@ -140,6 +140,6 @@ cnxk_nix_cman_config_get(struct rte_eth_dev *eth_dev, struct rte_eth_cman_config
 {
 	struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
 
-	memcpy(config, &dev->cman_cfg, sizeof(struct rte_eth_cman_config));
+	*config = dev->cman_cfg;
 	return 0;
 }
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 28/32] net/enic: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (26 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 27/32] net/cnxk: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 29/32] net/iavf: " Stephen Hemminger
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, John Daley, Hyong Youb Kim

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/enic/enic_fm_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c
index 8988148454..c2c3e55206 100644
--- a/drivers/net/enic/enic_fm_flow.c
+++ b/drivers/net/enic/enic_fm_flow.c
@@ -2590,7 +2590,7 @@ enic_action_handle_get(struct enic_flowman *fm, struct fm_action *action_in,
 			return rte_flow_error_set(error, ENOMEM,
 					   RTE_FLOW_ERROR_TYPE_HANDLE,
 					   NULL, "enic: calloc(fm-action)");
-		memcpy(&ah->key, action_in, sizeof(struct fm_action));
+		ah->key = *action_in;
 		args[0] = FM_ACTION_ALLOC;
 		args[1] = fm->cmd.pa;
 		ret = flowman_cmd(fm, args, 2);
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 29/32] net/iavf: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (27 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 28/32] net/enic: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 30/32] net/ice: " Stephen Hemminger
                   ` (2 subsequent siblings)
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Vladimir Medvedkin, Ian Stokes

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/intel/iavf/iavf_ipsec_crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/intel/iavf/iavf_ipsec_crypto.c b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
index 90421a66c3..d5bfbecf08 100644
--- a/drivers/net/intel/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
@@ -1139,8 +1139,7 @@ iavf_ipsec_crypto_pkt_metadata_set(void *device,
 		struct iavf_ipsec_crypto_pkt_metadata *);
 
 	/* Set immutable metadata values from session template */
-	memcpy(md, &iavf_sess->pkt_metadata_template,
-		sizeof(struct iavf_ipsec_crypto_pkt_metadata));
+	*md = iavf_sess->pkt_metadata_template;
 
 	esp_tail = iavf_ipsec_crypto_get_esp_trailer(m, iavf_sess,
 			&esp_trailer_length);
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 30/32] net/ice: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (28 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 29/32] net/iavf: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 31/32] test: " Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 32/32] test/cryptodev: " Stephen Hemminger
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Bruce Richardson, Anatoly Burakov

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/intel/ice/ice_hash.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/intel/ice/ice_hash.c b/drivers/net/intel/ice/ice_hash.c
index 00d65bc637..aa6a21c055 100644
--- a/drivers/net/intel/ice/ice_hash.c
+++ b/drivers/net/intel/ice/ice_hash.c
@@ -1309,8 +1309,7 @@ ice_hash_create(struct ice_adapter *ad,
 		goto out;
 	} else {
 		if (rss_meta->raw.raw_ena) {
-			memcpy(&filter_ptr->rss_cfg.raw, &rss_meta->raw,
-			       sizeof(struct ice_rss_raw_cfg));
+			filter_ptr->rss_cfg.raw = rss_meta->raw;
 			ret = ice_hash_add_raw_cfg(ad, &rss_meta->raw,
 						   pf->main_vsi->idx);
 			if (ret) {
@@ -1321,8 +1320,7 @@ ice_hash_create(struct ice_adapter *ad,
 				goto error;
 			}
 		} else {
-			memcpy(&filter_ptr->rss_cfg.hash, &rss_meta->cfg,
-			       sizeof(struct ice_rss_hash_cfg));
+			filter_ptr->rss_cfg.hash = rss_meta->cfg;
 			ret = ice_add_rss_cfg_wrap(pf, vsi->idx,
 						   &filter_ptr->rss_cfg.hash);
 			if (ret) {
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 31/32] test: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (29 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 30/32] net/ice: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  2025-02-08 20:22 ` [PATCH 32/32] test/cryptodev: " Stephen Hemminger
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Konstantin Ananyev, Fan Zhang, Ashish Gupta,
	Akhil Goyal, Anoob Joseph

Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_acl.c                   |  5 ++--
 app/test/test_compressdev.c           | 36 +++++++++------------------
 app/test/test_security_inline_proto.c | 23 +++++++----------
 3 files changed, 23 insertions(+), 41 deletions(-)

diff --git a/app/test/test_acl.c b/app/test/test_acl.c
index 503ff08894..43d13b5b0f 100644
--- a/app/test/test_acl.c
+++ b/app/test/test_acl.c
@@ -1223,8 +1223,7 @@ test_create_find_add(void)
 
 	/* create dummy acl */
 	for (i = 0; i < LEN; i++) {
-		memcpy(&rules[i], &acl_rule,
-			sizeof(struct rte_acl_ipv4vlan_rule));
+		rules[i] = acl_rule;
 		/* skip zero */
 		rules[i].data.userdata = i + 1;
 		/* one rule per category */
@@ -1286,7 +1285,7 @@ test_invalid_rules(void)
 	 * such rules.
 	 */
 	/* create dummy acl */
-	memcpy(&rule, &acl_rule, sizeof(struct rte_acl_ipv4vlan_rule));
+	rule = acl_rule;
 	rule.data.userdata = 1;
 	rule.dst_port_low = 0xfff0;
 	rule.dst_port_high = 0x0010;
diff --git a/app/test/test_compressdev.c b/app/test/test_compressdev.c
index 81b8e02006..c217ad6cda 100644
--- a/app/test/test_compressdev.c
+++ b/app/test/test_compressdev.c
@@ -346,8 +346,7 @@ test_compressdev_invalid_configuration(void)
 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
 
 	/* Invalid configuration with 0 queue pairs */
-	memcpy(&invalid_config, &valid_config,
-			sizeof(struct rte_compressdev_config));
+	invalid_config = valid_config;
 	invalid_config.nb_queue_pairs = 0;
 
 	TEST_ASSERT_FAIL(rte_compressdev_configure(0, &invalid_config),
@@ -360,8 +359,7 @@ test_compressdev_invalid_configuration(void)
 	 */
 	rte_compressdev_info_get(0, &dev_info);
 	if (dev_info.max_nb_queue_pairs != 0) {
-		memcpy(&invalid_config, &valid_config,
-			sizeof(struct rte_compressdev_config));
+		invalid_config = valid_config;
 		invalid_config.nb_queue_pairs = dev_info.max_nb_queue_pairs + 1;
 
 		TEST_ASSERT_FAIL(rte_compressdev_configure(0, &invalid_config),
@@ -2188,8 +2186,7 @@ test_compressdev_deflate_stateless_fixed(void)
 		goto exit;
 	}
 
-	memcpy(compress_xform, ts_params->def_comp_xform,
-			sizeof(struct rte_comp_xform));
+	*compress_xform = *ts_params->def_comp_xform;
 	compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_FIXED;
 
 	struct interim_data_params int_data = {
@@ -2260,8 +2257,7 @@ test_compressdev_deflate_stateless_dynamic(void)
 		goto exit;
 	}
 
-	memcpy(compress_xform, ts_params->def_comp_xform,
-			sizeof(struct rte_comp_xform));
+	*compress_xform = *ts_params->def_comp_xform;
 	compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_DYNAMIC;
 
 	struct interim_data_params int_data = {
@@ -2372,8 +2368,7 @@ test_compressdev_deflate_stateless_multi_level(void)
 		goto exit;
 	}
 
-	memcpy(compress_xform, ts_params->def_comp_xform,
-			sizeof(struct rte_comp_xform));
+	*compress_xform = *ts_params->def_comp_xform;
 
 	struct interim_data_params int_data = {
 		NULL,
@@ -2442,8 +2437,7 @@ test_compressdev_deflate_stateless_multi_xform(void)
 			goto exit;
 		}
 
-		memcpy(compress_xforms[i], ts_params->def_comp_xform,
-				sizeof(struct rte_comp_xform));
+		*compress_xforms[i] = *ts_params->def_comp_xform;
 		compress_xforms[i]->compress.level = level;
 		level++;
 
@@ -2456,8 +2450,7 @@ test_compressdev_deflate_stateless_multi_xform(void)
 			goto exit;
 		}
 
-		memcpy(decompress_xforms[i], ts_params->def_decomp_xform,
-				sizeof(struct rte_comp_xform));
+		*decompress_xforms[i] = *ts_params->def_decomp_xform;
 	}
 
 	for (i = 0; i < NUM_XFORMS; i++) {
@@ -2614,8 +2607,7 @@ test_compressdev_deflate_stateless_checksum(void)
 		return TEST_FAILED;
 	}
 
-	memcpy(compress_xform, ts_params->def_comp_xform,
-			sizeof(struct rte_comp_xform));
+	*compress_xform = *ts_params->def_comp_xform;
 
 	struct rte_comp_xform *decompress_xform =
 			rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
@@ -2625,8 +2617,7 @@ test_compressdev_deflate_stateless_checksum(void)
 		return TEST_FAILED;
 	}
 
-	memcpy(decompress_xform, ts_params->def_decomp_xform,
-			sizeof(struct rte_comp_xform));
+	*decompress_xform = *ts_params->def_decomp_xform;
 
 	struct interim_data_params int_data = {
 		NULL,
@@ -2960,8 +2951,7 @@ test_compressdev_deflate_stateful_decomp_checksum(void)
 		return TEST_FAILED;
 	}
 
-	memcpy(compress_xform, ts_params->def_comp_xform,
-	       sizeof(struct rte_comp_xform));
+	*compress_xform = *ts_params->def_comp_xform;
 
 	struct rte_comp_xform *decompress_xform =
 			rte_malloc(NULL, sizeof(struct rte_comp_xform), 0);
@@ -2971,8 +2961,7 @@ test_compressdev_deflate_stateful_decomp_checksum(void)
 		return TEST_FAILED;
 	}
 
-	memcpy(decompress_xform, ts_params->def_decomp_xform,
-	       sizeof(struct rte_comp_xform));
+	*decompress_xform = *ts_params->def_decomp_xform;
 
 	struct interim_data_params int_data = {
 		&compress_test_bufs[0],
@@ -3186,8 +3175,7 @@ test_compressdev_deflate_stateless_fixed_oos_recoverable(void)
 		goto exit;
 	}
 
-	memcpy(compress_xform, ts_params->def_comp_xform,
-			sizeof(struct rte_comp_xform));
+	*compress_xform = *ts_params->def_comp_xform;
 	compress_xform->compress.deflate.huffman = RTE_COMP_HUFFMAN_FIXED;
 
 	struct interim_data_params int_data = {
diff --git a/app/test/test_security_inline_proto.c b/app/test/test_security_inline_proto.c
index 480469f672..04ecfd02c6 100644
--- a/app/test/test_security_inline_proto.c
+++ b/app/test/test_security_inline_proto.c
@@ -858,7 +858,7 @@ test_ipsec_with_rx_inject(struct ip_pkt_vector *vector, const struct ipsec_test_
 	burst_sz = vector->burst ? ENCAP_DECAP_BURST_SZ : 1;
 	nb_tx = burst_sz;
 
-	memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data));
+	sa_data = *vector->sa_data;
 	sa_data.ipsec_xform.direction =	RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
 	outer_ipv4 = is_outer_ipv4(&sa_data);
 
@@ -873,7 +873,7 @@ test_ipsec_with_rx_inject(struct ip_pkt_vector *vector, const struct ipsec_test_
 	}
 
 	for (i = 0; i < burst_sz; i++) {
-		memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data));
+		sa_data = *vector->sa_data;
 		/* Update SPI for every new SA */
 		sa_data.ipsec_xform.spi += i;
 		sa_data.ipsec_xform.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
@@ -901,7 +901,7 @@ test_ipsec_with_rx_inject(struct ip_pkt_vector *vector, const struct ipsec_test_
 	}
 
 	for (i = 0; i < burst_sz; i++) {
-		memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data));
+		sa_data = *vector->sa_data;
 		/* Update SPI for every new SA */
 		sa_data.ipsec_xform.spi += i;
 		sa_data.ipsec_xform.direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS;
@@ -1078,7 +1078,7 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector,
 	memset(tx_pkts_burst, 0, sizeof(tx_pkts_burst[0]) * nb_tx);
 	memset(rx_pkts_burst, 0, sizeof(rx_pkts_burst[0]) * nb_tx);
 
-	memcpy(&sa_data, vector->sa_data, sizeof(struct ipsec_test_data));
+	sa_data = *vector->sa_data;
 	sa_data.ipsec_xform.direction =	RTE_SECURITY_IPSEC_SA_DIR_EGRESS;
 	outer_ipv4 = is_outer_ipv4(&sa_data);
 
@@ -1096,8 +1096,7 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector,
 	}
 
 	for (i = 0; i < burst_sz; i++) {
-		memcpy(&sa_data, vector->sa_data,
-				sizeof(struct ipsec_test_data));
+		sa_data = *vector->sa_data;
 		/* Update SPI for every new SA */
 		sa_data.ipsec_xform.spi += i;
 		sa_data.ipsec_xform.direction =
@@ -1132,8 +1131,7 @@ test_ipsec_with_reassembly(struct reassembly_vector *vector,
 	}
 
 	for (i = 0; i < burst_sz; i++) {
-		memcpy(&sa_data, vector->sa_data,
-				sizeof(struct ipsec_test_data));
+		sa_data = *vector->sa_data;
 		/* Update SPI for every new SA */
 		sa_data.ipsec_xform.spi += i;
 		sa_data.ipsec_xform.direction =
@@ -2371,13 +2369,11 @@ test_inline_ip_reassembly(const void *testdata)
 	reassembly_td.nb_frags = td->nb_frags;
 	reassembly_td.burst = td->burst;
 
-	memcpy(&full_pkt, td->full_pkt,
-			sizeof(struct ip_reassembly_test_packet));
+	full_pkt = *td->full_pkt;
 	reassembly_td.full_pkt = &full_pkt;
 
 	for (; i < reassembly_td.nb_frags; i++) {
-		memcpy(&frags[i], td->frags[i],
-			sizeof(struct ip_reassembly_test_packet));
+		frags[i] = *td->frags[i];
 		reassembly_td.frags[i] = &frags[i];
 
 		/* Add extra data for multi-seg test on all fragments except last one */
@@ -2466,8 +2462,7 @@ test_ipsec_inline_proto_rx_inj_inb(const void *test_data)
 	out_td.sa_data = td->sa_data;
 	out_td.burst = td->burst;
 
-	memcpy(&full_pkt, td->full_pkt,
-			sizeof(struct ip_reassembly_test_packet));
+	full_pkt = *td->full_pkt;
 	out_td.full_pkt = &full_pkt;
 
 	/* Add extra data for multi-seg test */
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 32/32] test/cryptodev: replace memcpy with structure assignment
  2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
                   ` (30 preceding siblings ...)
  2025-02-08 20:22 ` [PATCH 31/32] test: " Stephen Hemminger
@ 2025-02-08 20:22 ` Stephen Hemminger
  31 siblings, 0 replies; 33+ messages in thread
From: Stephen Hemminger @ 2025-02-08 20:22 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang

Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_cryptodev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 441ecc6ad5..50518dc5c6 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -14837,8 +14837,7 @@ test_multi_session_random_usage(void)
 
 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
 
-		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
-				sizeof(struct crypto_unittest_params));
+		ut_paramz[i].ut_params = unittest_params;
 
 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
 				&ut_paramz[i].ut_params,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2025-02-08 20:34 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-08 20:21 [PATCH 00/32] Use structure assignment instead of memcpy Stephen Hemminger
2025-02-08 20:21 ` [PATCH 01/32] devtools/cocci: prefer structure assignment over memcpy Stephen Hemminger
2025-02-08 20:21 ` [PATCH 02/32] app/testpmd: replace memcpy with assignment Stephen Hemminger
2025-02-08 20:21 ` [PATCH 03/32] app/graph: replace memcpy with structure assignment Stephen Hemminger
2025-02-08 20:21 ` [PATCH 04/32] crypto/dpaa_sec: replace memcpy with assignment Stephen Hemminger
2025-02-08 20:21 ` [PATCH 05/32] dma/dpaa2: " Stephen Hemminger
2025-02-08 20:21 ` [PATCH 06/32] eventdev: " Stephen Hemminger
2025-02-08 20:21 ` [PATCH 07/32] event/dpaa2: replace memcpy with structure assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 08/32] event/dsw: replace memcpy with assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 09/32] ml/cnxk: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 10/32] examples: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 11/32] node: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 12/32] pipeline: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 13/32] sched: replace memcpy with structure assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 14/32] table: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 15/32] net/ntnic: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 16/32] net/bnxt: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 17/32] crypto/qat: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 18/32] mempool/cnxk: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 19/32] net/dpaa2: replace memcpy with assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 20/32] net/enic: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 21/32] net/intel/i40e: replace memcpy with structure assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 22/32] net/nfp: replace memcpy with assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 23/32] net/txgbe: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 24/32] net/bnx2x: replace memcpy with structure assignment Stephen Hemminger
2025-02-08 20:22 ` [PATCH 25/32] net/dpaa2: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 26/32] net/bonding: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 27/32] net/cnxk: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 28/32] net/enic: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 29/32] net/iavf: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 30/32] net/ice: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 31/32] test: " Stephen Hemminger
2025-02-08 20:22 ` [PATCH 32/32] test/cryptodev: " Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).