From: Jeff Lien Date: Mon, 5 Feb 2018 16:35:59 +0000 (-0600) Subject: NVMe-CLI Fix fw_log Command json output X-Git-Tag: v1.6~98 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e664bfe00b7327769b128ed6e8b7e9b63d467025;p=users%2Fsagi%2Fnvme-cli.git NVMe-CLI Fix fw_log Command json output 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 [fixed whitespace formatting] Signed-off-by: Keith Busch --- diff --git a/nvme-print.c b/nvme-print.c index 1ca4b711..e00bb566 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -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);