Skip to content

Commit 53fc595

Browse files
andy-shevdjbw
authored andcommitted
nvdimm/namespace: drop unneeded temporary variable in size_store()
Refactor size_store() in order to remove temporary variable on stack by joining conditionals. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 36a40c3 commit 53fc595

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

drivers/nvdimm/namespace_devs.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ static ssize_t size_store(struct device *dev,
836836
{
837837
struct nd_region *nd_region = to_nd_region(dev->parent);
838838
unsigned long long val;
839-
uuid_t **uuid = NULL;
840839
int rc;
841840

842841
rc = kstrtoull(buf, 0, &val);
@@ -850,16 +849,12 @@ static ssize_t size_store(struct device *dev,
850849
if (rc >= 0)
851850
rc = nd_namespace_label_update(nd_region, dev);
852851

853-
if (is_namespace_pmem(dev)) {
852+
/* setting size zero == 'delete namespace' */
853+
if (rc == 0 && val == 0 && is_namespace_pmem(dev)) {
854854
struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev);
855855

856-
uuid = &nspm->uuid;
857-
}
858-
859-
if (rc == 0 && val == 0 && uuid) {
860-
/* setting size zero == 'delete namespace' */
861-
kfree(*uuid);
862-
*uuid = NULL;
856+
kfree(nspm->uuid);
857+
nspm->uuid = NULL;
863858
}
864859

865860
dev_dbg(dev, "%llx %s (%d)\n", val, rc < 0 ? "fail" : "success", rc);

0 commit comments

Comments
 (0)