All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Coccinelle: add atomic_as_refcounter script
@ 2017-09-01  9:40 ` Elena Reshetova
  0 siblings, 0 replies; 58+ messages in thread
From: Elena Reshetova @ 2017-09-01  9:40 UTC (permalink / raw)
  To: julia.lawall
  Cc: linux-kernel, cocci, Gilles.Muller, nicolas.palix, mmarek,
	keescook, ishkamiel, Elena Reshetova

atomic_as_refcounter.cocci script allows detecting
cases when refcount_t type and API should be used
instead of atomic_t.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
 1 file changed, 131 insertions(+)
 create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
new file mode 100644
index 0000000..bfa880d
--- /dev/null
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -0,0 +1,131 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+@r1 exists@
+identifier a, x;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+(
+ fname@p2(a, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r4 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+y=a
+...
+fname@p2(y, ...);
+
+
+@script:python depends on report@
+p1 << r4.p1;
+p2 << r4.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+@script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+@r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return@p1(-1, ...);
+|
+x = atomic_long_add_return@p1(-1, ...);
+|
+x = atomic64_add_return@p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)
+
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [Cocci] [PATCH] Coccinelle: add atomic_as_refcounter script
@ 2017-09-01  9:40 ` Elena Reshetova
  0 siblings, 0 replies; 58+ messages in thread
From: Elena Reshetova @ 2017-09-01  9:40 UTC (permalink / raw)
  To: cocci

atomic_as_refcounter.cocci script allows detecting
cases when refcount_t type and API should be used
instead of atomic_t.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
 1 file changed, 131 insertions(+)
 create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
new file mode 100644
index 0000000..bfa880d
--- /dev/null
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -0,0 +1,131 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+ at r1 exists@
+identifier a, x;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test at p1(&(a)->x)
+|
+ atomic_dec_and_lock at p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock at p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test at p1(&(a)->x)
+|
+ atomic64_dec_and_test at p1(&(a)->x)
+|
+ local_dec_and_test at p1(&(a)->x)
+)
+...
+(
+ fname at p2(a, ...);
+|
+ fname2 at p2(...);
+|
+ fname3 at p2(...);
+|
+ fname4 at p2(...);
+|
+ fname5 at p2(...);
+|
+ fname6 at p2(...);
+)
+
+
+ at script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+ at r4 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock at p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock at p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test at p1(&(a)->x)
+|
+ atomic64_dec_and_test at p1(&(a)->x)
+|
+ local_dec_and_test at p1(&(a)->x)
+)
+...
+y=a
+...
+fname at p2(y, ...);
+
+
+ at script:python depends on report@
+p1 << r4.p1;
+p2 << r4.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+ at script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+ at r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return at p1(-1, ...);
+|
+x = atomic_long_add_return at p1(-1, ...);
+|
+x = atomic64_add_return at p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)
+
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-09-01  9:40 ` [Cocci] " Elena Reshetova
@ 2018-06-14 23:58   ` Kees Cook
  -1 siblings, 0 replies; 58+ messages in thread
From: Kees Cook @ 2018-06-14 23:58 UTC (permalink / raw)
  To: Elena Reshetova, Masahiro Yamada
  Cc: Julia Lawall, LKML, cocci, Gilles Muller, Nicolas Palix,
	Michal Marek, Hans Liljestrand

On Fri, Sep 1, 2017 at 2:40 AM, Elena Reshetova
<elena.reshetova@intel.com> wrote:
> atomic_as_refcounter.cocci script allows detecting
> cases when refcount_t type and API should be used
> instead of atomic_t.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Reviewed-by: Kees Cook <keescook@chromium.org>

Oops, I think this got lost. Who can take this patch? I thought Julia
ran the scripts/coccinelle/ tree, but looking at git log, it looks
more like it's Masahiro? Either way, let's get this in the tree. Who
can take it?

Thanks!

-Kees

> ---
>  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
>  1 file changed, 131 insertions(+)
>  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
>
> diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> new file mode 100644
> index 0000000..bfa880d
> --- /dev/null
> +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> @@ -0,0 +1,131 @@
> +// Check if refcount_t type and API should be used
> +// instead of atomic_t type when dealing with refcounters
> +//
> +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> +//
> +// Confidence: Moderate
> +// URL: http://coccinelle.lip6.fr/
> +// Options: --include-headers --very-quiet
> +
> +virtual report
> +
> +@r1 exists@
> +identifier a, x;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +(
> + fname@p2(a, ...);
> +|
> + fname2@p2(...);
> +|
> + fname3@p2(...);
> +|
> + fname4@p2(...);
> +|
> + fname5@p2(...);
> +|
> + fname6@p2(...);
> +)
> +
> +
> +@script:python depends on report@
> +p1 << r1.p1;
> +p2 << r1.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r4 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +y=a
> +...
> +fname@p2(y, ...);
> +
> +
> +@script:python depends on report@
> +p1 << r4.p1;
> +p2 << r4.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r2 exists@
> +identifier a, x;
> +position p1;
> +@@
> +
> +(
> +atomic_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic_long_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic64_add_unless(&(a)->x,-1,1)@p1
> +)
> +
> +@script:python depends on report@
> +p1 << r2.p1;
> +@@
> +msg = "atomic_add_unless"
> +coccilib.report.print_report(p1[0], msg)
> +
> +@r3 exists@
> +identifier x;
> +position p1;
> +@@
> +
> +(
> +x = atomic_add_return@p1(-1, ...);
> +|
> +x = atomic_long_add_return@p1(-1, ...);
> +|
> +x = atomic64_add_return@p1(-1, ...);
> +)
> +
> +@script:python depends on report@
> +p1 << r3.p1;
> +@@
> +msg = "x = atomic_add_return(-1, ...)"
> +coccilib.report.print_report(p1[0], msg)
> +
> +
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Cocci] [PATCH] Coccinelle: add atomic_as_refcounter script
@ 2018-06-14 23:58   ` Kees Cook
  0 siblings, 0 replies; 58+ messages in thread
From: Kees Cook @ 2018-06-14 23:58 UTC (permalink / raw)
  To: cocci

On Fri, Sep 1, 2017 at 2:40 AM, Elena Reshetova
<elena.reshetova@intel.com> wrote:
> atomic_as_refcounter.cocci script allows detecting
> cases when refcount_t type and API should be used
> instead of atomic_t.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Reviewed-by: Kees Cook <keescook@chromium.org>

Oops, I think this got lost. Who can take this patch? I thought Julia
ran the scripts/coccinelle/ tree, but looking at git log, it looks
more like it's Masahiro? Either way, let's get this in the tree. Who
can take it?

Thanks!

-Kees

> ---
>  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
>  1 file changed, 131 insertions(+)
>  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
>
> diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> new file mode 100644
> index 0000000..bfa880d
> --- /dev/null
> +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> @@ -0,0 +1,131 @@
> +// Check if refcount_t type and API should be used
> +// instead of atomic_t type when dealing with refcounters
> +//
> +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> +//
> +// Confidence: Moderate
> +// URL: http://coccinelle.lip6.fr/
> +// Options: --include-headers --very-quiet
> +
> +virtual report
> +
> + at r1 exists@
> +identifier a, x;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test at p1(&(a)->x)
> +|
> + atomic_dec_and_lock at p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock at p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test at p1(&(a)->x)
> +|
> + atomic64_dec_and_test at p1(&(a)->x)
> +|
> + local_dec_and_test at p1(&(a)->x)
> +)
> +...
> +(
> + fname at p2(a, ...);
> +|
> + fname2 at p2(...);
> +|
> + fname3 at p2(...);
> +|
> + fname4 at p2(...);
> +|
> + fname5 at p2(...);
> +|
> + fname6 at p2(...);
> +)
> +
> +
> + at script:python depends on report@
> +p1 << r1.p1;
> +p2 << r1.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> + at r4 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test at p1(&(a)->x)
> +|
> + atomic_dec_and_lock at p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock at p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test at p1(&(a)->x)
> +|
> + atomic64_dec_and_test at p1(&(a)->x)
> +|
> + local_dec_and_test at p1(&(a)->x)
> +)
> +...
> +y=a
> +...
> +fname at p2(y, ...);
> +
> +
> + at script:python depends on report@
> +p1 << r4.p1;
> +p2 << r4.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> + at r2 exists@
> +identifier a, x;
> +position p1;
> +@@
> +
> +(
> +atomic_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic_long_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic64_add_unless(&(a)->x,-1,1)@p1
> +)
> +
> + at script:python depends on report@
> +p1 << r2.p1;
> +@@
> +msg = "atomic_add_unless"
> +coccilib.report.print_report(p1[0], msg)
> +
> + at r3 exists@
> +identifier x;
> +position p1;
> +@@
> +
> +(
> +x = atomic_add_return at p1(-1, ...);
> +|
> +x = atomic_long_add_return at p1(-1, ...);
> +|
> +x = atomic64_add_return at p1(-1, ...);
> +)
> +
> + at script:python depends on report@
> +p1 << r3.p1;
> +@@
> +msg = "x = atomic_add_return(-1, ...)"
> +coccilib.report.print_report(p1[0], msg)
> +
> +
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2018-06-14 23:58   ` [Cocci] " Kees Cook
@ 2018-06-15  5:06     ` Julia Lawall
  -1 siblings, 0 replies; 58+ messages in thread
From: Julia Lawall @ 2018-06-15  5:06 UTC (permalink / raw)
  To: Kees Cook
  Cc: Elena Reshetova, Masahiro Yamada, Julia Lawall, LKML, cocci,
	Gilles Muller, Nicolas Palix, Michal Marek, Hans Liljestrand



On Thu, 14 Jun 2018, Kees Cook wrote:

> On Fri, Sep 1, 2017 at 2:40 AM, Elena Reshetova
> <elena.reshetova@intel.com> wrote:
> > atomic_as_refcounter.cocci script allows detecting
> > cases when refcount_t type and API should be used
> > instead of atomic_t.
> >
> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> Oops, I think this got lost. Who can take this patch? I thought Julia
> ran the scripts/coccinelle/ tree, but looking at git log, it looks
> more like it's Masahiro? Either way, let's get this in the tree. Who
> can take it?

Masahiro takes patches.

julia

>
> Thanks!
>
> -Kees
>
> > ---
> >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
> >  1 file changed, 131 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> >
> > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > new file mode 100644
> > index 0000000..bfa880d
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > @@ -0,0 +1,131 @@
> > +// Check if refcount_t type and API should be used
> > +// instead of atomic_t type when dealing with refcounters
> > +//
> > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > +//
> > +// Confidence: Moderate
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --include-headers --very-quiet
> > +
> > +virtual report
> > +
> > +@r1 exists@
> > +identifier a, x;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +(
> > + fname@p2(a, ...);
> > +|
> > + fname2@p2(...);
> > +|
> > + fname3@p2(...);
> > +|
> > + fname4@p2(...);
> > +|
> > + fname5@p2(...);
> > +|
> > + fname6@p2(...);
> > +)
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r1.p1;
> > +p2 << r1.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r4 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +y=a
> > +...
> > +fname@p2(y, ...);
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r4.p1;
> > +p2 << r4.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r2 exists@
> > +identifier a, x;
> > +position p1;
> > +@@
> > +
> > +(
> > +atomic_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r2.p1;
> > +@@
> > +msg = "atomic_add_unless"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +@r3 exists@
> > +identifier x;
> > +position p1;
> > +@@
> > +
> > +(
> > +x = atomic_add_return@p1(-1, ...);
> > +|
> > +x = atomic_long_add_return@p1(-1, ...);
> > +|
> > +x = atomic64_add_return@p1(-1, ...);
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r3.p1;
> > +@@
> > +msg = "x = atomic_add_return(-1, ...)"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +
> > --
> > 2.7.4
> >
>
>
>
> --
> Kees Cook
> Pixel Security
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Cocci] [PATCH] Coccinelle: add atomic_as_refcounter script
@ 2018-06-15  5:06     ` Julia Lawall
  0 siblings, 0 replies; 58+ messages in thread
From: Julia Lawall @ 2018-06-15  5:06 UTC (permalink / raw)
  To: cocci



On Thu, 14 Jun 2018, Kees Cook wrote:

> On Fri, Sep 1, 2017 at 2:40 AM, Elena Reshetova
> <elena.reshetova@intel.com> wrote:
> > atomic_as_refcounter.cocci script allows detecting
> > cases when refcount_t type and API should be used
> > instead of atomic_t.
> >
> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> Oops, I think this got lost. Who can take this patch? I thought Julia
> ran the scripts/coccinelle/ tree, but looking at git log, it looks
> more like it's Masahiro? Either way, let's get this in the tree. Who
> can take it?

Masahiro takes patches.

julia

