diff mbox

[ndctl,1/4] ndctl, inject-error: error out for a non-existent namespace

Message ID 20180208210428.7285-1-vishal.l.verma@intel.com (mailing list archive)
State Accepted
Commit 6373ebd0c186
Headers show

Commit Message

Verma, Vishal L Feb. 8, 2018, 9:04 p.m. UTC
When an invalid namespace was specified, inject-error would simply walk
through a loop trying to matching namespace, and at the end, exit out
silently. This could make it look as though the operation had been
successful, when in reality, nothing had been done.

Fix to print a message, and exit with an ENXIO when this happens.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/inject-error.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/ndctl/inject-error.c b/ndctl/inject-error.c
index 9b9d821..efa9f92 100644
--- a/ndctl/inject-error.c
+++ b/ndctl/inject-error.c
@@ -338,7 +338,8 @@  static int do_inject(const char *namespace, struct ndctl_ctx *ctx)
 		}
 	}
 
-	return 0;
+	error("%s: no such namespace\n", namespace);
+	return rc;
 }
 
 int cmd_inject_error(int argc, const char **argv, void *ctx)