]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
NVMe-CLI Fix fw_log Command json output
authorJeff Lien <jeff.lien@wdc.com>
Mon, 5 Feb 2018 16:35:59 +0000 (10:35 -0600)
committerKeith Busch <keith.busch@intel.com>
Mon, 5 Feb 2018 17:11:54 +0000 (10:11 -0700)
Currently, the json output for the fw_log command slot number
is zero based while the normal output is one based.  This patch
will change the json output to one based.  It will also only
print the revisions for the valid slots.

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
[fixed whitespace formatting]
Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme-print.c

index 1ca4b711af2ece52c6253d0e760625fa01064e16..e00bb566696074f0403e759cf22020a26ba736da 100644 (file)
@@ -1928,10 +1928,12 @@ void json_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname)
        json_object_add_value_int(fwsi, "Active Firmware Slot (afi)", fw_log->afi);
 
        for (i = 0; i < 7; i++) {
-               snprintf(fmt, sizeof(fmt), "Firmware Rev Slot %d", i);
-               snprintf(str, sizeof(str), "%"PRIu64" (%s)", (uint64_t)fw_log->frs[i],
-                        fw_to_string(fw_log->frs[i]));
-               json_object_add_value_string(fwsi, fmt, str);
+               if (fw_log->frs[i]) {
+                       snprintf(fmt, sizeof(fmt), "Firmware Rev Slot %d", i+1);
+                       snprintf(str, sizeof(str), "%"PRIu64" (%s)", (uint64_t)fw_log->frs[i],
+                       fw_to_string(fw_log->frs[i]));
+                       json_object_add_value_string(fwsi, fmt, str);
+               }
        }
        json_object_add_value_object(root, devname, fwsi);