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