Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses

2019-05-13 Thread Markus Elfring
>> A SmPL ellipsis was specified for a search approach so that additional
>> source code would be tolerated between an assignment to a local variable
>> and the corresponding null pointer check.
>>
>> But such code should be restricted.
>> * The local variable must not be reassigned there.
>> * It must also not be forwarded to an other assignment target.
>>
>> Take additional casts for these code exclusion specifications into account
>> together with optional parentheses.
>
> NACK.

Can you agree to any information which I presented in the commit message?


> You don't need so many type metavariables.

It seems that the Coccinelle software can cope also with my SmPL code addition.
You might feel uncomfortable with the suggested changes for a while.


> Type metavariables in the same ... can be the same.

Such information is good to know for the proper usage of specifications
after a SmPL ellipsis.

* Can it become required to identify involved source code placeholders
  by extra metavariables?

* Would you like to clarify the probability any more how often the shown
  type casts will be identical?

Regards,
Markus
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one

2019-05-13 Thread Markus Elfring
>> I try to stress SmPL functionality in this use case.
>
> That's not the goal of the semantic patches in the kernel.
>
> The rule is fine as it is.

I am curious under which circumstances other software aspects
can become more relevant (as suggested).

Regards,
Markus


Re: [5/5] Coccinelle: put_device: Merge two SmPL when constraints into one

2019-05-13 Thread Markus Elfring
>> Combine the exclusion specifications into a disjunction for the semantic
>> patch language so that this argument is referenced only once there.
…
> NACK.  This hurts readability

I suggest to reconsider such readability concerns once more.
Can corresponding software limitations be adjusted any further?


> and gives no practical benefit.

I guess that you know better which aspects can matter also here
for software fine-tuning.


>> +++ b/scripts/coccinelle/free/put_device.cocci
>> @@ -22,8 +22,7 @@ id = of_find_device_by_node@p1(x)
>>  if (id == NULL || ...) { ... return ...; }
>>  ... when != put_device(>dev)
>>  when != id = (T6)(e)
>> -when != platform_device_put(id)
>> -when != of_dev_put(id)
>> +when != \( platform_device_put \| of_dev_put \) (id)

Can the reduction of a bit of duplicate SmPL code result in nicer
run time characteristics?

Regards,
Markus


Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses

2019-05-13 Thread Markus Elfring
>> Take additional casts for these code exclusion specifications into account
>> together with optional parentheses.
>
> NACK.

I find this rejection surprising.


> You don't need so many type metavariables.

I got an other software development opinion for this aspect.

Yesterday we started to clarify consequences from the isomorphism specification
“drop_cast” (for SmPL code).
https://github.com/coccinelle/coccinelle/blob/32d3b89ad909316464344a5f61a8092d8d702321/standard.iso#L52

Information like the following influenced my design decision to add three
metavariables here.

elfring@Sonne:~/Projekte/Linux/next-patched> spatch --parse-cocci 
scripts/coccinelle/free/put_device.cocci
…
warning: iso drop_cast does not match the code below on line -1
T (T )id

pure metavariable T is matched against the following nonpure code:
T
…


> Type metavariables in the same ... can be the same.

I would find it also occasionally nice when multiple SmPL ellipses
can refer to identical type casts.

* The under-documented “type purity” hinders this at the moment.

* But I got the impression that it can be safer to distinguish these
  code variants better.

Regards,
Markus
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> >> An assignment target was repeated in four SmPL when constraints.
> >> Combine the exclusion specifications into disjunctions for the semantic
> >> patch language so that this target is referenced only once there.
> >
> > NACK.
>
> I find this rejection questionable.
>
>
> > This exceeds 80 characters
>
> The line became 105 characters long.
> 14 space characters can eventually be omitted.
>
>
> > and provides no readability benefit.
>
> I try to stress SmPL functionality in this use case.

That's not the goal of the semantic patches in the kernel.

The rule is fine as it is.

> >> +++ b/scripts/coccinelle/free/put_device.cocci
> >> @@ -23,10 +23,7 @@ if (id == NULL || ...) { ... return ...; }
> >>  when != platform_device_put(id)
> >>  when != of_dev_put(id)
> >>  when != if (id) { ... put_device(>dev) ... }
> >> -when != e1 = (T)id
> >> -when != e1 = (T)(>dev)
> >> -when != e1 = get_device(>dev)
> >> -when != e1 = (T1)platform_get_drvdata(id)
> >> +when != e1 = \( (T) \( id \| (>dev) \) \| get_device(>dev) \| 
> >> (T1)platform_get_drvdata(id) \)
>
> How do you think about to extend the Coccinelle software in the way
> that such a detailed constraint can be specified on separate lines
> (without duplicated SmPL code)?