>
> Thanks!
>
> -Kees
>
> > ---
> >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
> >  1 file changed, 131 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> >
> > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > new file mode 100644
> > index 0000000..bfa880d
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > @@ -0,0 +1,131 @@
> > +// Check if refcount_t type and API should be used
> > +// instead of atomic_t type when dealing with refcounters
> > +//
> > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > +//
> > +// Confidence: Moderate
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --include-headers --very-quiet
> > +
> > +virtual report
> > +
> > + at r1 exists@
> > +identifier a, x;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test at p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock at p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock at p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test at p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test at p1(&(a)->x)
> > +|
> > + local_dec_and_test at p1(&(a)->x)
> > +)
> > +...
> > +(
> > + fname at p2(a, ...);
> > +|
> > + fname2 at p2(...);
> > +|
> > + fname3 at p2(...);
> > +|
> > + fname4 at p2(...);
> > +|
> > + fname5 at p2(...);
> > +|
> > + fname6 at p2(...);
> > +)
> > +
> > +
> > + at script:python depends on report@
> > +p1 << r1.p1;
> > +p2 << r1.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > + at r4 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test at p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock at p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock at p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test at p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test at p1(&(a)->x)
> > +|
> > + local_dec_and_test at p1(&(a)->x)
> > +)
> > +...
> > +y=a
> > +...
> > +fname at p2(y, ...);
> > +
> > +
> > + at script:python depends on report@
> > +p1 << r4.p1;
> > +p2 << r4.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > + at r2 exists@
> > +identifier a, x;
> > +position p1;
> > +@@
> > +
> > +(
> > +atomic_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > +)
> > +
> > + at script:python depends on report@
> > +p1 << r2.p1;
> > +@@
> > +msg = "atomic_add_unless"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > + at r3 exists@
> > +identifier x;
> > +position p1;
> > +@@
> > +
> > +(
> > +x = atomic_add_return at p1(-1, ...);
> > +|
> > +x = atomic_long_add_return at p1(-1, ...);
> > +|
> > +x = atomic64_add_return at p1(-1, ...);
> > +)
> > +
> > + at script:python depends on report@
> > +p1 << r3.p1;
> > +@@
> > +msg = "x = atomic_add_return(-1, ...)"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +
> > --
> > 2.7.4
> >
>
>
>
> --
> Kees Cook
> Pixel Security
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2018-06-15  5:06     ` [Cocci] " Julia Lawall
@ 2018-06-18 13:47       ` Masahiro Yamada
  -1 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2018-06-18 13:47 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Kees Cook, Elena Reshetova, LKML, cocci, Gilles Muller,
	Nicolas Palix, Michal Marek, Hans Liljestrand

2018-06-15 14:06 GMT+09:00 Julia Lawall <julia.lawall@lip6.fr>:
>
>
> On Thu, 14 Jun 2018, Kees Cook wrote:
>
>> On Fri, Sep 1, 2017 at 2:40 AM, Elena Reshetova
>> <elena.reshetova@intel.com> wrote:
>> > atomic_as_refcounter.cocci script allows detecting
>> > cases when refcount_t type and API should be used
>> > instead of atomic_t.
>> >
>> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
>> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>>
>> Reviewed-by: Kees Cook <keescook@chromium.org>
>>
>> Oops, I think this got lost. Who can take this patch? I thought Julia
>> ran the scripts/coccinelle/ tree, but looking at git log, it looks
>> more like it's Masahiro? Either way, let's get this in the tree. Who
>> can take it?
>
> Masahiro takes patches.
>
> julia


Somehow I missed this one.
Now, applied to linux-kbuild.  Thanks for the reminder.

(If Julia hosted a git repository, that would be better, though.)


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [Cocci] [PATCH] Coccinelle: add atomic_as_refcounter script
@ 2018-06-18 13:47       ` Masahiro Yamada
  0 siblings, 0 replies; 58+ messages in thread
From: Masahiro Yamada @ 2018-06-18 13:47 UTC (permalink / raw)
  To: cocci

2018-06-15 14:06 GMT+09:00 Julia Lawall <julia.lawall@lip6.fr>:
>
>
> On Thu, 14 Jun 2018, Kees Cook wrote:
>
>> On Fri, Sep 1, 2017 at 2:40 AM, Elena Reshetova
>> <elena.reshetova@intel.com> wrote:
>> > atomic_as_refcounter.cocci script allows detecting
>> > cases when refcount_t type and API should be used
>> > instead of atomic_t.
>> >
>> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
>> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>>
>> Reviewed-by: Kees Cook <keescook@chromium.org>
>>
>> Oops, I think this got lost. Who can take this patch? I thought Julia
>> ran the scripts/coccinelle/ tree, but looking at git log, it looks
>> more like it's Masahiro? Either way, let's get this in the tree. Who
>> can take it?
>
> Masahiro takes patches.
>
> julia


Somehow I missed this one.
Now, applied to linux-kbuild.  Thanks for the reminder.

(If Julia hosted a git repository, that would be better, though.)


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 0/6] Coccinelle: atomic_as_refcounter: Improvements for source code search specifications
  2018-06-18 13:47       ` [Cocci] " Masahiro Yamada
@ 2018-07-03  7:30         ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:30 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Jul 2018 09:15:26 +0200

This source code search pattern was programmed in the way that
some implementation details could be improved further.
I suggest to avoid unnecessary code repetition also in this script
for the semantic patch language.

Markus Elfring (6):
  Omit placeholder specifications from two SmPL constraints
  Optimise a disjunction in the first SmPL rule
  Use type “expression” for another metavariable
  Replace disjunction by a constraint in two SmPL rules
  Use nested disjunctions in two SmPL rules
  Use format strings directly in SmPL rules

 .../coccinelle/api/atomic_as_refcounter.cocci | 104 +++++++-----------
 1 file changed, 39 insertions(+), 65 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 0/6] Coccinelle: atomic_as_refcounter: Improvements for source code search specifications
@ 2018-07-03  7:30         ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:30 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Jul 2018 09:15:26 +0200

This source code search pattern was programmed in the way that
some implementation details could be improved further.
I suggest to avoid unnecessary code repetition also in this script
for the semantic patch language.

Markus Elfring (6):
  Omit placeholder specifications from two SmPL constraints
  Optimise a disjunction in the first SmPL rule
  Use type “expression” for another metavariable
  Replace disjunction by a constraint in two SmPL rules
  Use nested disjunctions in two SmPL rules
  Use format strings directly in SmPL rules

 .../coccinelle/api/atomic_as_refcounter.cocci | 104 +++++++-----------
 1 file changed, 39 insertions(+), 65 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH 1/6] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from two SmPL constraints
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-03  7:35           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:35 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 16:33:46 +0200

A string was enclosed by placeholder specifications for
regular expressions as constraints for metavariables in a script
for the semantic patch language.
The desired search functionality can be achieved also without
the notation “.*”. Thus delete it.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 988120e0fd67..94373a35744e 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -12,7 +12,7 @@ virtual report
 @r1 exists@
 identifier a, x;
 position p1, p2;
-identifier fname =~ ".*free.*";
+identifier fname =~ "free";
 identifier fname2 =~ ".*destroy.*";
 identifier fname3 =~ ".*del.*";
 identifier fname4 =~ ".*queue_work.*";
@@ -60,8 +60,7 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
 @r4 exists@
 identifier a, x, y;
 position p1, p2;
-identifier fname =~ ".*free.*";
-
+identifier fname =~ "free";
 @@
 
 (
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 1/6] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from two SmPL constrai
@ 2018-07-03  7:35           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:35 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 16:33:46 +0200

A string was enclosed by placeholder specifications for
regular expressions as constraints for metavariables in a script
for the semantic patch language.
The desired search functionality can be achieved also without
the notation “.*”. Thus delete it.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 988120e0fd67..94373a35744e 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -12,7 +12,7 @@ virtual report
 @r1 exists@
 identifier a, x;
 position p1, p2;
-identifier fname =~ ".*free.*";
+identifier fname =~ "free";
 identifier fname2 =~ ".*destroy.*";
 identifier fname3 =~ ".*del.*";
 identifier fname4 =~ ".*queue_work.*";
@@ -60,8 +60,7 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
 @r4 exists@
 identifier a, x, y;
 position p1, p2;
-identifier fname =~ ".*free.*";
-
+identifier fname =~ "free";
 @@
 
 (
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 2/6] Coccinelle: atomic_as_refcounter: Optimise a disjunction in the first SmPL rule
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-03  7:37           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:37 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 17:14:01 +0200

The names “fname2” till “fname6” do not care for different function
parameters in the disjunction at the end of a rule in a script
for the semantic patch language.
Thus reduce this disjunction by using a regular expression with
an alternation for an optimised constraint.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 94373a35744e..5571eea04c7b 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -13,12 +13,7 @@ virtual report
 identifier a, x;
 position p1, p2;
 identifier fname =~ "free";
-identifier fname2 =~ ".*destroy.*";
-identifier fname3 =~ ".*del.*";
-identifier fname4 =~ ".*queue_work.*";
-identifier fname5 =~ ".*schedule_work.*";
-identifier fname6 =~ ".*call_rcu.*";
-
+identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
@@ -39,14 +34,6 @@ identifier fname6 =~ ".*call_rcu.*";
  fname@p2(a, ...);
 |
  fname2@p2(...);
-|
- fname3@p2(...);
-|
- fname4@p2(...);
-|
- fname5@p2(...);
-|
- fname6@p2(...);
 )
 
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 2/6] Coccinelle: atomic_as_refcounter: Optimise a disjunction in the first SmPL rule
@ 2018-07-03  7:37           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:37 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 17:14:01 +0200

The names “fname2” till “fname6” do not care for different function
parameters in the disjunction at the end of a rule in a script
for the semantic patch language.
Thus reduce this disjunction by using a regular expression with
an alternation for an optimised constraint.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 94373a35744e..5571eea04c7b 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -13,12 +13,7 @@ virtual report
 identifier a, x;
 position p1, p2;
 identifier fname =~ "free";
-identifier fname2 =~ ".*destroy.*";
-identifier fname3 =~ ".*del.*";
-identifier fname4 =~ ".*queue_work.*";
-identifier fname5 =~ ".*schedule_work.*";
-identifier fname6 =~ ".*call_rcu.*";
-
+identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
@@ -39,14 +34,6 @@ identifier fname6 =~ ".*call_rcu.*";
  fname@p2(a, ...);
 |
  fname2@p2(...);
-|
- fname3@p2(...);
-|
- fname4@p2(...);
-|
- fname5@p2(...);
-|
- fname6@p2(...);
 )
 
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 3/6] Coccinelle: atomic_as_refcounter: Use type “expression” for another metavariable
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-03  7:40           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:40 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 17:55:27 +0200

The metavariable “a” is enclosed by parentheses in three rules of
a script for the semantic patch language.
Replace its type by “expression” so that the corresponding source code
search becomes more powerful.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 5571eea04c7b..57af2db9463e 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -10,7 +10,8 @@
 virtual report
 
 @r1 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1, p2;
 identifier fname =~ "free";
 identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
@@ -45,7 +46,8 @@ msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r4 exists@
-identifier a, x, y;
+expression a;
+identifier x, y;
 position p1, p2;
 identifier fname =~ "free";
 @@
@@ -77,7 +79,8 @@ msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1;
 @@
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 3/6] Coccinelle: atomic_as_refcounter: Use typ =?UTF-8?Q?e_=e2=80=9cexpressio
@ 2018-07-03  7:40           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:40 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 17:55:27 +0200

The metavariable “a” is enclosed by parentheses in three rules of
a script for the semantic patch language.
Replace its type by “expression” so that the corresponding source code
search becomes more powerful.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 5571eea04c7b..57af2db9463e 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -10,7 +10,8 @@
 virtual report
 
 @r1 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1, p2;
 identifier fname =~ "free";
 identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
@@ -45,7 +46,8 @@ msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r4 exists@
-identifier a, x, y;
+expression a;
+identifier x, y;
 position p1, p2;
 identifier fname =~ "free";
 @@
@@ -77,7 +79,8 @@ msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1;
 @@
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 4/6] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rules
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-03  7:42           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:42 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 18:45:15 +0200

Three function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Use a regular expression as a constraint for this source code search
pattern instead so that duplication of SmPL code can be avoided.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 21 +++++--------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 57af2db9463e..372ae99591fd 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -80,17 +80,11 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
 expression a;
-identifier x;
+identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
 position p1;
 @@
 
-(
-atomic_add_unless(&(a)->x,-1,1)@p1
-|
-atomic_long_add_unless(&(a)->x,-1,1)@p1
-|
-atomic64_add_unless(&(a)->x,-1,1)@p1
-)
+ F(&(a)->x, -1, 1)@p1
 
 @script:python depends on report@
 p1 << r2.p1;
@@ -99,17 +93,12 @@ msg = "atomic_add_unless"
 coccilib.report.print_report(p1[0], msg)
 
 @r3 exists@
-identifier x;
+expression E;
+identifier F =~ "^atomic(?:64|_long)?_add_return$";
 position p1;
 @@
 
