All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: "Martin Mares" <mj@ucw.cz>, "Bjorn Helgaas" <helgaas@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	linux-pci@vger.kernel.org
Subject: [PATCH pciutils 2/4] lspci: Simplify printing range in show_range()
Date: Mon, 20 Dec 2021 16:54:46 +0100	[thread overview]
Message-ID: <20211220155448.1233-2-pali@kernel.org> (raw)
In-Reply-To: <20211220155448.1233-1-pali@kernel.org>

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


  reply	other threads:[~2021-12-20 15:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 15:54 [PATCH pciutils 1/4] lspci: Show 16/32/64 bit width for address ranges behind bridge Pali Rohár
2021-12-20 15:54 ` Pali Rohár [this message]
2021-12-20 15:54 ` [PATCH pciutils 3/4] libpci: Add support for filling bridge resources Pali Rohár
2021-12-26 22:13   ` Martin Mareš
2021-12-26 22:20     ` Pali Rohár
2021-12-31 22:27       ` Pali Rohár
2022-01-20 20:33         ` Bjorn Helgaas
2022-01-20 20:45           ` Pali Rohár
2022-01-20 21:02             ` Bjorn Helgaas
2022-01-20 21:19               ` Pali Rohár
2022-11-11 20:09               ` IORESOURCE_WINDOW for PCI-to-PCI bridges Pali Rohár
2022-11-11 21:05                 ` Bjorn Helgaas
2022-11-11 21:48                   ` Pali Rohár
2022-11-15 22:15                     ` Bjorn Helgaas
2021-12-20 15:54 ` [PATCH pciutils 4/4] lspci: Use PCI_FILL_BRIDGE_BASES to detect if range behind bridge is disabled or unsupported Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211220155448.1233-2-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=helgaas@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mj@ucw.cz \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.