This causes some ambiguities in the parser.  No change is likely to occur
here.

julia

>
> How long will it take to reconsider corresponding software limitations?
>
> Regards,
> Markus
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one

2019-05-13 Thread Markus Elfring
>> An assignment target was repeated in four SmPL when constraints.
>> Combine the exclusion specifications into disjunctions for the semantic
>> patch language so that this target is referenced only once there.
>
> NACK.

I find this rejection questionable.


> This exceeds 80 characters

The line became 105 characters long.
14 space characters can eventually be omitted.


> and provides no readability benefit.

I try to stress SmPL functionality in this use case.


>> +++ b/scripts/coccinelle/free/put_device.cocci
>> @@ -23,10 +23,7 @@ if (id == NULL || ...) { ... return ...; }
>>  when != platform_device_put(id)
>>  when != of_dev_put(id)
>>  when != if (id) { ... put_device(>dev) ... }
>> -when != e1 = (T)id
>> -when != e1 = (T)(>dev)
>> -when != e1 = get_device(>dev)
>> -when != e1 = (T1)platform_get_drvdata(id)
>> +when != e1 = \( (T) \( id \| (>dev) \) \| get_device(>dev) \| 
>> (T1)platform_get_drvdata(id) \)

How do you think about to extend the Coccinelle software in the way
that such a detailed constraint can be specified on separate lines
(without duplicated SmPL code)?

How long will it take to reconsider corresponding software limitations?

Regards,
Markus
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [1/5] Coccinelle: put_device: Adjust a message construction

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> >> Thus simplify a message construction in a SmPL rule by concatenating text
> >> with two plus operators less.
> >
> > Is there any way to unindent, so that the string doesn't exceed 80 
> > characters,
> > or at least no so much?
>
> How does your concern fit to the string literal tolerance from
> the Linux coding style?

The point of view of the Linux kernel is that if there is no nicer way to
persent the string, exceeding 80 characters is preferable to breaking the
string.  But here, at least if Python was not indentation sensitive, there
are much nicer ways to present the string and not exceed 80 characters.

> > On the other hand, I would have much preferred the original msg = code.
> > I don't understand why it is so offensive.
>
> I suggested again to avoid the use of extra variables in such cases
> (also in the discussed bit of Python source code within a SmPL script).

I realize that you don't like it, although I have no idea why.  Does it
make the code slower? Less reliable? Less readable?  I doubt any of those
things.  I think that staying within 80 characters would be a much greater
benefit that all of these baseless concerns.

julia

>
> Regards,
> Markus
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [1/5] Coccinelle: put_device: Adjust a message construction

2019-05-13 Thread Markus Elfring
>> Thus simplify a message construction in a SmPL rule by concatenating text
>> with two plus operators less.
>
> Is there any way to unindent, so that the string doesn't exceed 80 characters,
> or at least no so much?

How does your concern fit to the string literal tolerance from
the Linux coding style?


> On the other hand, I would have much preferred the original msg = code.
> I don't understand why it is so offensive.

I suggested again to avoid the use of extra variables in such cases
(also in the discussed bit of Python source code within a SmPL script).

Regards,
Markus


