From: Keith Busch Date: Fri, 11 Nov 2016 15:24:23 +0000 (-0500) Subject: get-feature updates X-Git-Tag: v1.0~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c800978b6b017d3751e51da2c37f360501a0ee3d;p=users%2Fsagi%2Fnvme-cli.git get-feature updates 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 --- diff --git a/nvme-ioctl.c b/nvme-ioctl.c index 9df04ae1..3720ab48 100644 --- a/nvme-ioctl.c +++ b/nvme-ioctl.c @@ -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 a9e78aae..170fbec0 100644 --- 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)