]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme-cli : only print help text and return for nvme list -h option.
authorChaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Tue, 4 Jul 2017 18:58:46 +0000 (11:58 -0700)
committerKeith Busch <keith.busch@intel.com>
Wed, 5 Jul 2017 16:21:12 +0000 (12:21 -0400)
For " nvme list -h " don't print list after help text,
only print help text and return.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@hgst.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 17d9d9e065987bbb19eb36f68bb1fe68b285e0d6..d64d042d422c5f993580cdbc148304a29d022e87 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -871,8 +871,8 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
        char path[264];
        struct dirent **devices;
        struct list_item *list_items;
-       unsigned int i, n, fd, ret;
-       int fmt;
+       unsigned int i, n, fd;
+       int fmt, ret;
        const char *desc = "Retrieve basic information for the given device";
        struct config {
                char *output_format;
@@ -887,7 +887,10 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
                {NULL}
        };
 
-       argconfig_parse(argc, argv, desc, opts, &cfg, sizeof(cfg));
+       ret = argconfig_parse(argc, argv, desc, opts, &cfg, sizeof(cfg));
+       if (ret < 0)
+               return ret;
+
        fmt = validate_output_format(cfg.output_format);
 
        if (fmt != JSON && fmt != NORMAL)
@@ -979,8 +982,10 @@ int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin,
        fmt = validate_output_format(cfg.output_format);
        if (fmt < 0)
                return fmt;
-       if (cfg.raw_binary)
+       if (cfg.raw_binary) {
+               fprintf(stderr, "binary output\n");
                fmt = BINARY;
+       }
 
        if (cfg.vendor_specific)
                flags |= VS;