]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
get-feature updates
authorKeith Busch <keith.busch@intel.com>
Fri, 11 Nov 2016 15:24:23 +0000 (10:24 -0500)
committerKeith Busch <keith.busch@intel.com>
Fri, 11 Nov 2016 15:24:23 +0000 (10:24 -0500)
This fixes some of the printing options. We don't want to print text if
the request is to display the buffer in raw binary, and we don't want
to do a binary output if there is no buffer to write.

Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme-ioctl.c
nvme.c

index 9df04ae1247f5b381db20f35b340314a14b18f5a..3720ab48ff692d3cbcfe74116d86e75f051b6658 100644 (file)
@@ -414,6 +414,7 @@ int nvme_feature(int fd, __u8 opcode, __u32 nsid, __u32 cdw10, __u32 cdw11,
        int err;
 
        err = nvme_submit_admin_passthru(fd, &cmd);
+       printf("err:%d result:%x\n", err, cmd.result);
        if (!err && result)
                *result = cmd.result;
        return err;
diff --git a/nvme.c b/nvme.c
index a9e78aae50a9bf67827904f5b51a47ca3f4bda14..170fbec08d4c88a5528b41807bd96c88dd469bae 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1124,23 +1124,20 @@ static int get_feature(int argc, char **argv, struct command *cmd, struct plugin
        err = nvme_get_feature(fd, cfg.namespace_id, cfg.feature_id, cfg.sel, cfg.cdw11,
                        cfg.data_len, buf, &result);
        if (!err) {
-               printf("get-feature:0x%02x (%s), %s value: %#08x\n", cfg.feature_id,
+               if (!cfg.raw_binary || !buf) {
+                       printf("get-feature:%#02x (%s), %s value:%#08x\n", cfg.feature_id,
                                nvme_feature_to_string(cfg.feature_id),
                                nvme_select_to_string(cfg.sel), result);
-               if (cfg.human_readable)
-                       nvme_feature_show_fields(cfg.feature_id, result, buf);
-               else {
-                       if (buf) {
-                               if (!cfg.raw_binary)
-                                       d(buf, cfg.data_len, 16, 1);
-                               else
-                                       d_raw(buf, cfg.data_len);
-                       }
-               }
-       }
-       else if (err > 0)
+                       if (cfg.human_readable)
+                               nvme_feature_show_fields(cfg.feature_id, result, buf);
+                       else if (buf)
+                               d(buf, cfg.data_len, 16, 1);
+               } else if (buf)
+                       d_raw(buf, cfg.data_len);
+       } else if (err > 0)
                fprintf(stderr, "NVMe Status:%s(%x)\n",
                                nvme_status_to_string(err), err);
+
        if (buf)
                free(buf);
        return err;
@@ -1616,8 +1613,7 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin
        if (err < 0) {
                perror("set-feature");
                return errno;
-       }
-       if (!err) {
+       } else if (!err) {
                printf("set-feature:%02x (%s), value:%#08x\n", cfg.feature_id,
                        nvme_feature_to_string(cfg.feature_id), cfg.value);
                if (buf) {
@@ -1627,8 +1623,7 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin
                        else
                                d(buf, cfg.data_len, 16, 1);
                }
-       }
-       else if (err > 0)
+       } else
                fprintf(stderr, "NVMe Status:%s(%x)\n",
                                nvme_status_to_string(err), err);
        if (buf)