From: Somnath Kotur <somnath.kotur@broadcom.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org, Ajit Khaparde <ajit.khaparde@broadcom.com>
Subject: Re: [PATCH 16/32] net/bnxt: replace memcpy with structure assignment
Date: Mon, 10 Feb 2025 08:26:15 +0530 [thread overview]
Message-ID: <CAOBf=msU1U=E8kACR+MH3E-_VPzazFAkrtmUW5GUr8R4UhE9xA@mail.gmail.com> (raw)
In-Reply-To: <20250208203142.242284-17-stephen@networkplumber.org>
[-- Attachment #1: Type: text/plain, Size: 2755 bytes --]
On Sun, Feb 9, 2025 at 2:02 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> 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
>
Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4212 bytes --]
next prev parent reply other threads:[~2025-02-10 2:56 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 [this message]
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
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='CAOBf=msU1U=E8kACR+MH3E-_VPzazFAkrtmUW5GUr8R4UhE9xA@mail.gmail.com' \
--to=somnath.kotur@broadcom.com \
--cc=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--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).