-(
-x = atomic_add_return@p1(-1, ...);
-|
-x = atomic_long_add_return@p1(-1, ...);
-|
-x = atomic64_add_return@p1(-1, ...);
-)
+ E = F@p1(-1, ...);
 
 @script:python depends on report@
 p1 << r3.p1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 4/6] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rules
@ 2018-07-03  7:42           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:42 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 18:45:15 +0200

Three function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Use a regular expression as a constraint for this source code search
pattern instead so that duplication of SmPL code can be avoided.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 21 +++++--------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 57af2db9463e..372ae99591fd 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -80,17 +80,11 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
 expression a;
-identifier x;
+identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
 position p1;
 @@
 
-(
-atomic_add_unless(&(a)->x,-1,1)@p1
-|
-atomic_long_add_unless(&(a)->x,-1,1)@p1
-|
-atomic64_add_unless(&(a)->x,-1,1)@p1
-)
+ F(&(a)->x, -1, 1)@p1
 
 @script:python depends on report@
 p1 << r2.p1;
@@ -99,17 +93,12 @@ msg = "atomic_add_unless"
 coccilib.report.print_report(p1[0], msg)
 
 @r3 exists@
-identifier x;
+expression E;
+identifier F =~ "^atomic(?:64|_long)?_add_return$";
 position p1;
 @@
 
-(
-x = atomic_add_return@p1(-1, ...);
-|
-x = atomic_long_add_return@p1(-1, ...);
-|
-x = atomic64_add_return@p1(-1, ...);
-)
+ E = F@p1(-1, ...);
 
 @script:python depends on report@
 p1 << r3.p1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 5/6] Coccinelle: atomic_as_refcounter: Use nested disjunctions in two SmPL rules
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-03  7:45           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:45 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 19:21:28 +0200

Six function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Refactor them into two groups so that the SmPL code repetition
could be reduced a bit.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 36 +++++++++----------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 372ae99591fd..63cbe866c99f 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -18,17 +18,15 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
- atomic_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_test@p1
+|atomic_long_dec_and_test@p1
+|atomic64_dec_and_test@p1
+|local_dec_and_test@p1
+)                           (&(a)->x)
 |
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
-|
- local_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_lock@p1
+|atomic_long_dec_and_lock@p1
+)                           (&(a)->x, ...)
 )
 ...
 (
@@ -53,17 +51,15 @@ identifier fname =~ "free";
 @@
 
 (
- atomic_dec_and_test@p1(&(a)->x)
-|
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_test@p1
+|atomic_long_dec_and_test@p1
+|atomic64_dec_and_test@p1
+|local_dec_and_test@p1
+)                           (&(a)->x)
 |
- local_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_lock@p1
+|atomic_long_dec_and_lock@p1
+)                           (&(a)->x, ...)
 )
 ...
 y=a
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 5/6] Coccinelle: atomic_as_refcounter: Use nested disjunctions in two SmPL rules
@ 2018-07-03  7:45           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:45 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 19:21:28 +0200

Six function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Refactor them into two groups so that the SmPL code repetition
could be reduced a bit.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 36 +++++++++----------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 372ae99591fd..63cbe866c99f 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -18,17 +18,15 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
- atomic_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_test@p1
+|atomic_long_dec_and_test@p1
+|atomic64_dec_and_test@p1
+|local_dec_and_test@p1
+)                           (&(a)->x)
 |
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
-|
- local_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_lock@p1
+|atomic_long_dec_and_lock@p1
+)                           (&(a)->x, ...)
 )
 ...
 (
@@ -53,17 +51,15 @@ identifier fname =~ "free";
 @@
 
 (
- atomic_dec_and_test@p1(&(a)->x)
-|
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_test@p1
+|atomic_long_dec_and_test@p1
+|atomic64_dec_and_test@p1
+|local_dec_and_test@p1
+)                           (&(a)->x)
 |
- local_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_lock@p1
+|atomic_long_dec_and_lock@p1
+)                           (&(a)->x, ...)
 )
 ...
 y=a
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 6/6] Coccinelle: atomic_as_refcounter: Use format strings directly in SmPL rules
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-03  7:48           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:48 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 19:46:45 +0200

Format strings were always assigned to the Python variable “msg”
before they were used in four rules of a script for the semantic
patch language.
Delete these extra variables so that the specified string objects
are directly used for the desired data output.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 63cbe866c99f..1e2278ff3261 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -40,8 +40,9 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 p1 << r1.p1;
 p2 << r1.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
+coccilib.report.print_report(p1[0],
+                             "atomic_dec_and_test variation before object free at line %s."
+                             % (p2[0].line))
 
 @r4 exists@
 expression a;
@@ -71,8 +72,9 @@ fname@p2(y, ...);
 p1 << r4.p1;
 p2 << r4.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
+coccilib.report.print_report(p1[0],
+                             "atomic_dec_and_test variation before object free at line %s."
+                             % (p2[0].line))
 
 @r2 exists@
 expression a;
@@ -85,8 +87,7 @@ position p1;
 @script:python depends on report@
 p1 << r2.p1;
 @@
-msg = "atomic_add_unless"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "atomic_add_unless")
 
 @r3 exists@
 expression E;
@@ -99,5 +100,4 @@ position p1;
 @script:python depends on report@
 p1 << r3.p1;
 @@
-msg = "x = atomic_add_return(-1, ...)"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "x = atomic_add_return(-1, ...)")
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH 6/6] Coccinelle: atomic_as_refcounter: Use format strings directly in SmPL rules
@ 2018-07-03  7:48           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-03  7:48 UTC (permalink / raw)
  To: Elena Reshetova, Julia Lawall, Kees Cook, Masahiro Yamada,
	kernel-janitors
  Cc: LKML, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Jul 2018 19:46:45 +0200

Format strings were always assigned to the Python variable “msg”
before they were used in four rules of a script for the semantic
patch language.
Delete these extra variables so that the specified string objects
are directly used for the desired data output.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 63cbe866c99f..1e2278ff3261 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -40,8 +40,9 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 p1 << r1.p1;
 p2 << r1.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
+coccilib.report.print_report(p1[0],
+                             "atomic_dec_and_test variation before object free at line %s."
+                             % (p2[0].line))
 
 @r4 exists@
 expression a;
@@ -71,8 +72,9 @@ fname@p2(y, ...);
 p1 << r4.p1;
 p2 << r4.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
+coccilib.report.print_report(p1[0],
+                             "atomic_dec_and_test variation before object free at line %s."
+                             % (p2[0].line))
 
 @r2 exists@
 expression a;
@@ -85,8 +87,7 @@ position p1;
 @script:python depends on report@
 p1 << r2.p1;
 @@
-msg = "atomic_add_unless"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "atomic_add_unless")
 
 @r3 exists@
 expression E;
@@ -99,5 +100,4 @@ position p1;
 @script:python depends on report@
 p1 << r3.p1;
 @@
