Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Jaskaran Singh <jaskaransingh7654321@gmail.com>
Cc: "linux-kernel-mentees@lists.linuxfoundation.org"
	<linux-kernel-mentees@lists.linuxfoundation.org>,
	cocci@systeme.lip6.fr
Subject: Re: [Cocci] [PATCH v4 3/3] tests: Add test case to match const pointer variants
Date: Sun, 9 Feb 2020 18:35:10 +0100 (CET)
Message-ID: <alpine.DEB.2.21.2002091834431.3430@hadrien> (raw)
In-Reply-To: <beb17020cc87be2d0e63edc0a897a4c0c2975b27.camel@gmail.com>



On Sun, 9 Feb 2020, Jaskaran Singh wrote:

> On Sun, 2020-02-09 at 17:48 +0100, Julia Lawall wrote:
> > On Sun, 9 Feb 2020, Jaskaran Singh wrote:
> >
> > > Pointer to const pointer and its variants would not match
> > > previously.
> > > Add a test case for matching these types.
> > >
> > > Signed-off-by: Jaskaran Singh <jaskaransingh7654321@gmail.com>
> > > ---
> > >  tests/constptr.c     |  7 +++++++
> > >  tests/constptr.cocci | 19 +++++++++++++++++++
> > >  tests/constptr.res   |  7 +++++++
> > >  3 files changed, 33 insertions(+)
> > >  create mode 100644 tests/constptr.c
> > >  create mode 100644 tests/constptr.cocci
> > >  create mode 100644 tests/constptr.res
> > >
> > > diff --git a/tests/constptr.c b/tests/constptr.c
> > > new file mode 100644
> > > index 00000000..13fe064c
> > > --- /dev/null
> > > +++ b/tests/constptr.c
> > > @@ -0,0 +1,7 @@
> > > +int main()
> > > +{
> > > +	const char * const * id;
> > > +	const char * * const * id;
> > > +	const char * const * * id;
> > > +	const char * const id;
> >
> > As far as I can see in the Linux kernel, there is no space between
> > two *s,
> > and there is no space before an identifier.
> >
>
> Well, the test isn't replacing the type here. It's just replacing the
> ident as per the matches. So I guess the spaces are preserved as in the
> C file.
> When replacing the type like say
> -t x;
> +t y;
> Spaces are not added between the stars or the ident.

Yes, I agree.

>
> Sorry if I'm missing something. Do you mean that the C file/res file
> should conform to the Linux style?

I think it would be nicer if it did.

julia

> Cheers,
> Jaskaran.
>
> > julia
> >
> > > +}
> > > diff --git a/tests/constptr.cocci b/tests/constptr.cocci
> > > new file mode 100644
> > > index 00000000..29f0aa96
> > > --- /dev/null
> > > +++ b/tests/constptr.cocci
> > > @@ -0,0 +1,19 @@
> > > +@ r0 @
> > > +identifier id;
> > > +@@
> > > +const char * const *
> > > +- id
> > > ++ id1
> > > +;
> > > +const char * * const *
> > > +- id
> > > ++ id2
> > > +;
> > > +const char * const * *
> > > +- id
> > > ++ id3
> > > +;
> > > +const char * const
> > > +- id
> > > ++ id4
> > > +;
> > > diff --git a/tests/constptr.res b/tests/constptr.res
> > > new file mode 100644
> > > index 00000000..0af4de9a
> > > --- /dev/null
> > > +++ b/tests/constptr.res
> > > @@ -0,0 +1,7 @@
> > > +int main()
> > > +{
> > > +	const char * const * id1;
> > > +	const char * * const * id2;
> > > +	const char * const * * id3;
> > > +	const char * const id4;
> > > +}
> > > --
> > > 2.21.1
> > >
> > >
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

      reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-09 15:34 [Cocci] [PATCH v4 0/3] cocci: Align the C AST and Cocci AST for pointer Jaskaran Singh
2020-02-09 15:34 ` [Cocci] [PATCH v4 1/3] parsing_c: Align " Jaskaran Singh
2020-02-09 16:46   ` Julia Lawall
2020-02-09 15:34 ` [Cocci] [PATCH v4 2/3] tests: Add space between * and const in ptrconstptr.res Jaskaran Singh
2020-02-09 15:34 ` [Cocci] [PATCH v4 3/3] tests: Add test case to match const pointer variants Jaskaran Singh
2020-02-09 16:48   ` Julia Lawall
2020-02-09 17:32     ` Jaskaran Singh
2020-02-09 17:35       ` Julia Lawall [this message]

Reply instructions:

You may reply publically 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=alpine.DEB.2.21.2002091834431.3430@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=jaskaransingh7654321@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    /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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr
	public-inbox-index cocci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git