Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1572968 > unrolled thread
| Started by | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| First post | 2017-02-03 10:40 +0100 |
| Last post | 2017-02-06 14:10 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] iommu: to avoid an unnecessary assignment Zhen Lei <thunder.leizhen@huawei.com> - 2017-02-03 10:40 +0100
Re: [PATCH 1/1] iommu: to avoid an unnecessary assignment Robin Murphy <robin.murphy@arm.com> - 2017-02-03 12:40 +0100
Re: [PATCH 1/1] iommu: to avoid an unnecessary assignment Joerg Roedel <joro@8bytes.org> - 2017-02-06 14:10 +0100
| From | Zhen Lei <thunder.leizhen@huawei.com> |
|---|---|
| Date | 2017-02-03 10:40 +0100 |
| Subject | [PATCH 1/1] iommu: to avoid an unnecessary assignment |
| Message-ID | <t6Ivv-8fS-11@gated-at.bofh.it> |
Move the assignment statement into if branch above, where it only needs to be. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index dbe7f65..b231400 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1714,13 +1714,14 @@ int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids) fwspec = krealloc(dev->iommu_fwspec, size, GFP_KERNEL); if (!fwspec) return -ENOMEM; + + dev->iommu_fwspec = fwspec; } for (i = 0; i < num_ids; i++) fwspec->ids[fwspec->num_ids + i] = ids[i]; fwspec->num_ids += num_ids; - dev->iommu_fwspec = fwspec; return 0; } EXPORT_SYMBOL_GPL(iommu_fwspec_add_ids); -- 2.5.0
[toc] | [next] | [standalone]
| From | Robin Murphy <robin.murphy@arm.com> |
|---|---|
| Date | 2017-02-03 12:40 +0100 |
| Message-ID | <t6KnE-10D-15@gated-at.bofh.it> |
| In reply to | #1572968 |
On 03/02/17 09:35, Zhen Lei wrote: > Move the assignment statement into if branch above, where it only > needs to be. > > Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> > --- > drivers/iommu/iommu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index dbe7f65..b231400 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -1714,13 +1714,14 @@ int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids) > fwspec = krealloc(dev->iommu_fwspec, size, GFP_KERNEL); > if (!fwspec) > return -ENOMEM; > + > + dev->iommu_fwspec = fwspec; > } > > for (i = 0; i < num_ids; i++) > fwspec->ids[fwspec->num_ids + i] = ids[i]; > > fwspec->num_ids += num_ids; > - dev->iommu_fwspec = fwspec; Strictly, it was done here because I like following transactional idioms, i.e. at any point dev->fwspec is either the old one or the fully-initialised new one. However, since the state of the new one immediately after realloc isn't uninitialised, but still directly equivalent to the old one, I don't see an issue with moving the assignemnt there, plus it does avoid a redundant reassignment the first time through. Reviewed-by: Robin Murphy <robin.murphy@arm.com> > return 0; > } > EXPORT_SYMBOL_GPL(iommu_fwspec_add_ids); > -- > 2.5.0 > > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu >
[toc] | [prev] | [next] | [standalone]
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Date | 2017-02-06 14:10 +0100 |
| Message-ID | <t7Rdo-5m6-19@gated-at.bofh.it> |
| In reply to | #1572968 |
On Fri, Feb 03, 2017 at 05:35:02PM +0800, Zhen Lei wrote: > Move the assignment statement into if branch above, where it only > needs to be. > > Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> > --- > drivers/iommu/iommu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Applied, thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web