-msg = "x = atomic_add_return(-1, ...)"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "x = atomic_add_return(-1, ...)")
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 0/8] Coccinelle: atomic_as_refcounter: Adjustments for source code search specifications
  2018-07-03  7:30         ` SF Markus Elfring
@ 2018-07-16 17:21           ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:21 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 19:15:26 +0200

This source code search pattern was programmed in the way that
some implementation details could be improved further.
I suggest to avoid unnecessary code repetition also in this script
for the semantic patch language.

Markus Elfring (8):
  Delete an unnecessary SmPL rule
  Omit placeholder specifications from a SmPL constraint
  Optimise a disjunction in the first SmPL rule
  Use type “expression” for another metavariable
  Replace disjunction by a constraint in two SmPL rules
  Use nested disjunctions in the first SmPL rule
  Use string literals directly in two SmPL rules
  Use format string directly in the first SmPL rule

---

V2:
Possible changes were recombined after the deletion of a questionable
SmPL rule.

 .../coccinelle/api/atomic_as_refcounter.cocci | 108 ++++--------------
 1 file changed, 24 insertions(+), 84 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH v2 0/8] Coccinelle: atomic_as_refcounter: Adjustments for source code search specifications
@ 2018-07-16 17:21           ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:21 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 19:15:26 +0200

This source code search pattern was programmed in the way that
some implementation details could be improved further.
I suggest to avoid unnecessary code repetition also in this script
for the semantic patch language.

Markus Elfring (8):
  Delete an unnecessary SmPL rule
  Omit placeholder specifications from a SmPL constraint
  Optimise a disjunction in the first SmPL rule
  Use type “expression” for another metavariable
  Replace disjunction by a constraint in two SmPL rules
  Use nested disjunctions in the first SmPL rule
  Use string literals directly in two SmPL rules
  Use format string directly in the first SmPL rule

---

V2:
Possible changes were recombined after the deletion of a questionable
SmPL rule.

 .../coccinelle/api/atomic_as_refcounter.cocci | 108 ++++--------------
 1 file changed, 24 insertions(+), 84 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH v2 1/8] Coccinelle: atomic_as_refcounter: Delete an unnecessary SmPL rule
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:24             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:24 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 17:15:26 +0200

A search was specified in the rule “r4” for function calls which should be
found by the rule “r1” already in a script for the semantic patch language.
It is useless to repeat a source code search there just to determine
that a variable assignment was performed also for an input parameter
of such a function call (while the same message will be displayed so far).
Thus delete an inappropriate search specification.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 33 -------------------
 1 file changed, 33 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 988120e0fd67..61fcaf5e45a3 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -57,39 +57,6 @@ p2 << r1.p2;
 msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
-@r4 exists@
-identifier a, x, y;
-position p1, p2;
-identifier fname =~ ".*free.*";
-
-@@
-
-(
- atomic_dec_and_test@p1(&(a)->x)
-|
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
-|
- local_dec_and_test@p1(&(a)->x)
-)
-...
-y=a
-...
-fname@p2(y, ...);
-
-
-@script:python depends on report@
-p1 << r4.p1;
-p2 << r4.p2;
-@@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
-
 @r2 exists@
 identifier a, x;
 position p1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 1/8] Coccinelle: atomic_as_refcounter: Delete an unnecessary SmPL rule
@ 2018-07-16 17:24             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:24 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 17:15:26 +0200

A search was specified in the rule “r4” for function calls which should be
found by the rule “r1” already in a script for the semantic patch language.
It is useless to repeat a source code search there just to determine
that a variable assignment was performed also for an input parameter
of such a function call (while the same message will be displayed so far).
Thus delete an inappropriate search specification.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 33 -------------------
 1 file changed, 33 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 988120e0fd67..61fcaf5e45a3 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -57,39 +57,6 @@ p2 << r1.p2;
 msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
-@r4 exists@
-identifier a, x, y;
-position p1, p2;
-identifier fname =~ ".*free.*";
-
-@@
-
-(
- atomic_dec_and_test@p1(&(a)->x)
-|
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
-|
- local_dec_and_test@p1(&(a)->x)
-)
-...
-y=a
-...
-fname@p2(y, ...);
-
-
-@script:python depends on report@
-p1 << r4.p1;
-p2 << r4.p2;
-@@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
-
 @r2 exists@
 identifier a, x;
 position p1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 2/8] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from a SmPL constraint
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:26             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:26 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 17:34:56 +0200

A string was enclosed by placeholder specifications for
regular expressions as constraints for metavariables in a script
for the semantic patch language.
The desired search functionality can be achieved also without
the notation “.*”. Thus delete it at a specific place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 61fcaf5e45a3..46d27b2b1dff 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -12,7 +12,7 @@ virtual report
 @r1 exists@
 identifier a, x;
 position p1, p2;
-identifier fname =~ ".*free.*";
+identifier fname =~ "free";
 identifier fname2 =~ ".*destroy.*";
 identifier fname3 =~ ".*del.*";
 identifier fname4 =~ ".*queue_work.*";
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 2/8] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from a SmPL constra
@ 2018-07-16 17:26             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:26 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 17:34:56 +0200

A string was enclosed by placeholder specifications for
regular expressions as constraints for metavariables in a script
for the semantic patch language.
The desired search functionality can be achieved also without
the notation “.*”. Thus delete it at a specific place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 61fcaf5e45a3..46d27b2b1dff 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -12,7 +12,7 @@ virtual report
 @r1 exists@
 identifier a, x;
 position p1, p2;
-identifier fname =~ ".*free.*";
+identifier fname =~ "free";
 identifier fname2 =~ ".*destroy.*";
 identifier fname3 =~ ".*del.*";
 identifier fname4 =~ ".*queue_work.*";
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 3/8] Coccinelle: atomic_as_refcounter: Optimise a disjunction in the first SmPL rule
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:28             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:28 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 17:43:49 +0200

The variables “fname2” till “fname6” do not care for different function
parameters in the disjunction at the end of a rule in a script
for the semantic patch language.
Thus reduce this disjunction by using a regular expression with
an alternation for an optimised constraint.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 46d27b2b1dff..4da83ccfa6f6 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -13,12 +13,7 @@ virtual report
 identifier a, x;
 position p1, p2;
 identifier fname =~ "free";
-identifier fname2 =~ ".*destroy.*";
-identifier fname3 =~ ".*del.*";
-identifier fname4 =~ ".*queue_work.*";
-identifier fname5 =~ ".*schedule_work.*";
-identifier fname6 =~ ".*call_rcu.*";
-
+identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
@@ -39,14 +34,6 @@ identifier fname6 =~ ".*call_rcu.*";
  fname@p2(a, ...);
 |
  fname2@p2(...);
-|
- fname3@p2(...);
-|
- fname4@p2(...);
-|
- fname5@p2(...);
-|
- fname6@p2(...);
 )
 
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 3/8] Coccinelle: atomic_as_refcounter: Optimise a disjunction in the first SmPL rule
@ 2018-07-16 17:28             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:28 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 17:43:49 +0200

The variables “fname2” till “fname6” do not care for different function
parameters in the disjunction at the end of a rule in a script
for the semantic patch language.
Thus reduce this disjunction by using a regular expression with
an alternation for an optimised constraint.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 46d27b2b1dff..4da83ccfa6f6 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -13,12 +13,7 @@ virtual report
 identifier a, x;
 position p1, p2;
 identifier fname =~ "free";
-identifier fname2 =~ ".*destroy.*";
-identifier fname3 =~ ".*del.*";
-identifier fname4 =~ ".*queue_work.*";
-identifier fname5 =~ ".*schedule_work.*";
-identifier fname6 =~ ".*call_rcu.*";
-
+identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
@@ -39,14 +34,6 @@ identifier fname6 =~ ".*call_rcu.*";
  fname@p2(a, ...);
 |
  fname2@p2(...);
-|
- fname3@p2(...);
-|
- fname4@p2(...);
-|
- fname5@p2(...);
-|
- fname6@p2(...);
 )
 
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 4/8] Coccinelle: atomic_as_refcounter: Use type “expression” for another metavariable
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:30             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:30 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:00:54 +0200

The metavariable “a” is enclosed by parentheses in two rules of
a script for the semantic patch language.
Replace its type by “expression” so that the corresponding source code
search becomes more powerful.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 4da83ccfa6f6..62b0132d65fc 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -10,7 +10,8 @@
 virtual report
 
 @r1 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1, p2;
 identifier fname =~ "free";
 identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
@@ -45,7 +46,8 @@ msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1;
 @@
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 4/8] Coccinelle: atomic_as_refcounter: Use  =?UTF-8?Q?type_=e2=80=9cexpres
@ 2018-07-16 17:30             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:30 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:00:54 +0200

The metavariable “a” is enclosed by parentheses in two rules of
a script for the semantic patch language.
Replace its type by “expression” so that the corresponding source code
search becomes more powerful.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 4da83ccfa6f6..62b0132d65fc 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -10,7 +10,8 @@
 virtual report
 
 @r1 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1, p2;
 identifier fname =~ "free";
 identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
@@ -45,7 +46,8 @@ msg = "atomic_dec_and_test variation before object free at line %s."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
-identifier a, x;
+expression a;
+identifier x;
 position p1;
 @@
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 5/8] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rules
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:32             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:32 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:12:10 +0200

Three function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Use a regular expression as a constraint for this source code search
pattern instead so that duplication of SmPL code can be avoided.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 23 ++++---------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 62b0132d65fc..4484bea6c9d8 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -47,17 +47,10 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
 expression a;
-identifier x;
+identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
 position p1;
 @@
-
-(
-atomic_add_unless(&(a)->x,-1,1)@p1
-|
-atomic_long_add_unless(&(a)->x,-1,1)@p1
-|
-atomic64_add_unless(&(a)->x,-1,1)@p1
-)
+ F(&(a)->x, -1, 1)@p1
 
 @script:python depends on report@
 p1 << r2.p1;
@@ -66,17 +59,11 @@ msg = "atomic_add_unless"
 coccilib.report.print_report(p1[0], msg)
 
 @r3 exists@
-identifier x;
+expression E;
+identifier F =~ "^atomic(?:64|_long)?_add_return$";
 position p1;
 @@
-
-(
-x = atomic_add_return@p1(-1, ...);
-|
-x = atomic_long_add_return@p1(-1, ...);
-|
-x = atomic64_add_return@p1(-1, ...);
-)
+ E = F@p1(-1, ...);
 
 @script:python depends on report@
 p1 << r3.p1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 5/8] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rul
@ 2018-07-16 17:32             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:32 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:12:10 +0200

Three function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Use a regular expression as a constraint for this source code search
pattern instead so that duplication of SmPL code can be avoided.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 23 ++++---------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 62b0132d65fc..4484bea6c9d8 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -47,17 +47,10 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
 expression a;
-identifier x;
+identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
 position p1;
 @@
-
-(
-atomic_add_unless(&(a)->x,-1,1)@p1
-|
-atomic_long_add_unless(&(a)->x,-1,1)@p1
-|
-atomic64_add_unless(&(a)->x,-1,1)@p1
-)
+ F(&(a)->x, -1, 1)@p1
 
 @script:python depends on report@
 p1 << r2.p1;
@@ -66,17 +59,11 @@ msg = "atomic_add_unless"
 coccilib.report.print_report(p1[0], msg)
 
 @r3 exists@
-identifier x;
+expression E;
+identifier F =~ "^atomic(?:64|_long)?_add_return$";
 position p1;
 @@
-
-(
-x = atomic_add_return@p1(-1, ...);
-|
-x = atomic_long_add_return@p1(-1, ...);
-|
-x = atomic64_add_return@p1(-1, ...);
-)
+ E = F@p1(-1, ...);
 
 @script:python depends on report@
 p1 << r3.p1;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 6/8] Coccinelle: atomic_as_refcounter: Use nested disjunctions in the first SmPL rule
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:34             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:34 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:22:53 +0200

Six function names were specified for a search of function calls
by the means of a disjunction in the rule of a script for
the semantic patch language.
Refactor them into two groups so that the SmPL code repetition
could be reduced a bit.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci  | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 4484bea6c9d8..7eae23dc9ea8 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -18,17 +18,15 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
- atomic_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_test@p1
+|atomic_long_dec_and_test@p1
+|atomic64_dec_and_test@p1
+|local_dec_and_test@p1
+)                           (&(a)->x)
 |
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
-|
- local_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_lock@p1
+|atomic_long_dec_and_lock@p1
+)                           (&(a)->x, ...)
 )
 ...
 (
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 6/8] Coccinelle: atomic_as_refcounter: Use nested disjunctions in the first SmPL rule
@ 2018-07-16 17:34             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:34 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:22:53 +0200

Six function names were specified for a search of function calls
by the means of a disjunction in the rule of a script for
the semantic patch language.
Refactor them into two groups so that the SmPL code repetition
could be reduced a bit.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci  | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 4484bea6c9d8..7eae23dc9ea8 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -18,17 +18,15 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
 
 (
- atomic_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_test@p1
+|atomic_long_dec_and_test@p1
+|atomic64_dec_and_test@p1
+|local_dec_and_test@p1
+)                           (&(a)->x)
 |
- atomic_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_lock@p1(&(a)->x, ...)
-|
- atomic_long_dec_and_test@p1(&(a)->x)
-|
- atomic64_dec_and_test@p1(&(a)->x)
-|
- local_dec_and_test@p1(&(a)->x)
+(atomic_dec_and_lock@p1
+|atomic_long_dec_and_lock@p1
+)                           (&(a)->x, ...)
 )
 ...
 (
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 7/8] Coccinelle: atomic_as_refcounter: Use string literals directly in two SmPL rules
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:36             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:36 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:36:41 +0200

String literals were always assigned to the Python variable “msg”
before they were used in two rules of a script for the semantic
patch language.
Delete these extra variables so that the specified string objects
are directly used for the desired data output.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 7eae23dc9ea8..c9b838941024 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -53,8 +53,7 @@ position p1;
 @script:python depends on report@
 p1 << r2.p1;
 @@
-msg = "atomic_add_unless"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "atomic_add_unless")
 
 @r3 exists@
 expression E;
@@ -66,5 +65,4 @@ position p1;
 @script:python depends on report@
 p1 << r3.p1;
 @@
-msg = "x = atomic_add_return(-1, ...)"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "x = atomic_add_return(-1, ...)")
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 7/8] Coccinelle: atomic_as_refcounter: Use string literals directly in two SmPL rules
@ 2018-07-16 17:36             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:36 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:36:41 +0200

String literals were always assigned to the Python variable “msg”
before they were used in two rules of a script for the semantic
patch language.
Delete these extra variables so that the specified string objects
are directly used for the desired data output.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 7eae23dc9ea8..c9b838941024 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -53,8 +53,7 @@ position p1;
 @script:python depends on report@
 p1 << r2.p1;
 @@
-msg = "atomic_add_unless"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "atomic_add_unless")
 
 @r3 exists@
 expression E;
@@ -66,5 +65,4 @@ position p1;
 @script:python depends on report@
 p1 << r3.p1;
 @@
-msg = "x = atomic_add_return(-1, ...)"
-coccilib.report.print_report(p1[0], msg)
+coccilib.report.print_report(p1[0], "x = atomic_add_return(-1, ...)")
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 8/8] Coccinelle: atomic_as_refcounter: Use format string directly in the first SmPL rule
  2018-07-16 17:21           ` SF Markus Elfring
@ 2018-07-16 17:39             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:39 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:45:55 +0200

A format string was assigned to the Python variable “msg” before it was
used in a rule of a script for the semantic patch language.
Delete this extra variable so that the specified string object
is directly used for the desired data output.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index c9b838941024..c2b55a5babb0 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -40,8 +40,9 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 p1 << r1.p1;
 p2 << r1.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
+coccilib.report.print_report(p1[0],
+                             "atomic_dec_and_test variation before object free at line %s."
+                             % (p2[0].line))
 
 @r2 exists@
 expression a;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH v2 8/8] Coccinelle: atomic_as_refcounter: Use format string directly in the first SmPL rule
@ 2018-07-16 17:39             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-07-16 17:39 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Jul 2018 18:45:55 +0200

A format string was assigned to the Python variable “msg” before it was
used in a rule of a script for the semantic patch language.
Delete this extra variable so that the specified string object
is directly used for the desired data output.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index c9b838941024..c2b55a5babb0 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -40,8 +40,9 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 p1 << r1.p1;
 p2 << r1.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
-coccilib.report.print_report(p1[0], msg % (p2[0].line))
+coccilib.report.print_report(p1[0],
+                             "atomic_dec_and_test variation before object free at line %s."
+                             % (p2[0].line))
 
 @r2 exists@
 expression a;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH] Coccinelle: atomic_as_refcounter: Merge two SmPL rules
  2018-07-03  7:48           ` SF Markus Elfring
@ 2018-08-01 12:30             ` SF Markus Elfring
  -1 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-08-01 12:30 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Aug 2018 14:16:01 +0200

Two rules of a script for the semantic patch language displayed
the same message.
Thus reduce duplicate SmPL code so that the desired data processing
is achieved by another nested SmPL disjunction in a single SmPL rule.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 50 ++++---------------
 1 file changed, 10 insertions(+), 40 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 1e2278ff3261..292a029d5a51 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -11,12 +11,11 @@ virtual report
 
 @r1 exists@
 expression a;
-identifier x;
 position p1, p2;
-identifier fname =~ "free";
-identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
+identifier x, y,
+           fname =~ "free",
+           fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
-
 (
 (atomic_dec_and_test@p1
 |atomic_long_dec_and_test@p1
@@ -28,14 +27,17 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 |atomic_long_dec_and_lock@p1
 )                           (&(a)->x, ...)
 )
-...
+ ...
 (
- fname@p2(a, ...);
+(fname@p2(a, ...)
+|fname2@p2(...)
+);
 |
- fname2@p2(...);
+ y = a
+ ...
+ fname@p2(y, ...);
 )
 
-
 @script:python depends on report@
 p1 << r1.p1;
 p2 << r1.p2;
@@ -44,38 +46,6 @@ coccilib.report.print_report(p1[0],
                              "atomic_dec_and_test variation before object free at line %s."
                              % (p2[0].line))
 
-@r4 exists@
-expression a;
-identifier x, y;
-position p1, p2;
-identifier fname =~ "free";
-@@
-
-(
-(atomic_dec_and_test@p1
-|atomic_long_dec_and_test@p1
-|atomic64_dec_and_test@p1
-|local_dec_and_test@p1
-)                           (&(a)->x)
-|
-(atomic_dec_and_lock@p1
-|atomic_long_dec_and_lock@p1
-)                           (&(a)->x, ...)
-)
-...
-y=a
-...
-fname@p2(y, ...);
-
-
-@script:python depends on report@
-p1 << r4.p1;
-p2 << r4.p2;
-@@
-coccilib.report.print_report(p1[0],
-                             "atomic_dec_and_test variation before object free at line %s."
-                             % (p2[0].line))
-
 @r2 exists@
 expression a;
 identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* [PATCH] Coccinelle: atomic_as_refcounter: Merge two SmPL rules
