From: Hemant Agrawal <hemant.agrawal@oss.nxp.com>
To: Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org
Cc: Hemant Agrawal <hemant.agrawal@nxp.com>,
Sachin Saxena <sachin.saxena@nxp.com>
Subject: Re: [PATCH 25/32] net/dpaa2: replace memcpy with structure assignment
Date: Mon, 10 Feb 2025 16:10:04 +0530 [thread overview]
Message-ID: <a28bee31-d753-9203-f84d-00c272cf346e@oss.nxp.com> (raw)
In-Reply-To: <20250208203142.242284-26-stephen@networkplumber.org>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
On 09-02-2025 01:52, Stephen Hemminger wrote:
> 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];
> }
> }
>
next prev parent reply other threads:[~2025-02-10 10:40 UTC|newest]
Thread overview: 40+ 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-10 10:38 ` Hemant Agrawal
2025-02-08 20:21 ` [PATCH 05/32] dma/dpaa2: " Stephen Hemminger
2025-02-10 10:42 ` Hemant Agrawal
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-10 10:39 ` Hemant Agrawal
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-10 2:56 ` Somnath Kotur
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-10 10:39 ` Hemant Agrawal
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-10 1:13 ` Chaoyong He
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-10 10:40 ` Hemant Agrawal [this message]
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=a28bee31-d753-9203-f84d-00c272cf346e@oss.nxp.com \
--to=hemant.agrawal@oss.nxp.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=sachin.saxena@nxp.com \
--cc=stephen@networkplumber.org \
/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).