Messages in this thread Patch in this message | | | From | Zhen Lei <> | Subject | [PATCH v3 5/7] libnvdimm: reduce an unnecessary if branch in nd_region_activate() | Date | Thu, 20 Aug 2020 10:16:39 +0800 |
| |
According to the original code logic: if (!nvdimm->num_flush) { flush_data_size += sizeof(void *); //nvdimm->num_flush is zero now, add 1) have no side effects } else { flush_data_size += sizeof(void *); 1) flush_data_size += nvdimm->num_flush * sizeof(void *); }
Obviously, the above code snippet can be reduced to one statement: flush_data_size += (nvdimm->num_flush + 1) * sizeof(void *);
No functional change.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> --- drivers/nvdimm/region_devs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index 7cf9c7d857909ce..49be115c9189eff 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -77,11 +77,8 @@ int nd_region_activate(struct nd_region *nd_region) } /* at least one null hint slot per-dimm for the "no-hint" case */ - flush_data_size += sizeof(void *); + flush_data_size += (nvdimm->num_flush + 1) * sizeof(void *); num_flush = min_not_zero(num_flush, nvdimm->num_flush); - if (!nvdimm->num_flush) - continue; - flush_data_size += nvdimm->num_flush * sizeof(void *); } nvdimm_bus_unlock(&nd_region->dev); -- 1.8.3
| |