@ 2018-08-01 12:30             ` SF Markus Elfring
  0 siblings, 0 replies; 58+ messages in thread
From: SF Markus Elfring @ 2018-08-01 12:30 UTC (permalink / raw)
  To: kernel-janitors, Elena Reshetova, Julia Lawall, Kees Cook,
	Masahiro Yamada
  Cc: LKML, Coccinelle, Gilles Muller, Michal Marek, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Aug 2018 14:16:01 +0200

Two rules of a script for the semantic patch language displayed
the same message.
Thus reduce duplicate SmPL code so that the desired data processing
is achieved by another nested SmPL disjunction in a single SmPL rule.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../coccinelle/api/atomic_as_refcounter.cocci | 50 ++++---------------
 1 file changed, 10 insertions(+), 40 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 1e2278ff3261..292a029d5a51 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -11,12 +11,11 @@ virtual report
 
 @r1 exists@
 expression a;
-identifier x;
 position p1, p2;
-identifier fname =~ "free";
-identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
+identifier x, y,
+           fname =~ "free",
+           fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 @@
-
 (
 (atomic_dec_and_test@p1
 |atomic_long_dec_and_test@p1
@@ -28,14 +27,17 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
 |atomic_long_dec_and_lock@p1
 )                           (&(a)->x, ...)
 )
-...
+ ...
 (
- fname@p2(a, ...);
+(fname@p2(a, ...)
+|fname2@p2(...)
+);
 |
- fname2@p2(...);
+ y = a
+ ...
+ fname@p2(y, ...);
 )
 
-
 @script:python depends on report@
 p1 << r1.p1;
 p2 << r1.p2;
@@ -44,38 +46,6 @@ coccilib.report.print_report(p1[0],
                              "atomic_dec_and_test variation before object free at line %s."
                              % (p2[0].line))
 
-@r4 exists@
-expression a;
-identifier x, y;
-position p1, p2;
-identifier fname =~ "free";
-@@
-
-(
-(atomic_dec_and_test@p1
-|atomic_long_dec_and_test@p1
-|atomic64_dec_and_test@p1
-|local_dec_and_test@p1
-)                           (&(a)->x)
-|
-(atomic_dec_and_lock@p1
-|atomic_long_dec_and_lock@p1
-)                           (&(a)->x, ...)
-)
-...
-y=a
-...
-fname@p2(y, ...);
-
-
-@script:python depends on report@
-p1 << r4.p1;
-p2 << r4.p2;
-@@
-coccilib.report.print_report(p1[0],
-                             "atomic_dec_and_test variation before object free at line %s."
-                             % (p2[0].line))
-
 @r2 exists@
 expression a;
 identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-30 13:06       ` Julia Lawall
@ 2017-08-31  9:46         ` Reshetova, Elena
  0 siblings, 0 replies; 58+ messages in thread
From: Reshetova, Elena @ 2017-08-31  9:46 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel

> On Wed, 30 Aug 2017, Reshetova, Elena wrote:
> 
> >
> > >
> > > On Wed, 30 Aug 2017, Elena Reshetova wrote:
> > >
> > > > atomic_as_refcounter.cocci script allows detecting
> > > > cases when refcount_t type and API should be used
> > > > instead of atomic_t.
> > > >
> > > > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> > >
> > > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> >
> > Thank you very much Julia! What is the correct path to merge this?
> > I will resend with your acked-by, but what is the tree that should merge it?
> 
> Marek will take it.  If you want to resend, please get rid of the
> metavariable y in the rule r1. It causes an unused variable warning.

Sure, will do. Thank you!

Best Regards,
Elena.
> 
> julia
> 
> >
> > Best Regards,
> > Elena.
> > >
> > > > ---
> > > >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131
> > > ++++++++++++++++++++++
> > > >  1 file changed, 131 insertions(+)
> > > >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> > > >
> > > > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > > b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > > > new file mode 100644
> > > > index 0000000..f83771b
> > > > --- /dev/null
> > > > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > > > @@ -0,0 +1,131 @@
> > > > +// Check if refcount_t type and API should be used
> > > > +// instead of atomic_t type when dealing with refcounters
> > > > +//
> > > > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > > > +//
> > > > +// Confidence: Moderate
> > > > +// URL: http://coccinelle.lip6.fr/
> > > > +// Options: --include-headers --very-quiet
> > > > +
> > > > +virtual report
> > > > +
> > > > +@r1 exists@
> > > > +identifier a, x, y;
> > > > +position p1, p2;
> > > > +identifier fname =~ ".*free.*";
> > > > +identifier fname2 =~ ".*destroy.*";
> > > > +identifier fname3 =~ ".*del.*";
> > > > +identifier fname4 =~ ".*queue_work.*";
> > > > +identifier fname5 =~ ".*schedule_work.*";
> > > > +identifier fname6 =~ ".*call_rcu.*";
> > > > +
> > > > +@@
> > > > +
> > > > +(
> > > > + atomic_dec_and_test@p1(&(a)->x)
> > > > +|
> > > > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > > > +|
> > > > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > > > +|
> > > > + atomic_long_dec_and_test@p1(&(a)->x)
> > > > +|
> > > > + atomic64_dec_and_test@p1(&(a)->x)
> > > > +|
> > > > + local_dec_and_test@p1(&(a)->x)
> > > > +)
> > > > +...
> > > > +(
> > > > + fname@p2(a, ...);
> > > > +|
> > > > + fname2@p2(...);
> > > > +|
> > > > + fname3@p2(...);
> > > > +|
> > > > + fname4@p2(...);
> > > > +|
> > > > + fname5@p2(...);
> > > > +|
> > > > + fname6@p2(...);
> > > > +)
> > > > +
> > > > +
> > > > +@script:python depends on report@
> > > > +p1 << r1.p1;
> > > > +p2 << r1.p2;
> > > > +@@
> > > > +msg = "atomic_dec_and_test variation before object free at line %s."
> > > > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > > > +
> > > > +@r4 exists@
> > > > +identifier a, x, y;
> > > > +position p1, p2;
> > > > +identifier fname =~ ".*free.*";
> > > > +
> > > > +@@
> > > > +
> > > > +(
> > > > + atomic_dec_and_test@p1(&(a)->x)
> > > > +|
> > > > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > > > +|
> > > > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > > > +|
> > > > + atomic_long_dec_and_test@p1(&(a)->x)
> > > > +|
> > > > + atomic64_dec_and_test@p1(&(a)->x)
> > > > +|
> > > > + local_dec_and_test@p1(&(a)->x)
> > > > +)
> > > > +...
> > > > +y=a
> > > > +...
> > > > +fname@p2(y, ...);
> > > > +
> > > > +
> > > > +@script:python depends on report@
> > > > +p1 << r4.p1;
> > > > +p2 << r4.p2;
> > > > +@@
> > > > +msg = "atomic_dec_and_test variation before object free at line %s."
> > > > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > > > +
> > > > +@r2 exists@
> > > > +identifier a, x;
> > > > +position p1;
> > > > +@@
> > > > +
> > > > +(
> > > > +atomic_add_unless(&(a)->x,-1,1)@p1
> > > > +|
> > > > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > > > +|
> > > > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > > > +)
> > > > +
> > > > +@script:python depends on report@
> > > > +p1 << r2.p1;
> > > > +@@
> > > > +msg = "atomic_add_unless"
> > > > +coccilib.report.print_report(p1[0], msg)
> > > > +
> > > > +@r3 exists@
> > > > +identifier x;
> > > > +position p1;
> > > > +@@
> > > > +
> > > > +(
> > > > +x = atomic_add_return@p1(-1, ...);
> > > > +|
> > > > +x = atomic_long_add_return@p1(-1, ...);
> > > > +|
> > > > +x = atomic64_add_return@p1(-1, ...);
> > > > +)
> > > > +
> > > > +@script:python depends on report@
> > > > +p1 << r3.p1;
> > > > +@@
> > > > +msg = "x = atomic_add_return(-1, ...)"
> > > > +coccilib.report.print_report(p1[0], msg)
> > > > +
> > > > +
> > > > --
> > > > 2.7.4
> > > >
> > > >
> >

^ permalink raw reply	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-30 12:44     ` Reshetova, Elena
@ 2017-08-30 13:06       ` Julia Lawall
  2017-08-31  9:46         ` Reshetova, Elena
  0 siblings, 1 reply; 58+ messages in thread
From: Julia Lawall @ 2017-08-30 13:06 UTC (permalink / raw)
  To: Reshetova, Elena
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel



On Wed, 30 Aug 2017, Reshetova, Elena wrote:

>
> >
> > On Wed, 30 Aug 2017, Elena Reshetova wrote:
> >
> > > atomic_as_refcounter.cocci script allows detecting
> > > cases when refcount_t type and API should be used
> > > instead of atomic_t.
> > >
> > > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> >
> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
>
> Thank you very much Julia! What is the correct path to merge this?
> I will resend with your acked-by, but what is the tree that should merge it?

Marek will take it.  If you want to resend, please get rid of the
metavariable y in the rule r1. It causes an unused variable warning.

julia

