[15/32] net/ntnic: replace memcpy with structure assignment

Message ID 20250208203142.242284-16-stephen@networkplumber.org (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series Use structure assignment instead of memcpy |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 8, 2025, 8:22 p.m. UTC
Prefer structure assignment over memcpy.
Found by struct-assign.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ntnic/nthw/flow_api/flow_id_table.c               | 4 ++--
 .../nthw/flow_api/profile_inline/flow_api_profile_inline.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
index a63f5542d1..61cec41590 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_id_table.c
@@ -99,7 +99,7 @@  uint32_t ntnic_id_table_get_id(void *id_table, union flm_handles flm_h, uint8_t
 	struct ntnic_id_table_element *element = ntnic_id_table_array_find_element(handle, new_id);
 	element->caller_id = caller_id;
 	element->type = type;
-	memcpy(&element->handle, &flm_h, sizeof(union flm_handles));
+	element->handle = flm_h;
 
 	rte_spinlock_unlock(&handle->mtx);
 
@@ -139,7 +139,7 @@  void ntnic_id_table_find(void *id_table, uint32_t id, union flm_handles *flm_h,
 
 	*caller_id = element->caller_id;
 	*type = element->type;
-	memcpy(flm_h, &element->handle, sizeof(union flm_handles));
+	*flm_h = element->handle;
 
 	rte_spinlock_unlock(&handle->mtx);
 }
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index ff8eb502f4..5565a7857c 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -3099,7 +3099,7 @@  static int convert_fh_to_fh_flm(struct flow_handle *fh, const uint32_t *packet_d
 	if (fh->type != FLOW_HANDLE_TYPE_FLOW)
 		return -1;
 
-	memcpy(&fh_copy, fh, sizeof(struct flow_handle));
+	fh_copy = *fh;
 	memset(fh, 0x0, sizeof(struct flow_handle));
 	fd = fh_copy.fd;