[lkml]   [2021]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [PATCH 2/4] lib/vsprintf.c: Make %p{D,d} mean as much components as possible
On Wed 2021-04-28 21:59:27, Jia He wrote:
> From: Linus Torvalds <>
> We have '%pD'(no digit following) for printing a filename. It may not be
> perfect (by default it only prints one component.
> %pD4 should be more than good enough, but we should make plain "%pD" mean
> "as much of the path that is reasonable" rather than "as few components as
> possible" (ie 1).

Could you please provide link to the discussion where this idea was
came from?

It would be great to add and example into the commit message how
it improved the output.

Also please explain why it is useful/safe to change the behavior
for all existing users. It seems that you checked them and prevented
any regression by the other patches in this patchset.

Anyway, some regressions are fixed by the followup patches.
It would break bisection.

We either need to prevent the regression before this patch.
Or the changes have to be done in this patch. For example,
it would be perfectly fine to update test_printf.c in
this patch.

> Signed-off-by: Linus Torvalds <>

If you want to keep Linus as the author and do more changes, you might
describe here changes done by you, for example:

[ update documentation and test_printf]
Signed-off-by: Jia He <>

Or you might make you the author and add

Suggested-by: Linus Torvalds <>

> ---
> Documentation/core-api/printk-formats.rst | 3 ++-
> lib/vsprintf.c | 4 ++--
> 2 files changed, 4 insertions(+), 3 deletions(-)
> diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst
> index 9be6de402cb9..aa76cbec0dae 100644
> --- a/Documentation/core-api/printk-formats.rst
> +++ b/Documentation/core-api/printk-formats.rst

Plese, update also the pattern:

- %pd{,2,3,4}
- %pD{,2,3,4}
+ %pd{1,2,3,4}
+ %pD{1,2,3,4}

> @@ -413,7 +413,8 @@ dentry names
> For printing dentry name; if we race with :c:func:`d_move`, the name might
> be a mix of old and new ones, but it won't oops. %pd dentry is a safer
> equivalent of %s dentry-> we used to use, %pd<n> prints ``n``
> -last components. %pD does the same thing for struct file.
> +last components. %pD does the same thing for struct file. By default, %p{D,d}
> +is equal to %p{D,d}4.
> Passed by reference.

Best Regards,

 \ /
  Last update: 2021-04-29 10:48    [W:0.088 / U:2.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site