[PATCH pciutils 2/4] lspci: Simplify printing range in show_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use just one printf() call with width format argument based on number of bits.
---
 lspci.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lspci.c b/lspci.c
index 17649a0540fa..67ac19b61a29 100644
--- 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
-- 
2.20.1




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux