From 8072e231318d852d79d0f3ac0046720ecb69b4c3 Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Sun, 26 Mar 2023 20:06:49 +0900 Subject: [PATCH] nvme-print: Unify number base format for nsid `nvme list` is one of the most frequently used subcommand to list up nvme devices in the system. `nvme list -v` prints much more detail in it. But, those two commands have different number base format which are decimal and hexadecimal without any prefix (e.g., 0x) or something. nvme list -v shows hexadecimal nsid without `0x` which means it might be confused between decimal and hexadecimal. To unify this, this patch expands device NSID fields width from 8 to 10 to cover `0x` two chracters as a prefix for both `nvme list` and `nvme list -v`. Signed-off-by: Minwoo Im --- nvme-print.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nvme-print.c b/nvme-print.c index 356fb440..11746993 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -5159,7 +5159,7 @@ void nvme_show_list_item(nvme_ns_t n) nvme_dev_full_path(n, devname, sizeof(devname)); nvme_generic_full_path(n, genname, sizeof(genname)); - printf("%-21s %-21s %-20s %-40s %-9d %-26s %-16s %-8s\n", + printf("%-21s %-21s %-20s %-40s %#-10x %-26s %-16s %-8s\n", devname, genname, nvme_ns_get_serial(n), nvme_ns_get_model(n), nvme_ns_get_nsid(n), usage, format, nvme_ns_get_firmware(n)); @@ -5172,9 +5172,9 @@ static void nvme_show_simple_list(nvme_root_t r) nvme_ctrl_t c; nvme_ns_t n; - printf("%-21s %-21s %-20s %-40s %-9s %-26s %-16s %-8s\n", + printf("%-21s %-21s %-20s %-40s %-10s %-26s %-16s %-8s\n", "Node", "Generic", "SN", "Model", "Namespace", "Usage", "Format", "FW Rev"); - printf("%-.21s %-.21s %-.20s %-.40s %-.9s %-.26s %-.16s %-.8s\n", + printf("%-.21s %-.21s %-.20s %-.40s %-.10s %-.26s %-.16s %-.8s\n", dash, dash, dash, dash, dash, dash, dash, dash); nvme_for_each_host(r, h) { @@ -5209,7 +5209,7 @@ static void nvme_show_ns_details(nvme_ns_t n) nvme_dev_full_path(n, devname, sizeof(devname)); nvme_generic_full_path(n, genname, sizeof(genname)); - printf("%-12s %-12s %-8x %-26s %-16s ", devname, + printf("%-12s %-12s %#-10x %-26s %-16s ", devname, genname, nvme_ns_get_nsid(n), usage, format); } @@ -5279,9 +5279,9 @@ static void nvme_show_detailed_list(nvme_root_t r) } printf("\n"); - printf("%-12s %-12s %-8s %-26s %-16s %-16s\n", "Device", "Generic", + printf("%-12s %-12s %-10s %-26s %-16s %-16s\n", "Device", "Generic", "NSID", "Usage", "Format", "Controllers"); - printf("%-.12s %-.12s %-.8s %-.26s %-.16s %-.16s\n", dash, dash, dash, + printf("%-.12s %-.12s %-.10s %-.26s %-.16s %-.16s\n", dash, dash, dash, dash, dash, dash); nvme_for_each_host(r, h) { -- 2.50.1