Thread (22 messages) 22 messages, 4 authors, 2021-06-15

RE: [PATCH RFCv3 2/3] lib/vsprintf.c: make %pD print full path for file

From: Justin He <hidden>
Date: 2021-06-15 07:18:22
Also in: linux-fsdevel, lkml

-----Original Message-----
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Sent: Tuesday, June 15, 2021 3:15 PM
To: Justin He <redacted>; Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>; Sergey Senozhatsky
[off-list ref]; Andy Shevchenko
[off-list ref]; Rasmus Villemoes
[off-list ref]; Jonathan Corbet [off-list ref]; Alexander
Viro [off-list ref]; Linus Torvalds <torvalds@linux-
foundation.org>; Peter Zijlstra (Intel) [off-list ref]; Eric
Biggers [off-list ref]; Ahmed S. Darwish [off-list ref];
linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
fsdevel@vger.kernel.org
Subject: Re: [PATCH RFCv3 2/3] lib/vsprintf.c: make %pD print full path for
file

On 15/06/2021 08.48, Justin He wrote:
quoted
Hi Petr
quoted
quoted
quoted
+   /* no filling space at all */
+   if (buf >= end || !buf)
+           return buf + reserved_size;
+
+   /* small space for long name */
+   if (buf < end && prepend_len < 0)
+           return string_truncate(buf, end, p, dpath_len, spec);
We need this only because we allowed to write the path behind
spec.field_width. Do I get it right?
Both of field_width and precision:
"%.14pD" or "%8.14pD"
Precision is never gonna be used with %p (or any of its kernel
extensions) because gcc would tell you

foo.c:5:13: warning: precision used with �%p� gnu_printf format [-
Wformat=]
    5 |  printf("%.5p\n", foo);

and there's no way -Wformat is going to be turned off to allow that usage.

IOW, there's no need to add complexity to make "%.3pD" of something that
would normally print "/foo/bar" merely print "/fo", similar to what a
precision with %s would mean.
Aha, this answer my question in last email.
Thank you


--
Cheers,
Justin (Jia He)

As for field width, I don't know if it's worth honouring, but IIRC the
original %pd and %pD did that (that's where we have widen_string etc. from).

Other %p extensions put the field with to some other use (e.g. the
bitmap and hex string printing), so they obviously cannot simultaneously
use it in the traditional sense.

Rasmus
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help