Re: [PATCH v1 1/2] vsprintf: Add %pR human-readable size

From: Andy Shevchenko

Date: Sat Aug 08 2026 - 13:43:45 EST


On Sat, Aug 08, 2026 at 12:23:07PM -0500, Bjorn Helgaas wrote:
> Include human-readable size when printing struct resource memory ranges
> (not including DMA, bus number, or I/O port ranges) with the %pR format to
> make it easier to read, e.g.,
>
> - pci 0000:00:02.0: BAR 0 [mem 0xfea80000-0xfea9ffff]
> + pci 0000:00:02.0: BAR 0 [mem 0xfea80000-0xfea9ffff (128 KiB)]

...

> lib/vsprintf.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)

Sorry, we do not accept this without added test cases.

...

> + if (res->flags & IORESOURCE_MEM) {

Besides we have resource_type() macro, why only this? I would expect IO as well
as 64-bit MEM version.

> + *p++ = ' ';
> + *p++ = '(';
> + string_get_size(resource_size(res), 1, STRING_UNITS_2,
> + size_buf, sizeof(size_buf));

> + p = string_nocheck(p, pend, size_buf, str_spec);

Why do you need this? Use returned value from string_get_size() directly.

> + *p++ = ')';
> + }

--
With Best Regards,
Andy Shevchenko