]> mj.ucw.cz Git - pciutils.git/commitdiff
lspci: Simplify printing range in show_range()
authorPali Rohár <pali@kernel.org>
Sat, 20 Nov 2021 12:43:35 +0000 (13:43 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 10 Feb 2022 12:49:35 +0000 (13:49 +0100)
Use just one printf() call with width format argument based on number of bits.

lspci.c

diff --git a/lspci.c b/lspci.c
index 17649a0540faca66eea185fd90141821b9a2ddfd..67ac19b61a293209539f3d9e93067832f459aa27 100644 (file)
--- a/lspci.c
+++ b/lspci.c
@@ -378,12 +378,7 @@ show_range(char *prefix, u64 base, u64 limit, int bits)
 {
   printf("%s:", prefix);
   if (base <= limit || verbose > 2)
-    {
-      if (bits > 32)
-        printf(" %016" PCI_U64_FMT_X "-%016" PCI_U64_FMT_X, base, limit);
-      else
-        printf(" %08x-%08x", (unsigned) base, (unsigned) limit);
-    }
+    printf(" %0*" PCI_U64_FMT_X "-%0*" PCI_U64_FMT_X, (bits+3)/4, base, (bits+3)/4, limit);
   if (base <= limit)
     show_size(limit - base + 1);
   else