>
> Best Regards,
> Elena.
> >
> > > ---
> > >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131
> > ++++++++++++++++++++++
> > >  1 file changed, 131 insertions(+)
> > >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> > >
> > > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > > new file mode 100644
> > > index 0000000..f83771b
> > > --- /dev/null
> > > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > > @@ -0,0 +1,131 @@
> > > +// Check if refcount_t type and API should be used
> > > +// instead of atomic_t type when dealing with refcounters
> > > +//
> > > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > > +//
> > > +// Confidence: Moderate
> > > +// URL: http://coccinelle.lip6.fr/
> > > +// Options: --include-headers --very-quiet
> > > +
> > > +virtual report
> > > +
> > > +@r1 exists@
> > > +identifier a, x, y;
> > > +position p1, p2;
> > > +identifier fname =~ ".*free.*";
> > > +identifier fname2 =~ ".*destroy.*";
> > > +identifier fname3 =~ ".*del.*";
> > > +identifier fname4 =~ ".*queue_work.*";
> > > +identifier fname5 =~ ".*schedule_work.*";
> > > +identifier fname6 =~ ".*call_rcu.*";
> > > +
> > > +@@
> > > +
> > > +(
> > > + atomic_dec_and_test@p1(&(a)->x)
> > > +|
> > > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > > +|
> > > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > > +|
> > > + atomic_long_dec_and_test@p1(&(a)->x)
> > > +|
> > > + atomic64_dec_and_test@p1(&(a)->x)
> > > +|
> > > + local_dec_and_test@p1(&(a)->x)
> > > +)
> > > +...
> > > +(
> > > + fname@p2(a, ...);
> > > +|
> > > + fname2@p2(...);
> > > +|
> > > + fname3@p2(...);
> > > +|
> > > + fname4@p2(...);
> > > +|
> > > + fname5@p2(...);
> > > +|
> > > + fname6@p2(...);
> > > +)
> > > +
> > > +
> > > +@script:python depends on report@
> > > +p1 << r1.p1;
> > > +p2 << r1.p2;
> > > +@@
> > > +msg = "atomic_dec_and_test variation before object free at line %s."
> > > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > > +
> > > +@r4 exists@
> > > +identifier a, x, y;
> > > +position p1, p2;
> > > +identifier fname =~ ".*free.*";
> > > +
> > > +@@
> > > +
> > > +(
> > > + atomic_dec_and_test@p1(&(a)->x)
> > > +|
> > > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > > +|
> > > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > > +|
> > > + atomic_long_dec_and_test@p1(&(a)->x)
> > > +|
> > > + atomic64_dec_and_test@p1(&(a)->x)
> > > +|
> > > + local_dec_and_test@p1(&(a)->x)
> > > +)
> > > +...
> > > +y=a
> > > +...
> > > +fname@p2(y, ...);
> > > +
> > > +
> > > +@script:python depends on report@
> > > +p1 << r4.p1;
> > > +p2 << r4.p2;
> > > +@@
> > > +msg = "atomic_dec_and_test variation before object free at line %s."
> > > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > > +
> > > +@r2 exists@
> > > +identifier a, x;
> > > +position p1;
> > > +@@
> > > +
> > > +(
> > > +atomic_add_unless(&(a)->x,-1,1)@p1
> > > +|
> > > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > > +|
> > > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > > +)
> > > +
> > > +@script:python depends on report@
> > > +p1 << r2.p1;
> > > +@@
> > > +msg = "atomic_add_unless"
> > > +coccilib.report.print_report(p1[0], msg)
> > > +
> > > +@r3 exists@
> > > +identifier x;
> > > +position p1;
> > > +@@
> > > +
> > > +(
> > > +x = atomic_add_return@p1(-1, ...);
> > > +|
> > > +x = atomic_long_add_return@p1(-1, ...);
> > > +|
> > > +x = atomic64_add_return@p1(-1, ...);
> > > +)
> > > +
> > > +@script:python depends on report@
> > > +p1 << r3.p1;
> > > +@@
> > > +msg = "x = atomic_add_return(-1, ...)"
> > > +coccilib.report.print_report(p1[0], msg)
> > > +
> > > +
> > > --
> > > 2.7.4
> > >
> > >
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-30 12:26   ` Julia Lawall
@ 2017-08-30 12:44     ` Reshetova, Elena
  2017-08-30 13:06       ` Julia Lawall
  0 siblings, 1 reply; 58+ messages in thread
From: Reshetova, Elena @ 2017-08-30 12:44 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel


> 
> On Wed, 30 Aug 2017, Elena Reshetova wrote:
> 
> > atomic_as_refcounter.cocci script allows detecting
> > cases when refcount_t type and API should be used
> > instead of atomic_t.
> >
> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> 
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Thank you very much Julia! What is the correct path to merge this?
I will resend with your acked-by, but what is the tree that should merge it?

Best Regards,
Elena.
> 
> > ---
> >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131
> ++++++++++++++++++++++
> >  1 file changed, 131 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> >
> > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci
> b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > new file mode 100644
> > index 0000000..f83771b
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > @@ -0,0 +1,131 @@
> > +// Check if refcount_t type and API should be used
> > +// instead of atomic_t type when dealing with refcounters
> > +//
> > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > +//
> > +// Confidence: Moderate
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --include-headers --very-quiet
> > +
> > +virtual report
> > +
> > +@r1 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +(
> > + fname@p2(a, ...);
> > +|
> > + fname2@p2(...);
> > +|
> > + fname3@p2(...);
> > +|
> > + fname4@p2(...);
> > +|
> > + fname5@p2(...);
> > +|
> > + fname6@p2(...);
> > +)
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r1.p1;
> > +p2 << r1.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r4 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +y=a
> > +...
> > +fname@p2(y, ...);
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r4.p1;
> > +p2 << r4.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r2 exists@
> > +identifier a, x;
> > +position p1;
> > +@@
> > +
> > +(
> > +atomic_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r2.p1;
> > +@@
> > +msg = "atomic_add_unless"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +@r3 exists@
> > +identifier x;
> > +position p1;
> > +@@
> > +
> > +(
> > +x = atomic_add_return@p1(-1, ...);
> > +|
> > +x = atomic_long_add_return@p1(-1, ...);
> > +|
> > +x = atomic64_add_return@p1(-1, ...);
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r3.p1;
> > +@@
> > +msg = "x = atomic_add_return(-1, ...)"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +
> > --
> > 2.7.4
> >
> >

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-30  6:15 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
@ 2017-08-30 12:26   ` Julia Lawall
  2017-08-30 12:44     ` Reshetova, Elena
  0 siblings, 1 reply; 58+ messages in thread
From: Julia Lawall @ 2017-08-30 12:26 UTC (permalink / raw)
  To: Elena Reshetova
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel



On Wed, 30 Aug 2017, Elena Reshetova wrote:

> atomic_as_refcounter.cocci script allows detecting
> cases when refcount_t type and API should be used
> instead of atomic_t.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>

Acked-by: Julia Lawall <julia.lawall@lip6.fr>

> ---
>  scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
>  1 file changed, 131 insertions(+)
>  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
>
> diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> new file mode 100644
> index 0000000..f83771b
> --- /dev/null
> +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> @@ -0,0 +1,131 @@
> +// Check if refcount_t type and API should be used
> +// instead of atomic_t type when dealing with refcounters
> +//
> +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> +//
> +// Confidence: Moderate
> +// URL: http://coccinelle.lip6.fr/
> +// Options: --include-headers --very-quiet
> +
> +virtual report
> +
> +@r1 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +(
> + fname@p2(a, ...);
> +|
> + fname2@p2(...);
> +|
> + fname3@p2(...);
> +|
> + fname4@p2(...);
> +|
> + fname5@p2(...);
> +|
> + fname6@p2(...);
> +)
> +
> +
> +@script:python depends on report@
> +p1 << r1.p1;
> +p2 << r1.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r4 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +y=a
> +...
> +fname@p2(y, ...);
> +
> +
> +@script:python depends on report@
> +p1 << r4.p1;
> +p2 << r4.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r2 exists@
> +identifier a, x;
> +position p1;
> +@@
> +
> +(
> +atomic_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic_long_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic64_add_unless(&(a)->x,-1,1)@p1
> +)
> +
> +@script:python depends on report@
> +p1 << r2.p1;
> +@@
> +msg = "atomic_add_unless"
> +coccilib.report.print_report(p1[0], msg)
> +
> +@r3 exists@
> +identifier x;
> +position p1;
> +@@
> +
> +(
> +x = atomic_add_return@p1(-1, ...);
> +|
> +x = atomic_long_add_return@p1(-1, ...);
> +|
> +x = atomic64_add_return@p1(-1, ...);
> +)
> +
> +@script:python depends on report@
> +p1 << r3.p1;
> +@@
> +msg = "x = atomic_add_return(-1, ...)"
> +coccilib.report.print_report(p1[0], msg)
> +
> +
> --
> 2.7.4
>
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-30  6:15 [PATCH v4] provide rule for finding refcounters Elena Reshetova
@ 2017-08-30  6:15 ` Elena Reshetova
  2017-08-30 12:26   ` Julia Lawall
  0 siblings, 1 reply; 58+ messages in thread
From: Elena Reshetova @ 2017-08-30  6:15 UTC (permalink / raw)
  To: julia.lawall
  Cc: linux-kernel, cocci, Gilles.Muller, nicolas.palix, mmarek,
	keescook, ishkamiel, Elena Reshetova

atomic_as_refcounter.cocci script allows detecting
cases when refcount_t type and API should be used
instead of atomic_t.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 131 ++++++++++++++++++++++
 1 file changed, 131 insertions(+)
 create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
new file mode 100644
index 0000000..f83771b
--- /dev/null
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -0,0 +1,131 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+@r1 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+(
+ fname@p2(a, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r4 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+y=a
+...
+fname@p2(y, ...);
+
+
+@script:python depends on report@
+p1 << r4.p1;
+p2 << r4.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+@script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+@r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return@p1(-1, ...);
+|
+x = atomic_long_add_return@p1(-1, ...);
+|
+x = atomic64_add_return@p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)
+
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-17 11:50   ` Julia Lawall
@ 2017-08-29  9:01     ` Reshetova, Elena
  0 siblings, 0 replies; 58+ messages in thread
From: Reshetova, Elena @ 2017-08-29  9:01 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel


> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> 
> Personally, I find the above regular expressions much easier to understand
> than the merged version that Markus proposed.  

I really don't have a strong opinion on the presentation side. 
One is more compact, the above one perhaps a bit clearer for unexperienced reader (like myself). 
Sometimes when I try to read patterns from cocci folder,
it takes me really a while to understand what is happening, which is not the case
with simple expression above. I have just considered myself to be too new into this
and therefore sticked to simple expressions to make sure I am minimizing functional mistakes. 

But the performance issue is
> only on whether to use regular expressions or not.  If you use regular
> expressions, Coccinelle will not do some optimizations.  But once you
> decide to use regular expressions, the performance hit is already taken -
> for a good cause here, to my understanding.  

Ok, so then performance is not even a factor. Thank you for the explanation! 

So just put whatever you find
> convenient, in terms of readability, precision, etc.  It seems that del is
> not very precise, because it is a substring of multiple words with
> different meanings.  Maybe it should be improved, or maybe one can just
> live with the false positives (eg delay), if they actually are false
> positives.

This is the problem that some of them might be and some not. 
I can call the queuing works explicitly:
identifier fname4 =~ ".*queue_work.*";
identifier fname5 =~ ".*queue_delayed_work.*";

Then there is no need to match "delay", but I still like to match both "delete" and "del". 

Best Regards,
Elena.
> 
> julia

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-16 11:52 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
@ 2017-08-17 11:50   ` Julia Lawall
  2017-08-29  9:01     ` Reshetova, Elena
  0 siblings, 1 reply; 58+ messages in thread
From: Julia Lawall @ 2017-08-17 11:50 UTC (permalink / raw)
  To: Elena Reshetova
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel

> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";

Personally, I find the above regular expressions much easier to understand
than the merged version that Markus proposed.  But the performance issue is
only on whether to use regular expressions or not.  If you use regular
expressions, Coccinelle will not do some optimizations.  But once you
decide to use regular expressions, the performance hit is already taken -
for a good cause here, to my understanding.  So just put whatever you find
convenient, in terms of readability, precision, etc.  It seems that del is
not very precise, because it is a substring of multiple words with
different meanings.  Maybe it should be improved, or maybe one can just
live with the false positives (eg delay), if they actually are false
positives.

julia

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-16 11:52 [PATCH v3] provide rule for finding refcounters Elena Reshetova
@ 2017-08-16 11:52 ` Elena Reshetova
  2017-08-17 11:50   ` Julia Lawall
  0 siblings, 1 reply; 58+ messages in thread
From: Elena Reshetova @ 2017-08-16 11:52 UTC (permalink / raw)
  To: julia.lawall
  Cc: linux-kernel, cocci, Gilles.Muller, nicolas.palix, mmarek,
	keescook, ishkamiel, Elena Reshetova

atomic_as_refcounter.cocci script allows detecting
cases when refcount_t type and API should be used
instead of atomic_t.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 133 ++++++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
new file mode 100644
index 0000000..64c97d1
--- /dev/null
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -0,0 +1,133 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+@r1 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+(
+ fname@p2(a, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r4 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+y=a
+...
+(
+ fname@p2(y, ...);
+)
+
+
+@script:python depends on report@
+p1 << r4.p1;
+p2 << r4.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+@script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+@r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return@p1(-1, ...);
+|
+x = atomic_long_add_return@p1(-1, ...);
+|
+x = atomic64_add_return@p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)
+
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-14 14:16   ` Julia Lawall
@ 2017-08-15 12:19     ` Reshetova, Elena
  0 siblings, 0 replies; 58+ messages in thread
From: Reshetova, Elena @ 2017-08-15 12:19 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel

> On Mon, 14 Aug 2017, Elena Reshetova wrote:
> 
> > atomic_as_refcounter.cocci script allows detecting
> > cases when refcount_t type and API should be used
> > instead of atomic_t.
> >
> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> > ---
> >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 148
> ++++++++++++++++++++++
> >  1 file changed, 148 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> >
> > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci
> b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > new file mode 100644
> > index 0000000..996d72b
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > @@ -0,0 +1,148 @@
> > +// Check if refcount_t type and API should be used
> > +// instead of atomic_t type when dealing with refcounters
> > +//
> > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > +//
> > +// Confidence: Moderate
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --include-headers --very-quiet
> > +
> > +virtual report
> > +
> > +@r1 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +(
> > + fname@p2(a, ...);
> > +|
> > + fname2@p2(...);
> > +|
> > + fname3@p2(...);
> > +|
> > + fname4@p2(...);
> > +|
> > + fname5@p2(...);
> > +|
> > + fname6@p2(...);
> > +)
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r1.p1;
> > +p2 << r1.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r4 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +y=a
> > +...
> > +(
> > + fname@p2(y, ...);
> > +|
> > + fname2@p2(...);
> 
> From here to the end of the rule there is no a or y.  So they would match
> the same thing as in the previous rule.  so you could get rid of all of
> these cases, and just leave fname@p2(y, ...);

True, stupid of me :(
Will fix. 

Best Regards,
Elena.

> 
> julia
> 
> > +|
> > + fname3@p2(...);
> > +|
> > + fname4@p2(...);
> > +|
> > + fname5@p2(...);
> > +|
> > + fname6@p2(...);
> > +)
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r4.p1;
> > +p2 << r4.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r2 exists@
> > +identifier a, x;
> > +position p1;
> > +@@
> > +
> > +(
> > +atomic_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r2.p1;
> > +@@
> > +msg = "atomic_add_unless"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +@r3 exists@
> > +identifier x;
> > +position p1;
> > +@@
> > +
> > +(
> > +x = atomic_add_return@p1(-1, ...);
> > +|
> > +x = atomic_long_add_return@p1(-1, ...);
> > +|
> > +x = atomic64_add_return@p1(-1, ...);
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r3.p1;
> > +@@
> > +msg = "x = atomic_add_return(-1, ...)"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +
> > --
> > 2.7.4
> >
> >

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-14  5:59 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
@ 2017-08-14 14:16   ` Julia Lawall
  2017-08-15 12:19     ` Reshetova, Elena
  0 siblings, 1 reply; 58+ messages in thread
From: Julia Lawall @ 2017-08-14 14:16 UTC (permalink / raw)
  To: Elena Reshetova
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel



On Mon, 14 Aug 2017, Elena Reshetova wrote:

> atomic_as_refcounter.cocci script allows detecting
> cases when refcount_t type and API should be used
> instead of atomic_t.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> ---
>  scripts/coccinelle/api/atomic_as_refcounter.cocci | 148 ++++++++++++++++++++++
>  1 file changed, 148 insertions(+)
>  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
>
> diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> new file mode 100644
> index 0000000..996d72b
> --- /dev/null
> +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> @@ -0,0 +1,148 @@
> +// Check if refcount_t type and API should be used
> +// instead of atomic_t type when dealing with refcounters
> +//
> +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> +//
> +// Confidence: Moderate
> +// URL: http://coccinelle.lip6.fr/
> +// Options: --include-headers --very-quiet
> +
> +virtual report
> +
> +@r1 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +(
> + fname@p2(a, ...);
> +|
> + fname2@p2(...);
> +|
> + fname3@p2(...);
> +|
> + fname4@p2(...);
> +|
> + fname5@p2(...);
> +|
> + fname6@p2(...);
> +)
> +
> +
> +@script:python depends on report@
> +p1 << r1.p1;
> +p2 << r1.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r4 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +y=a
> +...
> +(
> + fname@p2(y, ...);
> +|
> + fname2@p2(...);

>From here to the end of the rule there is no a or y.  So they would match
the same thing as in the previous rule.  so you could get rid of all of
these cases, and just leave fname@p2(y, ...);

julia

> +|
> + fname3@p2(...);
> +|
> + fname4@p2(...);
> +|
> + fname5@p2(...);
> +|
> + fname6@p2(...);
> +)
> +
> +
> +@script:python depends on report@
> +p1 << r4.p1;
> +p2 << r4.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r2 exists@
> +identifier a, x;
> +position p1;
> +@@
> +
> +(
> +atomic_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic_long_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic64_add_unless(&(a)->x,-1,1)@p1
> +)
> +
> +@script:python depends on report@
> +p1 << r2.p1;
> +@@
> +msg = "atomic_add_unless"
> +coccilib.report.print_report(p1[0], msg)
> +
> +@r3 exists@
> +identifier x;
> +position p1;
> +@@
> +
> +(
> +x = atomic_add_return@p1(-1, ...);
> +|
> +x = atomic_long_add_return@p1(-1, ...);
> +|
> +x = atomic64_add_return@p1(-1, ...);
> +)
> +
> +@script:python depends on report@
> +p1 << r3.p1;
> +@@
> +msg = "x = atomic_add_return(-1, ...)"
> +coccilib.report.print_report(p1[0], msg)
> +
> +
> --
> 2.7.4
>
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-14  5:59 [PATCH v2] coccinelle: provide rule for finding refcounters Elena Reshetova
@ 2017-08-14  5:59 ` Elena Reshetova
  2017-08-14 14:16   ` Julia Lawall
  0 siblings, 1 reply; 58+ messages in thread
From: Elena Reshetova @ 2017-08-14  5:59 UTC (permalink / raw)
  To: julia.lawall
  Cc: linux-kernel, cocci, Gilles.Muller, nicolas.palix, mmarek,
	keescook, ishkamiel, Elena Reshetova

atomic_as_refcounter.cocci script allows detecting
cases when refcount_t type and API should be used
instead of atomic_t.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 148 ++++++++++++++++++++++
 1 file changed, 148 insertions(+)
 create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
new file mode 100644
index 0000000..996d72b
--- /dev/null
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -0,0 +1,148 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+@r1 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+(
+ fname@p2(a, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r4 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+y=a
+...
+(
+ fname@p2(y, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r4.p1;
+p2 << r4.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+@script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+@r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return@p1(-1, ...);
+|
+x = atomic_long_add_return@p1(-1, ...);
+|
+x = atomic64_add_return@p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)
+
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-08-04 15:23   ` Julia Lawall
@ 2017-08-07 11:06     ` Reshetova, Elena
  0 siblings, 0 replies; 58+ messages in thread
From: Reshetova, Elena @ 2017-08-07 11:06 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel

> On Tue, 18 Jul 2017, Elena Reshetova wrote:
> 
> > atomic_as_refcounter.cocci script allows detecting
> > cases when refcount_t type and API should be used
> > instead of atomic_t.
> >
> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> > ---
> >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 102
> ++++++++++++++++++++++
> >  1 file changed, 102 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> >
> > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci
> b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > new file mode 100644
> > index 0000000..a16d395
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > @@ -0,0 +1,102 @@
> > +// Check if refcount_t type and API should be used
> > +// instead of atomic_t type when dealing with refcounters
> > +//
> > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > +//
> > +// Confidence: Moderate
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --include-headers --very-quiet
> > +
> > +virtual report
> > +
> > +@r1 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> > +|
> > + atomic_long_dec_and_test@p1(&(a)->x)
> > +|
> > + atomic64_dec_and_test@p1(&(a)->x)
> > +|
> > + local_dec_and_test@p1(&(a)->x)
> > +)
> > +...
> > +?y=a
> 
> This makes the line optional. And if it dosn't appear, there is no
> constraint on y.  So the rule matches:
> 
> int main() {
>   atomic64_dec_and_test(&(a)->x);
>   free(b);
> }
> 
> I would suggest to just make two rules, one with y=a and one without.

Oh, thank you for the catch! I was a bit afraid it might be the case, but when
I tried it in practice it didn't show up that many additional cases compare to
not having ?y=a at all (only 20 or so), and when I checked some, they looked
worth a manual check anyway and interesting. 

But I will fix the rule and send a new version!

Best Regards,
Elena.

> 
> julia
> 
> > +...
> > +(
> > + fname@p2(a, ...);
> > +|
> > + fname@p2(y, ...);
> > +|
> > + fname2@p2(...);
> > +|
> > + fname3@p2(...);
> > +|
> > + fname4@p2(...);
> > +|
> > + fname5@p2(...);
> > +|
> > + fname6@p2(...);
> > +)
> > +
> > +
> > +@script:python depends on report@
> > +p1 << r1.p1;
> > +p2 << r1.p2;
> > +@@
> > +msg = "atomic_dec_and_test variation before object free at line %s."
> > +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> > +
> > +@r2 exists@
> > +identifier a, x;
> > +position p1;
> > +@@
> > +
> > +(
> > +atomic_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic_long_add_unless(&(a)->x,-1,1)@p1
> > +|
> > +atomic64_add_unless(&(a)->x,-1,1)@p1
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r2.p1;
> > +@@
> > +msg = "atomic_add_unless"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +@r3 exists@
> > +identifier x;
> > +position p1;
> > +@@
> > +
> > +(
> > +x = atomic_add_return@p1(-1, ...);
> > +|
> > +x = atomic_long_add_return@p1(-1, ...);
> > +|
> > +x = atomic64_add_return@p1(-1, ...);
> > +)
> > +
> > +@script:python depends on report@
> > +p1 << r3.p1;
> > +@@
> > +msg = "x = atomic_add_return(-1, ...)"
> > +coccilib.report.print_report(p1[0], msg)
> > +
> > +
> > --
> > 2.7.4
> >
> >

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-07-18  7:48 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
  2017-07-18 16:21   ` Kees Cook