Re: [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring 
> Date: Wed, 8 May 2019 13:50:49 +0200
>
> Extend a when constraint in a SmPL rule so that an additional cast
> is optionally excluded from source code searches for an expression
> in assignments.

Acked-by: Julia Lawall 

>
> Signed-off-by: Markus Elfring 
> Suggested-by: Julia Lawall 
> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.1902160934400.3212@hadrien/
> Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005592.html
> ---
>  scripts/coccinelle/free/put_device.cocci | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci 
> b/scripts/coccinelle/free/put_device.cocci
> index 3ebebc064f10..120921366e84 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -24,7 +24,7 @@ if (id == NULL || ...) { ... return ...; }
>  when != of_dev_put(id)
>  when != if (id) { ... put_device(>dev) ... }
>  when != e1 = (T)id
> -when != e1 = >dev
> +when != e1 = (T)(>dev)
>  when != e1 = get_device(>dev)
>  when != e1 = (T1)platform_get_drvdata(id)
>  (
> --
> 2.21.0
>
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring 
> Date: Mon, 13 May 2019 09:47:17 +0200
>
> A SmPL ellipsis was specified for a search approach so that additional
> source code would be tolerated between an assignment to a local variable
> and the corresponding null pointer check.
>
> But such code should be restricted.
> * The local variable must not be reassigned there.
> * It must also not be forwarded to an other assignment target.
>
> Take additional casts for these code exclusion specifications into account
> together with optional parentheses.

NACK.  You don't need so many type metavariables.  Type metavariables in
the same ... can be the same.

julia

>
> Link: https://lore.kernel.org/cocci/201902191014156680...@zte.com.cn/
> Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html
> Fixes: da9cfb87a44da61f2403c4312916befcb6b6d7e8 ("coccinelle: semantic code 
> search for missing put_device()")
> Signed-off-by: Markus Elfring 
> ---
>  scripts/coccinelle/free/put_device.cocci | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci 
> b/scripts/coccinelle/free/put_device.cocci
> index aae79c02c1e0..28b0be53fb3f 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -13,13 +13,15 @@ virtual org
>  local idexpression id;
>  expression x,e,e1;
>  position p1,p2;
> -type T,T1,T2,T3;
> +type T,T1,T2,T3,T4,T5,T6;
>  @@
>
>  id = of_find_device_by_node@p1(x)
> -... when != e = id
> + ... when != e = (T4)(id)
> + when != id = (T5)(e)
>  if (id == NULL || ...) { ... return ...; }
>  ... when != put_device(>dev)
> +when != id = (T6)(e)
>  when != platform_device_put(id)
>  when != of_dev_put(id)
>  when != if (id) { ... put_device(>dev) ... }
> --
> 2.21.0
>
>
___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


Re: [PATCH 1/5] Coccinelle: put_device: Adjust a message construction

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring 
> Date: Tue, 7 May 2019 11:20:48 +0200
>
> The Linux coding style tolerates long string literals so that
> the provided information can be easier found also by search tools
> like grep.
> Thus simplify a message construction in a SmPL rule by concatenating text
> with two plus operators less.

I don't know python very well.  Is there any way to unindent, so that the
string doesn't exceed 80 characters, or at least no so much?

On the other hand, I would have much preferred the original msg = code.  I
don't understand why it is so offensive.

julia

>
> Signed-off-by: Markus Elfring 
> ---
>  scripts/coccinelle/free/put_device.cocci | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci 
> b/scripts/coccinelle/free/put_device.cocci
> index c9f071b0a0ab..3ebebc064f10 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -42,11 +42,10 @@ p1 << search.p1;
>  p2 << search.p2;
>  @@
>
> -coccilib.report.print_report(p2[0], "ERROR: missing put_device; "
> -   + "call of_find_device_by_node on line "
> -   + p1[0].line
> -   + ", but without a corresponding object release "
> -   + "within this function.")
> +coccilib.report.print_report(p2[0],
> + "ERROR: missing put_device; call 
> of_find_device_by_node on line "
> + + p1[0].line
> + + ", but without a corresponding object release 
> within this function.")
>
>  @script:python depends on org@
>  p1 << search.p1;
> --
> 2.21.0
>
>


Re: [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring 
> Date: Sun, 12 May 2019 18:32:46 +0200
>
> An assignment target was repeated in four SmPL when constraints.
> Combine the exclusion specifications into disjunctions for the semantic
> patch language so that this target is referenced only once there.

NACK.  This exceeds 80 characters and provides no readability benefit.

julia

>
> Signed-off-by: Markus Elfring 
> ---
>  scripts/coccinelle/free/put_device.cocci | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci 
> b/scripts/coccinelle/free/put_device.cocci
> index 120921366e84..aae79c02c1e0 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -23,10 +23,7 @@ if (id == NULL || ...) { ... return ...; }
>  when != platform_device_put(id)
>  when != of_dev_put(id)
>  when != if (id) { ... put_device(>dev) ... }
> -when != e1 = (T)id
> -when != e1 = (T)(>dev)
> -when != e1 = get_device(>dev)
> -when != e1 = (T1)platform_get_drvdata(id)
> +when != e1 = \( (T) \( id \| (>dev) \) \| get_device(>dev) \| 
> (T1)platform_get_drvdata(id) \)
>  (
>return
>  (id
> --
> 2.21.0
>
>


Re: [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one

2019-05-13 Thread Julia Lawall



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring 
> Date: Mon, 13 May 2019 09:55:22 +0200
>
> A single parameter was repeated for a function call in two SmPL
> when constraints.
> Combine the exclusion specifications into a disjunction for the semantic
> patch language so that this argument is referenced only once there.
>
> Signed-off-by: Markus Elfring 

NACK.  This hurts readability and gives no practical benefit.

julia

> ---
>  scripts/coccinelle/free/put_device.cocci | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci 
> b/scripts/coccinelle/free/put_device.cocci
> index 28b0be53fb3f..975cabb97d01 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -22,8 +22,7 @@ id = of_find_device_by_node@p1(x)
>  if (id == NULL || ...) { ... return ...; }
>  ... when != put_device(>dev)
>  when != id = (T6)(e)
> -when != platform_device_put(id)
> -when != of_dev_put(id)
> +when != \( platform_device_put \| of_dev_put \) (id)
>  when != if (id) { ... put_device(>dev) ... }
>  when != e1 = \( (T) \( id \| (>dev) \) \| get_device(>dev) \| 
> (T1)platform_get_drvdata(id) \)
>  (
> --
> 2.21.0
>
>


[Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses

2019-05-13 Thread Markus Elfring
From: Markus Elfring 
Date: Mon, 13 May 2019 09:47:17 +0200

A SmPL ellipsis was specified for a search approach so that additional
source code would be tolerated between an assignment to a local variable
and the corresponding null pointer check.

But such code should be restricted.
* The local variable must not be reassigned there.
* It must also not be forwarded to an other assignment target.

Take additional casts for these code exclusion specifications into account
together with optional parentheses.

Link: https://lore.kernel.org/cocci/201902191014156680...@zte.com.cn/
Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html
Fixes: da9cfb87a44da61f2403c4312916befcb6b6d7e8 ("coccinelle: semantic code 
search for missing put_device()")
Signed-off-by: Markus Elfring 
---
 scripts/coccinelle/free/put_device.cocci | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/free/put_device.cocci 
b/scripts/coccinelle/free/put_device.cocci
index aae79c02c1e0..28b0be53fb3f 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -13,13 +13,15 @@ virtual org
 local idexpression id;
 expression x,e,e1;
 position p1,p2;
-type T,T1,T2,T3;
+type T,T1,T2,T3,T4,T5,T6;
 @@

 id = of_find_device_by_node@p1(x)
-... when != e = id
+ ... when != e = (T4)(id)
+ when != id = (T5)(e)
 if (id == NULL || ...) { ... return ...; }
 ... when != put_device(>dev)
+when != id = (T6)(e)
 when != platform_device_put(id)
 when != of_dev_put(id)
 when != if (id) { ... put_device(>dev) ... }
--
2.21.0

___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


[Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one

2019-05-13 Thread Markus Elfring
From: Markus Elfring 
Date: Mon, 13 May 2019 09:55:22 +0200

A single parameter was repeated for a function call in two SmPL
when constraints.
Combine the exclusion specifications into a disjunction for the semantic
patch language so that this argument is referenced only once there.

Signed-off-by: Markus Elfring 
---
 scripts/coccinelle/free/put_device.cocci | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/coccinelle/free/put_device.cocci 
b/scripts/coccinelle/free/put_device.cocci
index 28b0be53fb3f..975cabb97d01 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -22,8 +22,7 @@ id = of_find_device_by_node@p1(x)
 if (id == NULL || ...) { ... return ...; }
 ... when != put_device(>dev)
 when != id = (T6)(e)
-when != platform_device_put(id)
-when != of_dev_put(id)
+when != \( platform_device_put \| of_dev_put \) (id)
 when != if (id) { ... put_device(>dev) ... }
 when != e1 = \( (T) \( id \| (>dev) \) \| get_device(>dev) \| 
(T1)platform_get_drvdata(id) \)
 (
--
2.21.0

___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


[Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses

2019-05-13 Thread Markus Elfring
From: Markus Elfring 
Date: Mon, 13 May 2019 09:47:17 +0200

A SmPL ellipsis was specified for a search approach so that additional
source code would be tolerated between an assignment to a local variable
and the corresponding null pointer check.

But such code should be restricted.
* The local variable must not be reassigned there.
* It must also not be forwarded to an other assignment target.

Take additional casts for these code exclusion specifications into account
together with optional parentheses.

Link: https://lore.kernel.org/cocci/201902191014156680...@zte.com.cn/
Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html
Fixes: da9cfb87a44da61f2403c4312916befcb6b6d7e8 ("coccinelle: semantic code 
search for missing put_device()")
Signed-off-by: Markus Elfring 
---
 scripts/coccinelle/free/put_device.cocci | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/free/put_device.cocci 
b/scripts/coccinelle/free/put_device.cocci
index aae79c02c1e0..28b0be53fb3f 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -13,13 +13,15 @@ virtual org
 local idexpression id;
 expression x,e,e1;
 position p1,p2;
-type T,T1,T2,T3;
+type T,T1,T2,T3,T4,T5,T6;
 @@

 id = of_find_device_by_node@p1(x)
-... when != e = id
+ ... when != e = (T4)(id)
+ when != id = (T5)(e)
 if (id == NULL || ...) { ... return ...; }
 ... when != put_device(>dev)
+when != id = (T6)(e)
 when != platform_device_put(id)
 when != of_dev_put(id)
 when != if (id) { ... put_device(>dev) ... }
--
2.21.0

___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci


[PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment

2019-05-13 Thread Markus Elfring
From: Markus Elfring 
Date: Wed, 8 May 2019 13:50:49 +0200

Extend a when constraint in a SmPL rule so that an additional cast
is optionally excluded from source code searches for an expression
in assignments.

Signed-off-by: Markus Elfring 
Suggested-by: Julia Lawall 
Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.1902160934400.3212@hadrien/
Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005592.html
---
 scripts/coccinelle/free/put_device.cocci | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/free/put_device.cocci 
b/scripts/coccinelle/free/put_device.cocci
index 3ebebc064f10..120921366e84 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -24,7 +24,7 @@ if (id == NULL || ...) { ... return ...; }
 when != of_dev_put(id)
 when != if (id) { ... put_device(>dev) ... }
 when != e1 = (T)id
-when != e1 = >dev
+when != e1 = (T)(>dev)
 when != e1 = get_device(>dev)
 when != e1 = (T1)platform_get_drvdata(id)
 (
--
2.21.0



[PATCH 1/5] Coccinelle: put_device: Adjust a message construction

2019-05-13 Thread Markus Elfring
From: Markus Elfring 
Date: Tue, 7 May 2019 11:20:48 +0200

The Linux coding style tolerates long string literals so that
the provided information can be easier found also by search tools
like grep.
Thus simplify a message construction in a SmPL rule by concatenating text
with two plus operators less.

Signed-off-by: Markus Elfring 
---
 scripts/coccinelle/free/put_device.cocci | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/coccinelle/free/put_device.cocci 
b/scripts/coccinelle/free/put_device.cocci
index c9f071b0a0ab..3ebebc064f10 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -42,11 +42,10 @@ p1 << search.p1;
 p2 << search.p2;
 @@

-coccilib.report.print_report(p2[0], "ERROR: missing put_device; "
- + "call of_find_device_by_node on line "
- + p1[0].line
- + ", but without a corresponding object release "
- + "within this function.")
+coccilib.report.print_report(p2[0],
+ "ERROR: missing put_device; call 
of_find_device_by_node on line "
+ + p1[0].line
+ + ", but without a corresponding object release 
within this function.")

 @script:python depends on org@
 p1 << search.p1;
--
2.21.0



[PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script

2019-05-13 Thread Markus Elfring
Some adjustments were discussed also for this script a while ago.
The software development attention evolved in a special way in the meantime.

See also for further background information:
https://lore.kernel.org/lkml/cak7lnatjasisezotz57zbhse0j5zyy_12zq0gaf_ocziuwh...@mail.gmail.com/
https://systeme.lip6.fr/pipermail/cocci/2019-March/005692.html
https://lkml.org/lkml/2019/3/26/395

I would appreciate if corresponding implementation details will get
another look.

Markus Elfring (5):
  Adjust a message construction
  Add a cast to an expression for an assignment
  Merge four SmPL when constraints into one
  Extend when constraints for two SmPL ellipses
  Merge two SmPL when constraints into one

 scripts/coccinelle/free/put_device.cocci | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

--
2.21.0