[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <113d9380-8493-1bde-9c76-992f4ce675d9@rasmusvillemoes.dk>
Date: Tue, 15 Jun 2021 09:14:37 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Justin He <Justin.He@....com>, Petr Mladek <pmladek@...e.com>
Cc: Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Jonathan Corbet <corbet@....net>,
Alexander Viro <viro@...iv.linux.org.uk>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Eric Biggers <ebiggers@...gle.com>,
"Ahmed S. Darwish" <a.darwish@...utronix.de>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.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:
> Hi Petr
>
>>> + /* 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.
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
Powered by blists - more mailing lists