RE: [PATCH RFCv3 3/3] lib/test_printf: add test cases for '%pD'
From: Justin He <hidden>
Date: 2021-06-15 07:15:38
Also in:
linux-fsdevel, lkml
Hi Rasmus
-----Original Message----- From: Justin He Sent: Tuesday, June 15, 2021 3:06 PM To: Rasmus Villemoes <linux@rasmusvillemoes.dk>; Petr Mladek [off-list ref]; Steven Rostedt [off-list ref]; Sergey Senozhatsky [off-list ref]; Andy Shevchenko [off-list ref]; Jonathan Corbet [off-list ref]; Alexander Viro [off-list ref]; Linus Torvalds <torvalds@linux- foundation.org> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>; 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 3/3] lib/test_printf: add test cases for '%pD' Hi Rasmusquoted
-----Original Message----- From: Rasmus Villemoes <linux@rasmusvillemoes.dk> Sent: Saturday, June 12, 2021 5:40 AM To: Justin He <redacted>; Petr Mladek <pmladek@suse.com>; Steven Rostedt [off-list ref]; Sergey Senozhatsky [off-list ref]; Andy Shevchenko [off-list ref]; Jonathan Corbet [off-list ref]; Alexander Viro [off-list ref]; Linus Torvalds <torvalds@linux- foundation.org> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>; 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 3/3] lib/test_printf: add test cases for '%pD' On 11/06/2021 17.59, Jia He wrote:quoted
After the behaviour of specifier '%pD' is changed to print full path of struct file, the related test cases are also updated. Given the string is prepended from the end of the buffer, the check of "wrote beyond the nul-terminator" should be skipped.Sorry, that is far from enough justification. I should probably have split the "wrote beyond nul-terminator" check intwo:quoted
One that checks whether any memory beyond the buffer given to vsnprintf() was touched (including all the padding, but possibly more for the cases where we pass a known-too-short buffer), symmetric to the "wrote before buffer" check. And then another that checks the area between the '\0' and the end of the given buffer - I suppose that it's fair game for vsnprintf to use all of that as scratch space, and for that it could be ok to add that boolean knob.Sorry, I could have thought sth like "write beyond the buffer" had been checked by old test cases, but seems not. I will split the "wrote beyond nul-terminator" check into 2 parts. One for Non-%pD case, the other for %pD. For %pD, it needs to check whether the space beyond test_buffer[] is written
Another question is about precision, Do you think I should add some test cases e.g. "%.10pD" here? I once added some, but the gcc report warning: warning: precision used with '%p' gnu_printf What do you think of that? -- Cheers, Justin (Jia He) 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.