From: Pali Rohár Date: Sat, 20 Nov 2021 12:43:35 +0000 (+0100) Subject: lspci: Simplify printing range in show_range() X-Git-Tag: v3.8.0~44 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=3b26eaa884987a828421415559aaf61772839fed;p=pciutils.git lspci: Simplify printing range in show_range() Use just one printf() call with width format argument based on number of bits. --- diff --git a/lspci.c b/lspci.c index 17649a0..67ac19b 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