@ 2017-08-04 15:23   ` Julia Lawall
  2017-08-07 11:06     ` Reshetova, Elena
  1 sibling, 1 reply; 58+ messages in thread
From: Julia Lawall @ 2017-08-04 15:23 UTC (permalink / raw)
  To: Elena Reshetova
  Cc: linux-kernel, cocci, Gilles Muller, nicolas.palix, mmarek,
	keescook, ishkamiel



On Tue, 18 Jul 2017, Elena Reshetova wrote:

> atomic_as_refcounter.cocci script allows detecting
> cases when refcount_t type and API should be used
> instead of atomic_t.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> ---
>  scripts/coccinelle/api/atomic_as_refcounter.cocci | 102 ++++++++++++++++++++++
>  1 file changed, 102 insertions(+)
>  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
>
> diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> new file mode 100644
> index 0000000..a16d395
> --- /dev/null
> +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> @@ -0,0 +1,102 @@
> +// Check if refcount_t type and API should be used
> +// instead of atomic_t type when dealing with refcounters
> +//
> +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> +//
> +// Confidence: Moderate
> +// URL: http://coccinelle.lip6.fr/
> +// Options: --include-headers --very-quiet
> +
> +virtual report
> +
> +@r1 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> +|
> + atomic_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_lock@p1(&(a)->x, ...)
> +|
> + atomic_long_dec_and_test@p1(&(a)->x)
> +|
> + atomic64_dec_and_test@p1(&(a)->x)
> +|
> + local_dec_and_test@p1(&(a)->x)
> +)
> +...
> +?y=a

This makes the line optional. And if it dosn't appear, there is no
constraint on y.  So the rule matches:

int main() {
  atomic64_dec_and_test(&(a)->x);
  free(b);
}

I would suggest to just make two rules, one with y=a and one without.

julia

> +...
> +(
> + fname@p2(a, ...);
> +|
> + fname@p2(y, ...);
> +|
> + fname2@p2(...);
> +|
> + fname3@p2(...);
> +|
> + fname4@p2(...);
> +|
> + fname5@p2(...);
> +|
> + fname6@p2(...);
> +)
> +
> +
> +@script:python depends on report@
> +p1 << r1.p1;
> +p2 << r1.p2;
> +@@
> +msg = "atomic_dec_and_test variation before object free at line %s."
> +coccilib.report.print_report(p1[0], msg % (p2[0].line))
> +
> +@r2 exists@
> +identifier a, x;
> +position p1;
> +@@
> +
> +(
> +atomic_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic_long_add_unless(&(a)->x,-1,1)@p1
> +|
> +atomic64_add_unless(&(a)->x,-1,1)@p1
> +)
> +
> +@script:python depends on report@
> +p1 << r2.p1;
> +@@
> +msg = "atomic_add_unless"
> +coccilib.report.print_report(p1[0], msg)
> +
> +@r3 exists@
> +identifier x;
> +position p1;
> +@@
> +
> +(
> +x = atomic_add_return@p1(-1, ...);
> +|
> +x = atomic_long_add_return@p1(-1, ...);
> +|
> +x = atomic64_add_return@p1(-1, ...);
> +)
> +
> +@script:python depends on report@
> +p1 << r3.p1;
> +@@
> +msg = "x = atomic_add_return(-1, ...)"
> +coccilib.report.print_report(p1[0], msg)
> +
> +
> --
> 2.7.4
>
>

^ permalink raw reply	[flat|nested] 58+ messages in thread

* RE: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-07-18 16:21   ` Kees Cook
@ 2017-07-19 10:54     ` Reshetova, Elena
  0 siblings, 0 replies; 58+ messages in thread
From: Reshetova, Elena @ 2017-07-19 10:54 UTC (permalink / raw)
  To: Kees Cook
  Cc: Julia Lawall, LKML, cocci, Gilles Muller, Nicolas Palix,
	Michal Marek, Hans Liljestrand

 On Tue, Jul 18, 2017 at 12:48 AM, Elena Reshetova
