All of lore.kernel.org
 help / color / mirror / Atom feed
From: Justin He <Justin.He@arm.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Jonathan Corbet <corbet@lwn.net>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Eric Biggers <ebiggers@google.com>,
	"Ahmed S. Darwish" <a.darwish@linutronix.de>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: RE: [PATCH RFCv3 3/3] lib/test_printf: add test cases for '%pD'
Date: Tue, 15 Jun 2021 07:07:03 +0000	[thread overview]
Message-ID: <AM6PR08MB4376096643BA02A1AE2BA8F4F7309@AM6PR08MB4376.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <YMd5StgkBINLlb8E@alley>

Hi Petr

> -----Original Message-----
> From: Petr Mladek <pmladek@suse.com>
> Sent: Monday, June 14, 2021 11:44 PM
> To: Justin He <Justin.He@arm.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>; Sergey Senozhatsky
> <senozhatsky@chromium.org>; Andy Shevchenko
> <andriy.shevchenko@linux.intel.com>; Rasmus Villemoes
> <linux@rasmusvillemoes.dk>; Jonathan Corbet <corbet@lwn.net>; Alexander
> Viro <viro@zeniv.linux.org.uk>; Linus Torvalds <torvalds@linux-
> foundation.org>; Peter Zijlstra (Intel) <peterz@infradead.org>; Eric
> Biggers <ebiggers@google.com>; Ahmed S. Darwish <a.darwish@linutronix.de>;
> 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 Fri 2021-06-11 23:59:53, Jia He 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 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@arm.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 ec0d5976bb69..3632bd6cf906 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, BUF_SIZE +
> PAD_SIZE - (written + 1))) {
> > +   if (!is_prepend_buf && memchr_inv(test_buffer + written + 1,
> FILL_CHAR, BUF_SIZE + PAD_SIZE - (written + 1))) {
> >             pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote beyond the nul-
> terminator\n",
> >                     bufsize, fmt);
> >             return 1;
> > @@ -496,6 +498,27 @@ dentry(void)
> >     test("  bravo/alfa|  bravo/alfa", "%12pd2|%*pd2", &test_dentry[2],
> 12, &test_dentry[2]);
> >  }
> >
> > +static struct vfsmount test_vfsmnt = {};
> > +
> > +static struct file test_file __initdata = {
> > +   .f_path = { .dentry = &test_dentry[2],
> > +               .mnt = &test_vfsmnt,
> > +   },
> > +};
> > +
> > +static void __init
> > +f_d_path(void)
> > +{
> > +   test("(null)", "%pD", NULL);
> > +   test("(efault)", "%pD", PTR_INVALID);
> > +
> > +   is_prepend_buf = true;
> > +   test("/bravo/alfa   |/bravo/alfa   ", "%-14pD|%*pD", &test_file, -14,
> &test_file);
> > +   test("   /bravo/alfa|   /bravo/alfa", "%14pD|%*pD", &test_file, 14,
> &test_file);
> > +   test("   /bravo/alfa|/bravo/alfa   ", "%14pD|%-14pD", &test_file,
> &test_file);
>
> Please, add more test for scenarios when the path does not fit into
> the buffer or when there are no limitations, ...

Indeed, thanks


--
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.

  reply	other threads:[~2021-06-15  7:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-11 15:59 [PATCH RFCv3 0/3] make '%pD' print full path for file Jia He
2021-06-11 15:59 ` [PATCH RFCv3 1/3] fs: introduce helper d_path_unsafe() Jia He
2021-06-11 15:59 ` [PATCH RFCv3 2/3] lib/vsprintf.c: make %pD print full path for file Jia He
2021-06-11 21:28   ` Rasmus Villemoes
2021-06-15  6:43     ` Justin He
2021-06-15  7:04       ` Rasmus Villemoes
2021-06-15  8:32     ` Justin He
2021-06-14 15:40   ` Petr Mladek
2021-06-15  6:48     ` Justin He
2021-06-15  7:14       ` Rasmus Villemoes
2021-06-15  7:18         ` Justin He
2021-06-15 14:48     ` Justin He
2021-06-11 15:59 ` [PATCH RFCv3 3/3] lib/test_printf: add test cases for '%pD' Jia He
2021-06-11 21:40   ` Rasmus Villemoes
2021-06-15  7:06     ` Justin He
2021-06-15  7:15       ` Justin He
2021-06-15  7:40       ` Rasmus Villemoes
2021-06-14 15:44   ` Petr Mladek
2021-06-15  7:07     ` Justin He [this message]
2021-06-15  7:47       ` Rasmus Villemoes
2021-06-15  7:56         ` Justin He
2021-06-15  8:19           ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR08MB4376096643BA02A1AE2BA8F4F7309@AM6PR08MB4376.eurprd08.prod.outlook.com \
    --to=justin.he@arm.com \
    --cc=a.darwish@linutronix.de \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=ebiggers@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.