Message ID | 1478506083-14560-6-git-send-email-feng.wu@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Nov 07, 2016 at 04:08:02PM +0800, Feng Wu wrote: > Use type-safe structure assignment instead of memcpy() > Use sizeof(*iremap_entry). > > > Signed-off-by: Feng Wu <feng.wu@intel.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> > --- > v7: > - Remove a useless cleanup > > v6: > - More descripion about the patch > > xen/drivers/passthrough/vtd/intremap.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c > index 3f8c109..00a4bc1 100644 > --- a/xen/drivers/passthrough/vtd/intremap.c > +++ b/xen/drivers/passthrough/vtd/intremap.c > @@ -183,8 +183,8 @@ static void free_remap_entry(struct iommu *iommu, int index) > GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, > iremap_entries, iremap_entry); > > - memset(iremap_entry, 0, sizeof(struct iremap_entry)); > - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); > + memset(iremap_entry, 0, sizeof(*iremap_entry)); > + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); > iommu_flush_iec_index(iommu, 0, index); > > unmap_vtd_domain_page(iremap_entries); > @@ -310,7 +310,7 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, > GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, > iremap_entries, iremap_entry); > > - memcpy(&new_ire, iremap_entry, sizeof(struct iremap_entry)); > + new_ire = *iremap_entry; > > if ( rte_upper ) > { > @@ -353,8 +353,8 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, > remap_rte->format = 1; /* indicate remap format */ > } > > - memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry)); > - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); > + *iremap_entry = new_ire; > + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); > iommu_flush_iec_index(iommu, 0, index); > > unmap_vtd_domain_page(iremap_entries); > @@ -642,8 +642,8 @@ static int msi_msg_to_remap_entry( > > if ( iremap_entry->val != new_ire.val ) > { > - memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry)); > - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); > + *iremap_entry = new_ire; > + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); > iommu_flush_iec_index(iommu, 0, index); > } > > -- > 2.1.0 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > https://lists.xen.org/xen-devel
diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 3f8c109..00a4bc1 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -183,8 +183,8 @@ static void free_remap_entry(struct iommu *iommu, int index) GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); - memset(iremap_entry, 0, sizeof(struct iremap_entry)); - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); + memset(iremap_entry, 0, sizeof(*iremap_entry)); + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); unmap_vtd_domain_page(iremap_entries); @@ -310,7 +310,7 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, GET_IREMAP_ENTRY(ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); - memcpy(&new_ire, iremap_entry, sizeof(struct iremap_entry)); + new_ire = *iremap_entry; if ( rte_upper ) { @@ -353,8 +353,8 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, remap_rte->format = 1; /* indicate remap format */ } - memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry)); - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); + *iremap_entry = new_ire; + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); unmap_vtd_domain_page(iremap_entries); @@ -642,8 +642,8 @@ static int msi_msg_to_remap_entry( if ( iremap_entry->val != new_ire.val ) { - memcpy(iremap_entry, &new_ire, sizeof(struct iremap_entry)); - iommu_flush_cache_entry(iremap_entry, sizeof(struct iremap_entry)); + *iremap_entry = new_ire; + iommu_flush_cache_entry(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); }
Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry). Signed-off-by: Feng Wu <feng.wu@intel.com> --- v7: - Remove a useless cleanup v6: - More descripion about the patch xen/drivers/passthrough/vtd/intremap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)