From: Minwoo Im Date: Thu, 23 May 2019 14:16:54 +0000 (+0900) Subject: fabrics: Do not return in the middle of the subcommand X-Git-Tag: v1.9~39^2~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d3f37a54a363400119d512bfd74cbc5f1fb12b3c;p=users%2Fsagi%2Fnvme-cli.git fabrics: Do not return in the middle of the subcommand This patch also makes fabrics module to not return the internal error status in the middle of the subcommands to support uniformed mapped error value which will be introduced in the next patches. Cc: Keith Busch Cc: Chaitanya Kulkarni Cc: Sagi Grimberg Signed-off-by: Minwoo Im Reviewed-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg --- diff --git a/fabrics.c b/fabrics.c index 9ed4a568..adedca06 100644 --- a/fabrics.c +++ b/fabrics.c @@ -984,20 +984,23 @@ int discover(const char *desc, int argc, char **argv, bool connect) ret = argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (ret) - return ret; + goto out; cfg.nqn = NVME_DISC_SUBSYS_NAME; if (!cfg.transport && !cfg.traddr) { - return discover_from_conf_file(desc, argstr, + ret = discover_from_conf_file(desc, argstr, command_line_options, connect); } else { ret = build_options(argstr, BUF_SIZE); if (ret) - return ret; + goto out; - return do_discover(argstr, connect); + ret = do_discover(argstr, connect); } + +out: + return ret; } int connect(const char *desc, int argc, char **argv) @@ -1029,21 +1032,23 @@ int connect(const char *desc, int argc, char **argv) ret = argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (ret) - return ret; + goto out; ret = build_options(argstr, BUF_SIZE); if (ret) - return ret; + goto out; if (!cfg.nqn) { fprintf(stderr, "need a -n argument\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } instance = add_ctrl(argstr); if (instance < 0) - return instance; - return 0; + ret = instance; +out: + return ret; } static int scan_sys_nvme_filter(const struct dirent *d) @@ -1148,11 +1153,12 @@ int disconnect(const char *desc, int argc, char **argv) ret = argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (ret) - return ret; + goto out; if (!cfg.nqn && !cfg.device) { fprintf(stderr, "need a -n or -d argument\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } if (cfg.nqn) { @@ -1174,6 +1180,7 @@ int disconnect(const char *desc, int argc, char **argv) cfg.device); } +out: return ret; } @@ -1188,7 +1195,7 @@ int disconnect_all(const char *desc, int argc, char **argv) ret = argconfig_parse(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); if (ret) - return ret; + goto out; slist = get_subsys_list(&subcnt, NULL, NVME_NSID_ALL); for (i = 0; i < subcnt; i++) {