Re: [PATCH] docs: printk-formats: Clarify %*pb format parameters

From: Luca Weiss
Date: Mon May 22 2023 - 02:42:03 EST


On Wed May 17, 2023 at 6:19 PM CEST, Andy Shevchenko wrote:
> On Tue, May 16, 2023 at 08:52:43AM +0200, Luca Weiss wrote:
> > Since it's rather unusual for printk formats to require two parameters,
>
> I don't think this is "unusual".

Well, unusual for me at least. I've never really used anything except
the standard integer types and %px. And I've been contributing to the
kernel since 2017.

> The %*... is very well described in the printf(3) (the meaning of *).
> It applies here for %*p... as well.

The printf(3) man page is never mentioned on this docs page. And even if
it would be mentioned somewhere, I doubt anyone is reading most of the
page when they're just looking for a format specifier for e.g. bitmap.
At least I am not.

>
> > expand the documentation to clearly mention that in the printk format
> > for bitmaps.
> >
> > As an extra example, for example from include/net/bluetooth/hci_core.h
> > we have a bitmap DECLARE_BITMAP(dev_flags, __HCI_NUM_FLAGS);
> > This can be printed with ("%*pb", __HCI_NUM_FLAGS, hdev->dev_flags)
>
> I think this change is not needed. But try to convince PRINTK maintainers.
> Maybe they will be okay with it if it covers all %*p... cases (like %*ph).

Cannot say I haven't tried :) As I wrote in the initial email I'd be
happy also if someone who knows more about the formats to include some
text for all the %* options so users know what's up.

Regards
Luca