From 68dae408433cc7d4d2176fe72ddc298286635ca9 Mon Sep 17 00:00:00 2001 From: KLZ-0 Date: Fri, 1 May 2020 23:49:33 +0200 Subject: [PATCH] Emit a warning message when no controller-id is specified --- nvme.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nvme.c b/nvme.c index e2e2abf..df803ef 100644 --- a/nvme.c +++ b/nvme.c @@ -1058,7 +1058,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s __u16 ctrlist[2048]; const char *namespace_id = "namespace to attach"; - const char *cont = "comma-sep controller id list"; + const char *cont = "optional comma-sep controller id list"; struct config { char *cntlist; @@ -1088,7 +1088,11 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s } num = argconfig_parse_comma_sep_array(cfg.cntlist, list, 2047); - if (num < 1) { + if (!num) { + fprintf(stderr, "warning: empty controller-id list will result in no actual change in namespace attachment\n"); + } + + if (num == -1) { fprintf(stderr, "%s: controller id list is required\n", cmd->name); err = -EINVAL; -- 2.49.0