diff mbox series

[ndctl,2/4] ndctl/namespace.c: fix an unchecked return value

Message ID 20190510190839.29637-3-vishal.l.verma@intel.com (mailing list archive)
State Accepted
Commit 1265cd7bc8683d2ce6e6aa05eb4cd282a485f5d3
Headers show
Series static analysis fixes | expand

Commit Message

Verma, Vishal L May 10, 2019, 7:08 p.m. UTC
Static analysis complains that we were neglecting to check the return
value from the ndctl_enable_namespace call in nstype_clear_badblocks.

The instance pointed out is in an error-out path, so there isn't much to
do there, however if the enable fails, we can check for it and print a
message. This ends up being more user friendly in addition to quelling
the warning.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/namespace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index e281298..31e6ecd 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -1134,8 +1134,10 @@  static int nstype_clear_badblocks(struct ndctl_namespace *ndns,
 
 	region_begin = ndctl_region_get_resource(region);
 	if (region_begin == ULLONG_MAX) {
-		ndctl_namespace_enable(ndns);
-		return -errno;
+		rc = -errno;
+		if (ndctl_namespace_enable(ndns) < 0)
+			error("%s: failed to reenable namespace\n", devname);
+		return rc;
 	}
 
 	dev_end = dev_begin + dev_size - 1;