[Linux-kernel-mentees] [PATCH v2 2/2] tests: Add test case to match const pointer variants

Julia Lawall julia.lawall at inria.fr
Sun Feb 9 08:07:27 UTC 2020


On Sun, 9 Feb 2020, Jaskaran Singh wrote:

> On Sun, 2020-02-09 at 08:20 +0100, Julia Lawall wrote:
> > On Fri, 7 Feb 2020, Jaskaran Singh wrote:
> >
> > > Pointer to const pointer and its variants would not match
> > > previously.
> > > Add a test case for matching these types.
> >
> > I don't get any matches for this test.  If I split the semantic patch
> > into
> > four separate rules, then I get the change for id2 and id4, but not
> > for
> > the other two.
> >
>
> That's weird, it works fine for me. I get this on both bytecode and
> native builds.

OK, you're right, it's OK.

Can you fix the *const problem?  I still see that one.

thanks,
julia

>
> --- tests/constptr.c
> +++ /tmp/cocci-output-31326-084eed-constptr.c
> @@ -1,7 +1,7 @@
>  int main()
>  {
> -	const char * const * id;
> -	const char * * const * id;
> -	const char * const * * id;
> -	const char * const id;
> +	const char * const * id1;
> +	const char * * const * id2;
> +	const char * const * * id3;
> +	const char * const id4;
>  }
>
>
> On the other hand, I get the id2 and id4 result with upstream.
>
> --- tests/constptr.c
> +++ /tmp/cocci-output-5387-a9b63b-constptr.c
> @@ -1,7 +1,7 @@
>  int main()
>  {
>  	const char * const * id;
> -	const char * * const * id;
> +	const char * * const * id2;
>  	const char * const * * id;
> -	const char * const id;
> +	const char * const id4;
>  }
>
> Could you check if you've applied 1/2 first?
>
> Cheers,
> Jaskaran.
>
> > julia
> >
> > > Signed-off-by: Jaskaran Singh <jaskaransingh7654321 at 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;
> > > +}
> > > 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
> > >
> > >
>
>


More information about the Linux-kernel-mentees mailing list