lkml.org 
[lkml]   [2020]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 5/7] libnvdimm: reduce an unnecessary if branch in nd_region_activate()
Date
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

\
 
 \ /
  Last update: 2020-08-20 04:18    [W:0.117 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site