]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: Do not print device on connect per default
authorDaniel Wagner <dwagner@suse.de>
Wed, 14 Jun 2023 12:03:53 +0000 (14:03 +0200)
committerDaniel Wagner <wagi@monom.org>
Wed, 14 Jun 2023 12:34:38 +0000 (14:34 +0200)
During the print code refactoring, the show connect message was enabled
per default. To avoid any regressions in application restore the old
behavior and print only the result when the '-o' option is used.

Fixes: 0576d84bf4aa ("fabrics: Move printing functions to the print files")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
fabrics.c

index 22f4da4084962b138dda03da4cbe6b8f0cb0f90c..821d0f55ce09771b082a7b1b81cb1e66c3956d47 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -856,8 +856,8 @@ int nvmf_connect(const char *desc, int argc, char **argv)
        nvme_host_t h;
        nvme_ctrl_t c;
        int ret;
-       struct nvme_fabrics_config cfg;
-       enum nvme_print_flags flags = -1;
+       enum nvme_print_flags flags;
+       struct nvme_fabrics_config cfg = { 0 };
        char *format = "";
 
        NVMF_ARGS(opts, cfg,
@@ -873,14 +873,7 @@ int nvmf_connect(const char *desc, int argc, char **argv)
        if (ret)
                return ret;
 
-       if (!strcmp(format, ""))
-               flags = -1;
-       else if (!strcmp(format, "normal"))
-               flags = NORMAL;
-       else if (!strcmp(format, "json"))
-               flags = JSON;
-       else
-               return -EINVAL;
+       flags = validate_output_format(format);
 
        if (!subsysnqn) {
                fprintf(stderr,
@@ -969,7 +962,8 @@ int nvmf_connect(const char *desc, int argc, char **argv)
                        nvme_strerror(errno));
        else {
                errno = 0;
-               nvme_show_connect_msg(c, flags);
+               if (flags != -EINVAL)
+                       nvme_show_connect_msg(c, flags);
        }
 
 out_free: