]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
property: Fit print size for a property
authorMinwoo Im <minwoo.im@samsung.com>
Sun, 5 May 2019 11:58:59 +0000 (20:58 +0900)
committerMinwoo Im <minwoo.im@samsung.com>
Sun, 5 May 2019 12:05:51 +0000 (13:05 +0100)
We may or may not be able to see the following output in nvme-loop env.
  # nvme get-property /dev/nvme0 -o 0x14
  property: 0x14 (Controller Configuration), value: 7f7800460001
The register CC is not in 64bit, but the upper bits are showing some values
even it's reserved in spec.

This patch makes this print size to fit to its own size of register.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
nvme-print.c

index 156a62c79e7a27dd2edf32473a4e2e59a7c80678..d70db203078f7333cff864106c507c4baccd412b 100644 (file)
@@ -3296,8 +3296,14 @@ void show_single_property(int offset, uint64_t value64, int human)
        uint32_t value32;
 
        if (!human) {
-               printf("property: 0x%02x (%s), value: %"PRIx64"\n", offset,
-                          nvme_register_to_string(offset), value64);
+               if (is_64bit_reg(offset))
+                       printf("property: 0x%02x (%s), value: %"PRIx64"\n", offset,
+                                  nvme_register_to_string(offset), value64);
+               else
+                       printf("property: 0x%02x (%s), value: %x\n", offset,
+                                  nvme_register_to_string(offset),
+                                  (uint32_t) value64);
+
                return;
        }