From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Nicolas Chautru <nicolas.chautru@intel.com>,
Tomasz Kantecki <tomasz.kantecki@intel.com>,
Kirill Rybalchenko <kirill.rybalchenko@intel.com>
Subject: [PATCH 10/32] examples: replace memcpy with assignment
Date: Sat, 8 Feb 2025 12:22:02 -0800 [thread overview]
Message-ID: <20250208203142.242284-11-stephen@networkplumber.org> (raw)
In-Reply-To: <20250208203142.242284-1-stephen@networkplumber.org>
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
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 ` Stephen Hemminger [this message]
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
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-11-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=kirill.rybalchenko@intel.com \
--cc=nicolas.chautru@intel.com \
--cc=tomasz.kantecki@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).