Prefer structure assignment over memcpy.
Found by cocci/struct_assign.cocci

Signed-off-by: Stephen Hemminger <step...@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

Reply via email to