On Sun, Feb 9, 2025 at 2:02 AM Stephen Hemminger wrote: > > Prefer structure assignment over memcpy. > Found by struct-assign.cocci. > > Signed-off-by: Stephen Hemminger > --- > 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