[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM6PR08MB4376FCAAFB6BF7914689C27DF7099@AM6PR08MB4376.eurprd08.prod.outlook.com>
Date: Tue, 22 Jun 2021 02:21:36 +0000
From: Justin He <Justin.He@....com>
To: Petr Mladek <pmladek@...e.com>,
Andy Shevchenko <andy.shevchenko@...il.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 Documentation List <linux-doc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux FS Devel <linux-fsdevel@...r.kernel.org>,
Matthew Wilcox <willy@...radead.org>
Subject: RE: [PATCH RFCv4 4/4] lib/test_printf.c: add test cases for '%pD'
> -----Original Message-----
> From: Petr Mladek <pmladek@...e.com>
> Sent: Thursday, June 17, 2021 10:53 PM
> To: Andy Shevchenko <andy.shevchenko@...il.com>
> Cc: Justin He <Justin.He@....com>; 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 Documentation List <linux-doc@...r.kernel.org>; Linux Kernel Mailing
> List <linux-kernel@...r.kernel.org>; Linux FS Devel <linux-
> fsdevel@...r.kernel.org>; Matthew Wilcox <willy@...radead.org>
> Subject: Re: [PATCH RFCv4 4/4] lib/test_printf.c: add test cases for '%pD'
>
> On Tue 2021-06-15 23:47:29, Andy Shevchenko wrote:
> > On Tue, Jun 15, 2021 at 6:55 PM Jia He <justin.he@....com> wrote:
> > >
> > > 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 of '%pD' is prepended from the end of the buffer, the
> > > check of "wrote beyond the nul-terminator" should be skipped.
> > >
> > > Signed-off-by: Jia He <justin.he@....com>
> > > ---
> > > lib/test_printf.c | 26 +++++++++++++++++++++++++-
> > > 1 file changed, 25 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/lib/test_printf.c b/lib/test_printf.c
> > > index d1d2f898ebae..9f851a82b3af 100644
> > > --- a/lib/test_printf.c
> > > +++ b/lib/test_printf.c
> > > @@ -78,7 +80,7 @@ do_test(int bufsize, const char *expect, int elen,
> > > return 1;
> > > }
> > >
> > > - if (memchr_inv(test_buffer + written + 1, FILL_CHAR, bufsize -
> (written + 1))) {
> >
> > > + if (!is_prepended_buf && memchr_inv(test_buffer + written + 1,
> FILL_CHAR, bufsize - (written + 1))) {
> >
> > Can it be parametrized? I don't like the custom test case being
> > involved here like this.
>
> Yup, it would be nice.
>
> Also it is far from obvious what @is_prepended_buf means if you do not
> have context of this patchset. I think about a more generic name
> that comes from the wording used in 3rd patch, e.g.
>
> @need_scratch_space or @using_scratch_space or @dirty_buf
>
> Anyway, the most easy way to pass this as a parameter would be to add it
> to __test() and define a wrapper, .e.g:
>
> static void __printf(3, 4) __init
> __test(const char *expect, int elen, bool using_scratch_space,
> const char *fmt, ...)
>
> /*
> * More relaxed test for non-standard formats that are using the provided
> buffer
> * as a scratch space and write beyond the trailing '\0'.
> */
> #define test_using_scratch_space(expect, fmt, ...) \
> __test(expect, strlen(expect), true, fmt, ##__VA_ARGS__)
Okay, thanks for the suggestion.
--
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.
Powered by blists - more mailing lists