From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Ian Stokes <ian.stokes@intel.com>,
Bruce Richardson <bruce.richardson@intel.com>,
Anatoly Burakov <anatoly.burakov@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Subject: [PATCH 21/32] net/intel/i40e: replace memcpy with structure assignment
Date: Sat, 8 Feb 2025 12:22:13 -0800 [thread overview]
Message-ID: <20250208203142.242284-22-stephen@networkplumber.org> (raw)
In-Reply-To: <20250208203142.242284-1-stephen@networkplumber.org>
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
next prev parent reply other threads:[~2025-02-08 20:33 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Stephen Hemminger [this message]
2025-02-08 20:22 ` [PATCH 22/32] net/nfp: " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250208203142.242284-22-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ian.stokes@intel.com \
--cc=vladimir.medvedkin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).