> <elena.reshetova@intel.com> wrote:
> > atomic_as_refcounter.cocci script allows detecting
> > cases when refcount_t type and API should be used
> > instead of atomic_t.
> >
> > Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> > ---
> >  scripts/coccinelle/api/atomic_as_refcounter.cocci | 102
> ++++++++++++++++++++++
> >  1 file changed, 102 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
> >
> > diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci
> b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > new file mode 100644
> > index 0000000..a16d395
> > --- /dev/null
> > +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> > @@ -0,0 +1,102 @@
> > +// Check if refcount_t type and API should be used
> > +// instead of atomic_t type when dealing with refcounters
> > +//
> > +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> > +//
> > +// Confidence: Moderate
> > +// URL: http://coccinelle.lip6.fr/
> > +// Options: --include-headers --very-quiet
> > +
> > +virtual report
> > +
> > +@r1 exists@
> > +identifier a, x, y;
> > +position p1, p2;
> > +identifier fname =~ ".*free.*";
> > +identifier fname2 =~ ".*destroy.*";
> > +identifier fname3 =~ ".*del.*";
> > +identifier fname4 =~ ".*queue_work.*";
> > +identifier fname5 =~ ".*schedule_work.*";
> > +identifier fname6 =~ ".*call_rcu.*";
> > +
> > +@@
> > +
> > +(
> > + atomic_dec_and_test@p1(&(a)->x)
> > [...]
> > +)
> > +...
> > +?y=a
> > +...
> > +(
> > + fname@p2(a, ...);
> > +|
> > + fname@p2(y, ...);
> > +|
> > [...]
> 
> Just to double check, this "?y=a" catches the seccomp case I pointed out?
> 
>         while (orig && atomic_dec_and_test(&orig->usage)) {
>                 struct seccomp_filter *freeme = orig;
>                 orig = orig->prev;
>                 seccomp_filter_free(freeme);
>         }
> 

Yes, it does find the seccomp case, I was specifically testing this new addition on it. 


> Seems like it should match. Did this find anything else besides seccomp?

Yes, it found about 20 new things, but I haven't had a chance to look at them all yet.
In any case, I would really love to merge the existing conversions first (we still have about 80 patches left)
and only after add more of them. I looked at some new found cases and for example this was one:

./crypto/cryptd.c:474:38-57: atomic_dec_and_test variation before object free at line 475.

static void cryptd_skcipher_complete(struct skcipher_request *req, int err)
{
    struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
    struct cryptd_skcipher_ctx *ctx = crypto_skcipher_ctx(tfm);
    struct cryptd_skcipher_request_ctx *rctx = skcipher_request_ctx(req);
    int refcnt = atomic_read(&ctx->refcnt);

    local_bh_disable();
    rctx->complete(&req->base, err);
    local_bh_enable();

    if (err != -EINPROGRESS && refcnt && atomic_dec_and_test(&ctx->refcnt))
        crypto_free_skcipher(tfm);
}

While it isn't exactly the case I had in mind when trying to modify the pattern to work
for seccomp case, it came as a nice bonus IMO since we do want to catch these cases as well.
Overall it seems that pointers/structures can be so nicely wrapped around in some cases,
that keeping the pattern as generic as possible is a good way to go. Otherwise we might
start losing cases ( I would prefer a bit more false positives in this case instead as soon as
they are fine to manage). 

Best Regards,
Elena.

> 
> -Kees
> 
> --
> Kees Cook
> Pixel Security

^ permalink raw reply	[flat|nested] 58+ messages in thread

* Re: [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-07-18  7:48 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
@ 2017-07-18 16:21   ` Kees Cook
  2017-07-19 10:54     ` Reshetova, Elena
  2017-08-04 15:23   ` Julia Lawall
  1 sibling, 1 reply; 58+ messages in thread
From: Kees Cook @ 2017-07-18 16:21 UTC (permalink / raw)
  To: Elena Reshetova
  Cc: Julia Lawall, LKML, cocci, Gilles Muller, Nicolas Palix,
	Michal Marek, Hans Liljestrand

On Tue, Jul 18, 2017 at 12:48 AM, Elena Reshetova
<elena.reshetova@intel.com> wrote:
> atomic_as_refcounter.cocci script allows detecting
> cases when refcount_t type and API should be used
> instead of atomic_t.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> ---
>  scripts/coccinelle/api/atomic_as_refcounter.cocci | 102 ++++++++++++++++++++++
>  1 file changed, 102 insertions(+)
>  create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci
>
> diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> new file mode 100644
> index 0000000..a16d395
> --- /dev/null
> +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
> @@ -0,0 +1,102 @@
> +// Check if refcount_t type and API should be used
> +// instead of atomic_t type when dealing with refcounters
> +//
> +// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
> +//
> +// Confidence: Moderate
> +// URL: http://coccinelle.lip6.fr/
> +// Options: --include-headers --very-quiet
> +
> +virtual report
> +
> +@r1 exists@
> +identifier a, x, y;
> +position p1, p2;
> +identifier fname =~ ".*free.*";
> +identifier fname2 =~ ".*destroy.*";
> +identifier fname3 =~ ".*del.*";
> +identifier fname4 =~ ".*queue_work.*";
> +identifier fname5 =~ ".*schedule_work.*";
> +identifier fname6 =~ ".*call_rcu.*";
> +
> +@@
> +
> +(
> + atomic_dec_and_test@p1(&(a)->x)
> [...]
> +)
> +...
> +?y=a
> +...
> +(
> + fname@p2(a, ...);
> +|
> + fname@p2(y, ...);
> +|
> [...]

Just to double check, this "?y=a" catches the seccomp case I pointed out?

        while (orig && atomic_dec_and_test(&orig->usage)) {
                struct seccomp_filter *freeme = orig;
                orig = orig->prev;
                seccomp_filter_free(freeme);
        }

Seems like it should match. Did this find anything else besides seccomp?

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 58+ messages in thread

* [PATCH] Coccinelle: add atomic_as_refcounter script
  2017-07-18  7:48 [PATCH] Coccinelle report script for refcounters Elena Reshetova
@ 2017-07-18  7:48 ` Elena Reshetova
  2017-07-18 16:21   ` Kees Cook
  2017-08-04 15:23   ` Julia Lawall
  0 siblings, 2 replies; 58+ messages in thread
From: Elena Reshetova @ 2017-07-18  7:48 UTC (permalink / raw)
  To: julia.lawall
  Cc: linux-kernel, cocci, Gilles.Muller, nicolas.palix, mmarek,
	keescook, ishkamiel, Elena Reshetova

atomic_as_refcounter.cocci script allows detecting
cases when refcount_t type and API should be used
instead of atomic_t.

Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 102 ++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 scripts/coccinelle/api/atomic_as_refcounter.cocci

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
new file mode 100644
index 0000000..a16d395
--- /dev/null
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -0,0 +1,102 @@
+// Check if refcount_t type and API should be used
+// instead of atomic_t type when dealing with refcounters
+//
+// Copyright (c) 2016-2017, Elena Reshetova, Intel Corporation
+//
+// Confidence: Moderate
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers --very-quiet
+
+virtual report
+
+@r1 exists@
+identifier a, x, y;
+position p1, p2;
+identifier fname =~ ".*free.*";
+identifier fname2 =~ ".*destroy.*";
+identifier fname3 =~ ".*del.*";
+identifier fname4 =~ ".*queue_work.*";
+identifier fname5 =~ ".*schedule_work.*";
+identifier fname6 =~ ".*call_rcu.*";
+
+@@
+
+(
+ atomic_dec_and_test@p1(&(a)->x)
+|
+ atomic_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_lock@p1(&(a)->x, ...)
+|
+ atomic_long_dec_and_test@p1(&(a)->x)
+|
+ atomic64_dec_and_test@p1(&(a)->x)
+|
+ local_dec_and_test@p1(&(a)->x)
+)
+...
+?y=a
+...
+(
+ fname@p2(a, ...);
+|
+ fname@p2(y, ...);
+|
+ fname2@p2(...);
+|
+ fname3@p2(...);
+|
+ fname4@p2(...);
+|
+ fname5@p2(...);
+|
+ fname6@p2(...);
+)
+
+
+@script:python depends on report@
+p1 << r1.p1;
+p2 << r1.p2;
+@@
+msg = "atomic_dec_and_test variation before object free at line %s."
+coccilib.report.print_report(p1[0], msg % (p2[0].line))
+
+@r2 exists@
+identifier a, x;
+position p1;
+@@
+
+(
+atomic_add_unless(&(a)->x,-1,1)@p1
+|
+atomic_long_add_unless(&(a)->x,-1,1)@p1
+|
+atomic64_add_unless(&(a)->x,-1,1)@p1
+)
+
+@script:python depends on report@
+p1 << r2.p1;
+@@
+msg = "atomic_add_unless"
+coccilib.report.print_report(p1[0], msg)
+
+@r3 exists@
+identifier x;
+position p1;
+@@
+
+(
+x = atomic_add_return@p1(-1, ...);
+|
+x = atomic_long_add_return@p1(-1, ...);
+|
+x = atomic64_add_return@p1(-1, ...);
+)
+
+@script:python depends on report@
+p1 << r3.p1;
+@@
+msg = "x = atomic_add_return(-1, ...)"
+coccilib.report.print_report(p1[0], msg)
+
+
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2018-08-01 12:30 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01  9:40 [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
2017-09-01  9:40 ` [Cocci] " Elena Reshetova
2018-06-14 23:58 ` Kees Cook
2018-06-14 23:58   ` [Cocci] " Kees Cook
2018-06-15  5:06   ` Julia Lawall
2018-06-15  5:06     ` [Cocci] " Julia Lawall
2018-06-18 13:47     ` Masahiro Yamada
2018-06-18 13:47       ` [Cocci] " Masahiro Yamada
2018-07-03  7:30       ` [PATCH 0/6] Coccinelle: atomic_as_refcounter: Improvements for source code search specifications SF Markus Elfring
2018-07-03  7:30         ` SF Markus Elfring
2018-07-03  7:35         ` [PATCH 1/6] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from two SmPL constraints SF Markus Elfring
2018-07-03  7:35           ` [PATCH 1/6] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from two SmPL constrai SF Markus Elfring
2018-07-03  7:37         ` [PATCH 2/6] Coccinelle: atomic_as_refcounter: Optimise a disjunction in the first SmPL rule SF Markus Elfring
2018-07-03  7:37           ` SF Markus Elfring
2018-07-03  7:40         ` [PATCH 3/6] Coccinelle: atomic_as_refcounter: Use type “expression” for another metavariable SF Markus Elfring
2018-07-03  7:40           ` [PATCH 3/6] Coccinelle: atomic_as_refcounter: Use typ =?UTF-8?Q?e_=e2=80=9cexpressio SF Markus Elfring
2018-07-03  7:42         ` [PATCH 4/6] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rules SF Markus Elfring
2018-07-03  7:42           ` SF Markus Elfring
2018-07-03  7:45         ` [PATCH 5/6] Coccinelle: atomic_as_refcounter: Use nested disjunctions " SF Markus Elfring
2018-07-03  7:45           ` SF Markus Elfring
2018-07-03  7:48         ` [PATCH 6/6] Coccinelle: atomic_as_refcounter: Use format strings directly in " SF Markus Elfring
2018-07-03  7:48           ` SF Markus Elfring
2018-08-01 12:30           ` [PATCH] Coccinelle: atomic_as_refcounter: Merge two " SF Markus Elfring
2018-08-01 12:30             ` SF Markus Elfring
2018-07-16 17:21         ` [PATCH v2 0/8] Coccinelle: atomic_as_refcounter: Adjustments for source code search specifications SF Markus Elfring
2018-07-16 17:21           ` SF Markus Elfring
2018-07-16 17:24           ` [PATCH v2 1/8] Coccinelle: atomic_as_refcounter: Delete an unnecessary SmPL rule SF Markus Elfring
2018-07-16 17:24             ` SF Markus Elfring
2018-07-16 17:26           ` [PATCH v2 2/8] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from a SmPL constraint SF Markus Elfring
2018-07-16 17:26             ` [PATCH v2 2/8] Coccinelle: atomic_as_refcounter: Omit placeholder specifications from a SmPL constra SF Markus Elfring
2018-07-16 17:28           ` [PATCH v2 3/8] Coccinelle: atomic_as_refcounter: Optimise a disjunction in the first SmPL rule SF Markus Elfring
2018-07-16 17:28             ` SF Markus Elfring
2018-07-16 17:30           ` [PATCH v2 4/8] Coccinelle: atomic_as_refcounter: Use type “expression” for another metavariable SF Markus Elfring
2018-07-16 17:30             ` [PATCH v2 4/8] Coccinelle: atomic_as_refcounter: Use =?UTF-8?Q?type_=e2=80=9cexpres SF Markus Elfring
2018-07-16 17:32           ` [PATCH v2 5/8] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rules SF Markus Elfring
2018-07-16 17:32             ` [PATCH v2 5/8] Coccinelle: atomic_as_refcounter: Replace disjunction by a constraint in two SmPL rul SF Markus Elfring
2018-07-16 17:34           ` [PATCH v2 6/8] Coccinelle: atomic_as_refcounter: Use nested disjunctions in the first SmPL rule SF Markus Elfring
2018-07-16 17:34             ` SF Markus Elfring
2018-07-16 17:36           ` [PATCH v2 7/8] Coccinelle: atomic_as_refcounter: Use string literals directly in two SmPL rules SF Markus Elfring
2018-07-16 17:36             ` SF Markus Elfring
2018-07-16 17:39           ` [PATCH v2 8/8] Coccinelle: atomic_as_refcounter: Use format string directly in the first SmPL rule SF Markus Elfring
2018-07-16 17:39             ` SF Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2017-08-30  6:15 [PATCH v4] provide rule for finding refcounters Elena Reshetova
2017-08-30  6:15 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
2017-08-30 12:26   ` Julia Lawall
2017-08-30 12:44     ` Reshetova, Elena
2017-08-30 13:06       ` Julia Lawall
2017-08-31  9:46         ` Reshetova, Elena
2017-08-16 11:52 [PATCH v3] provide rule for finding refcounters Elena Reshetova
2017-08-16 11:52 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
2017-08-17 11:50   ` Julia Lawall
2017-08-29  9:01     ` Reshetova, Elena
2017-08-14  5:59 [PATCH v2] coccinelle: provide rule for finding refcounters Elena Reshetova
2017-08-14  5:59 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
2017-08-14 14:16   ` Julia Lawall
2017-08-15 12:19     ` Reshetova, Elena
2017-07-18  7:48 [PATCH] Coccinelle report script for refcounters Elena Reshetova
2017-07-18  7:48 ` [PATCH] Coccinelle: add atomic_as_refcounter script Elena Reshetova
2017-07-18 16:21   ` Kees Cook
2017-07-19 10:54     ` Reshetova, Elena
2017-08-04 15:23   ` Julia Lawall
2017-08-07 11:06     ` Reshetova, Elena

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.