Coccinelle archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] [PATCH] coccinelle: put_device: reduce false positives
@ 2019-03-23  6:14 Wen Yang
  2019-03-23 13:41 ` Julia Lawall
                   ` (2 more replies)
  0 siblings, 3 replies; 41+ messages in thread
From: Wen Yang @ 2019-03-23  6:14 UTC (permalink / raw)
  To: yamada.masahiro
  Cc: wang.yi59, Michal Marek, Nicolas Palix, linux-kernel, cocci, Wen Yang

Don't complain about a return when this function returns "&pdev->dev".

Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Gilles Muller <Gilles.Muller@lip6.fr>
Cc: Nicolas Palix <nicolas.palix@imag.fr>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
CC: cocci@systeme.lip6.fr
Cc: linux-kernel@vger.kernel.org
---
 scripts/coccinelle/free/put_device.cocci | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
index 7395697..c9f071b 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -32,6 +32,7 @@ if (id == NULL || ...) { ... return ...; }
 (    id
 |    (T2)dev_get_drvdata(&id->dev)
 |    (T3)platform_get_drvdata(id)
+|    &id->dev
 );
 | return@p2 ...;
 )
-- 
2.9.5

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

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-23  6:14 [Cocci] [PATCH] coccinelle: put_device: reduce false positives Wen Yang
@ 2019-03-23 13:41 ` Julia Lawall
  2019-03-23 19:44 ` Markus Elfring
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
  2 siblings, 0 replies; 41+ messages in thread
From: Julia Lawall @ 2019-03-23 13:41 UTC (permalink / raw)
  To: Wen Yang; +Cc: wang.yi59, Michal Marek, Nicolas Palix, linux-kernel, cocci



On Sat, 23 Mar 2019, Wen Yang wrote:

> Don't complain about a return when this function returns "&pdev->dev".
>
> Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Julia Lawall <Julia.Lawall@lip6.fr>
> Cc: Gilles Muller <Gilles.Muller@lip6.fr>
> Cc: Nicolas Palix <nicolas.palix@imag.fr>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> CC: cocci@systeme.lip6.fr
> Cc: linux-kernel@vger.kernel.org

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


> ---
>  scripts/coccinelle/free/put_device.cocci | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
> index 7395697..c9f071b 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -32,6 +32,7 @@ if (id == NULL || ...) { ... return ...; }
>  (    id
>  |    (T2)dev_get_drvdata(&id->dev)
>  |    (T3)platform_get_drvdata(id)
> +|    &id->dev
>  );
>  | return@p2 ...;
>  )
> --
> 2.9.5
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-23  6:14 [Cocci] [PATCH] coccinelle: put_device: reduce false positives Wen Yang
  2019-03-23 13:41 ` Julia Lawall
@ 2019-03-23 19:44 ` Markus Elfring
  2019-03-23 20:06   ` Julia Lawall
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
  2 siblings, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-03-23 19:44 UTC (permalink / raw)
  To: Wen Yang, Julia Lawall, Masahiro Yamada
  Cc: Yi Wang, Michal Marek, Nicolas Palix, kernel-janitors,
	linux-kernel, cocci

> Don't complain about a return when this function returns "&pdev->dev".

Would this information qualify to add the tag “Fixes” to the commit message?

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

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-23 19:44 ` Markus Elfring
@ 2019-03-23 20:06   ` Julia Lawall
  2019-03-26  8:45     ` Dan Carpenter
  0 siblings, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-03-23 20:06 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	linux-kernel, cocci, Wen Yang

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]



On Sat, 23 Mar 2019, Markus Elfring wrote:

> > Don't complain about a return when this function returns "&pdev->dev".
>
> Would this information qualify to add the tag “Fixes” to the commit message?

Fixes tags relate to stable kernels, so that one can see which stable
kernels a particular patch should be propagated to.  There is no need to
propagate patches on semantic patches to stable kernels.  People who run
stable kernels are interested in their behavior, not the bug finding
rules that they contain.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-23 20:06   ` Julia Lawall
@ 2019-03-26  8:45     ` Dan Carpenter
  2019-03-26  9:38       ` Julia Lawall
  0 siblings, 1 reply; 41+ messages in thread
From: Dan Carpenter @ 2019-03-26  8:45 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	linux-kernel, cocci, Markus Elfring, Wen Yang

On Sat, Mar 23, 2019 at 09:06:54PM +0100, Julia Lawall wrote:
> 
> 
> On Sat, 23 Mar 2019, Markus Elfring wrote:
> 
> > > Don't complain about a return when this function returns "&pdev->dev".
> >
> > Would this information qualify to add the tag “Fixes” to the commit message?
> 
> Fixes tags relate to stable kernels, so that one can see which stable
> kernels a particular patch should be propagated to.  There is no need to
> propagate patches on semantic patches to stable kernels.  People who run
> stable kernels are interested in their behavior, not the bug finding
> rules that they contain.

The Fixes tag is not just about stable...  For example, we use them for
statistics to see how quickly bugs get fixed etc.

regards,
dan carpenter

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

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-26  8:45     ` Dan Carpenter
@ 2019-03-26  9:38       ` Julia Lawall
  2019-03-26 10:11         ` Dan Carpenter
  0 siblings, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-03-26  9:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	linux-kernel, cocci, Markus Elfring, Wen Yang

[-- Attachment #1: Type: text/plain, Size: 975 bytes --]



On Tue, 26 Mar 2019, Dan Carpenter wrote:

> On Sat, Mar 23, 2019 at 09:06:54PM +0100, Julia Lawall wrote:
> >
> >
> > On Sat, 23 Mar 2019, Markus Elfring wrote:
> >
> > > > Don't complain about a return when this function returns "&pdev->dev".
> > >
> > > Would this information qualify to add the tag “Fixes” to the commit message?
> >
> > Fixes tags relate to stable kernels, so that one can see which stable
> > kernels a particular patch should be propagated to.  There is no need to
> > propagate patches on semantic patches to stable kernels.  People who run
> > stable kernels are interested in their behavior, not the bug finding
> > rules that they contain.
>
> The Fixes tag is not just about stable...  For example, we use them for
> statistics to see how quickly bugs get fixed etc.

OK.  But still do we need fixes tags for bug finding rules?  Perhaps if
the previous version was really broken, and it would be really undesirable
to use it.

thanks,
julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-26  9:38       ` Julia Lawall
@ 2019-03-26 10:11         ` Dan Carpenter
  2019-03-26 10:15           ` Julia Lawall
  0 siblings, 1 reply; 41+ messages in thread
From: Dan Carpenter @ 2019-03-26 10:11 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	linux-kernel, cocci, Markus Elfring, Wen Yang

On Tue, Mar 26, 2019 at 10:38:43AM +0100, Julia Lawall wrote:
> 
> 
> On Tue, 26 Mar 2019, Dan Carpenter wrote:
> 
> > On Sat, Mar 23, 2019 at 09:06:54PM +0100, Julia Lawall wrote:
> > >
> > >
> > > On Sat, 23 Mar 2019, Markus Elfring wrote:
> > >
> > > > > Don't complain about a return when this function returns "&pdev->dev".
> > > >
> > > > Would this information qualify to add the tag “Fixes” to the commit message?
> > >
> > > Fixes tags relate to stable kernels, so that one can see which stable
> > > kernels a particular patch should be propagated to.  There is no need to
> > > propagate patches on semantic patches to stable kernels.  People who run
> > > stable kernels are interested in their behavior, not the bug finding
> > > rules that they contain.
> >
> > The Fixes tag is not just about stable...  For example, we use them for
> > statistics to see how quickly bugs get fixed etc.
> 
> OK.  But still do we need fixes tags for bug finding rules?  Perhaps if
> the previous version was really broken, and it would be really undesirable
> to use it.

It's not worth resending a patch for that, but I probably would use the
fixes tag.  It depends on your definition of "bug" really...  I tell
people not to use Fixes for spelling mistakes and unused variables.  But
I do use the Fixes tag for things like "an off by one in a sanity check
which doesn't affect run time because the index is always correct".

regards,
dan carpenter
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-26 10:11         ` Dan Carpenter
@ 2019-03-26 10:15           ` Julia Lawall
  2019-03-28 13:08             ` Masahiro Yamada
  0 siblings, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-03-26 10:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	linux-kernel, cocci, Markus Elfring, Wen Yang

[-- Attachment #1: Type: text/plain, Size: 1551 bytes --]



On Tue, 26 Mar 2019, Dan Carpenter wrote:

> On Tue, Mar 26, 2019 at 10:38:43AM +0100, Julia Lawall wrote:
> >
> >
> > On Tue, 26 Mar 2019, Dan Carpenter wrote:
> >
> > > On Sat, Mar 23, 2019 at 09:06:54PM +0100, Julia Lawall wrote:
> > > >
> > > >
> > > > On Sat, 23 Mar 2019, Markus Elfring wrote:
> > > >
> > > > > > Don't complain about a return when this function returns "&pdev->dev".
> > > > >
> > > > > Would this information qualify to add the tag “Fixes” to the commit message?
> > > >
> > > > Fixes tags relate to stable kernels, so that one can see which stable
> > > > kernels a particular patch should be propagated to.  There is no need to
> > > > propagate patches on semantic patches to stable kernels.  People who run
> > > > stable kernels are interested in their behavior, not the bug finding
> > > > rules that they contain.
> > >
> > > The Fixes tag is not just about stable...  For example, we use them for
> > > statistics to see how quickly bugs get fixed etc.
> >
> > OK.  But still do we need fixes tags for bug finding rules?  Perhaps if
> > the previous version was really broken, and it would be really undesirable
> > to use it.
>
> It's not worth resending a patch for that, but I probably would use the
> fixes tag.  It depends on your definition of "bug" really...  I tell
> people not to use Fixes for spelling mistakes and unused variables.  But
> I do use the Fixes tag for things like "an off by one in a sanity check
> which doesn't affect run time because the index is always correct".

OK, thanks.

julia

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-26 10:15           ` Julia Lawall
@ 2019-03-28 13:08             ` Masahiro Yamada
  2019-03-28 14:19               ` Julia Lawall
  2019-04-01  6:44               ` [Cocci] Coccinelle: " Markus Elfring
  0 siblings, 2 replies; 41+ messages in thread
From: Masahiro Yamada @ 2019-03-28 13:08 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	Linux Kernel Mailing List, cocci, Markus Elfring, Wen Yang,
	Dan Carpenter

On Tue, Mar 26, 2019 at 7:16 PM Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>
> On Tue, 26 Mar 2019, Dan Carpenter wrote:
>
> > On Tue, Mar 26, 2019 at 10:38:43AM +0100, Julia Lawall wrote:
> > >
> > >
> > > On Tue, 26 Mar 2019, Dan Carpenter wrote:
> > >
> > > > On Sat, Mar 23, 2019 at 09:06:54PM +0100, Julia Lawall wrote:
> > > > >
> > > > >
> > > > > On Sat, 23 Mar 2019, Markus Elfring wrote:
> > > > >
> > > > > > > Don't complain about a return when this function returns "&pdev->dev".
> > > > > >
> > > > > > Would this information qualify to add the tag “Fixes” to the commit message?
> > > > >
> > > > > Fixes tags relate to stable kernels, so that one can see which stable
> > > > > kernels a particular patch should be propagated to.  There is no need to
> > > > > propagate patches on semantic patches to stable kernels.  People who run
> > > > > stable kernels are interested in their behavior, not the bug finding
> > > > > rules that they contain.
> > > >
> > > > The Fixes tag is not just about stable...  For example, we use them for
> > > > statistics to see how quickly bugs get fixed etc.
> > >
> > > OK.  But still do we need fixes tags for bug finding rules?  Perhaps if
> > > the previous version was really broken, and it would be really undesirable
> > > to use it.
> >
> > It's not worth resending a patch for that, but I probably would use the
> > fixes tag.  It depends on your definition of "bug" really...  I tell
> > people not to use Fixes for spelling mistakes and unused variables.  But
> > I do use the Fixes tag for things like "an off by one in a sanity check
> > which doesn't affect run time because the index is always correct".
>
> OK, thanks.
>
> julia

I added Fixes: tag,
and applied to linux-kbuild/fixes.

Thanks.

-- 
Best Regards
Masahiro Yamada
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH] coccinelle: put_device: reduce false positives
  2019-03-28 13:08             ` Masahiro Yamada
@ 2019-03-28 14:19               ` Julia Lawall
  2019-04-01  6:44               ` [Cocci] Coccinelle: " Markus Elfring
  1 sibling, 0 replies; 41+ messages in thread
From: Julia Lawall @ 2019-03-28 14:19 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Yi Wang, Michal Marek, kernel-janitors, Nicolas Palix,
	Linux Kernel Mailing List, cocci, Markus Elfring, Wen Yang,
	Dan Carpenter

[-- Attachment #1: Type: text/plain, Size: 1966 bytes --]



On Thu, 28 Mar 2019, Masahiro Yamada wrote:

> On Tue, Mar 26, 2019 at 7:16 PM Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> >
> >
> > On Tue, 26 Mar 2019, Dan Carpenter wrote:
> >
> > > On Tue, Mar 26, 2019 at 10:38:43AM +0100, Julia Lawall wrote:
> > > >
> > > >
> > > > On Tue, 26 Mar 2019, Dan Carpenter wrote:
> > > >
> > > > > On Sat, Mar 23, 2019 at 09:06:54PM +0100, Julia Lawall wrote:
> > > > > >
> > > > > >
> > > > > > On Sat, 23 Mar 2019, Markus Elfring wrote:
> > > > > >
> > > > > > > > Don't complain about a return when this function returns "&pdev->dev".
> > > > > > >
> > > > > > > Would this information qualify to add the tag “Fixes” to the commit message?
> > > > > >
> > > > > > Fixes tags relate to stable kernels, so that one can see which stable
> > > > > > kernels a particular patch should be propagated to.  There is no need to
> > > > > > propagate patches on semantic patches to stable kernels.  People who run
> > > > > > stable kernels are interested in their behavior, not the bug finding
> > > > > > rules that they contain.
> > > > >
> > > > > The Fixes tag is not just about stable...  For example, we use them for
> > > > > statistics to see how quickly bugs get fixed etc.
> > > >
> > > > OK.  But still do we need fixes tags for bug finding rules?  Perhaps if
> > > > the previous version was really broken, and it would be really undesirable
> > > > to use it.
> > >
> > > It's not worth resending a patch for that, but I probably would use the
> > > fixes tag.  It depends on your definition of "bug" really...  I tell
> > > people not to use Fixes for spelling mistakes and unused variables.  But
> > > I do use the Fixes tag for things like "an off by one in a sanity check
> > > which doesn't affect run time because the index is always correct".
> >
> > OK, thanks.
> >
> > julia
>
> I added Fixes: tag,
> and applied to linux-kbuild/fixes.

Thanks!

julia

>
> Thanks.
>
> --
> Best Regards
> Masahiro Yamada
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] Coccinelle: put_device: reduce false positives
  2019-03-28 13:08             ` Masahiro Yamada
  2019-03-28 14:19               ` Julia Lawall
@ 2019-04-01  6:44               ` " Markus Elfring
  2019-04-01 20:04                 ` Julia Lawall
  1 sibling, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-04-01  6:44 UTC (permalink / raw)
  To: Masahiro Yamada, Julia Lawall, Wen Yang, kernel-janitors
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, cocci, Dan Carpenter

> I added Fixes: tag,
> and applied to linux-kbuild/fixes.

Will this extension trigger further adjustments for similar SmPL scripts?

Example:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/scripts/coccinelle/free/pci_free_consistent.cocci?id=f7b167113753e95ae61383e234f8d10142782ace

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

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

* Re: [Cocci] Coccinelle: put_device: reduce false positives
  2019-04-01  6:44               ` [Cocci] Coccinelle: " Markus Elfring
@ 2019-04-01 20:04                 ` Julia Lawall
  0 siblings, 0 replies; 41+ messages in thread
From: Julia Lawall @ 2019-04-01 20:04 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, kernel-janitors,
	linux-kernel, cocci, Wen Yang, Dan Carpenter



On Mon, 1 Apr 2019, Markus Elfring wrote:

> > I added Fixes: tag,
> > and applied to linux-kbuild/fixes.
>
> Will this extension trigger further adjustments for similar SmPL scripts?
>
> Example:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/scripts/coccinelle/free/pci_free_consistent.cocci?id=f7b167113753e95ae61383e234f8d10142782ace

If there are false positives caused by this or other scripts, feel free to
submit a patch.

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

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

* [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script
  2019-03-23  6:14 [Cocci] [PATCH] coccinelle: put_device: reduce false positives Wen Yang
  2019-03-23 13:41 ` Julia Lawall
  2019-03-23 19:44 ` Markus Elfring
@ 2019-05-13  8:55 ` Markus Elfring
  2019-05-13  8:59   ` [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction Markus Elfring
                     ` (5 more replies)
  2 siblings, 6 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  8:55 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

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_oCziUWheOQ@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

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

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

* [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
@ 2019-05-13  8:59   ` Markus Elfring
  2019-05-13  9:35     ` Julia Lawall
  2019-07-06 13:13     ` [Cocci] [PATCH 1/5] " Masahiro Yamada
  2019-05-13  9:01   ` [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment Markus Elfring
                     ` (4 subsequent siblings)
  5 siblings, 2 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  8:59 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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

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

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

* [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
  2019-05-13  8:59   ` [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction Markus Elfring
@ 2019-05-13  9:01   ` Markus Elfring
  2019-05-13  9:33     ` Julia Lawall
  2019-07-06 13:13     ` Masahiro Yamada
  2019-05-13  9:05   ` [Cocci] [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one Markus Elfring
                     ` (3 subsequent siblings)
  5 siblings, 2 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  9:01 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
Suggested-by: Julia Lawall <Julia.Lawall@lip6.fr>
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(&id->dev) ... }
     when != e1 = (T)id
-    when != e1 = &id->dev
+    when != e1 = (T)(&id->dev)
     when != e1 = get_device(&id->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

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

* [Cocci] [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
  2019-05-13  8:59   ` [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction Markus Elfring
  2019-05-13  9:01   ` [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment Markus Elfring
@ 2019-05-13  9:05   ` Markus Elfring
  2019-05-13  9:32     ` Julia Lawall
  2019-05-13  9:07   ` [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  9:05 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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(&id->dev) ... }
-    when != e1 = (T)id
-    when != e1 = (T)(&id->dev)
-    when != e1 = get_device(&id->dev)
-    when != e1 = (T1)platform_get_drvdata(id)
+    when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->dev) \| (T1)platform_get_drvdata(id) \)
 (
   return
 (    id
--
2.21.0

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

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

* [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
                     ` (3 preceding siblings ...)
  2019-05-13  9:07   ` [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
@ 2019-05-13  9:07   ` " Markus Elfring
  2019-05-13  9:10   ` [Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one Markus Elfring
  5 siblings, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  9:07 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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/201902191014156680299@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 <elfring@users.sourceforge.net>
---
 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(&id->dev)
+    when != id = (T6)(e)
     when != platform_device_put(id)
     when != of_dev_put(id)
     when != if (id) { ... put_device(&id->dev) ... }
--
2.21.0

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

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

* [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
                     ` (2 preceding siblings ...)
  2019-05-13  9:05   ` [Cocci] [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one Markus Elfring
@ 2019-05-13  9:07   ` Markus Elfring
  2019-05-13  9:31     ` Julia Lawall
  2019-05-13  9:07   ` [Cocci] [PATCH 4/5] " Markus Elfring
  2019-05-13  9:10   ` [Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one Markus Elfring
  5 siblings, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  9:07 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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/201902191014156680299@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 <elfring@users.sourceforge.net>
---
 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(&id->dev)
+    when != id = (T6)(e)
     when != platform_device_put(id)
     when != of_dev_put(id)
     when != if (id) { ... put_device(&id->dev) ... }
--
2.21.0

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

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

* [Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one
  2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
                     ` (4 preceding siblings ...)
  2019-05-13  9:07   ` [Cocci] [PATCH 4/5] " Markus Elfring
@ 2019-05-13  9:10   ` Markus Elfring
  2019-05-13  9:30     ` Julia Lawall
  5 siblings, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-13  9:10 UTC (permalink / raw)
  To: Julia Lawall, Gilles Muller, Masahiro Yamada, Michal Marek,
	Nicolas Palix, Wen Yang
  Cc: Yi Wang, cocci, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
 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(&id->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(&id->dev) ... }
     when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->dev) \| (T1)platform_get_drvdata(id) \)
 (
--
2.21.0

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

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

* Re: [Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one
  2019-05-13  9:10   ` [Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one Markus Elfring
@ 2019-05-13  9:30     ` Julia Lawall
  2019-05-13 12:35       ` [Cocci] [5/5] " Markus Elfring
  0 siblings, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-05-13  9:30 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>

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(&id->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(&id->dev) ... }
>      when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->dev) \| (T1)platform_get_drvdata(id) \)
>  (
> --
> 2.21.0
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-13  9:07   ` [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
@ 2019-05-13  9:31     ` Julia Lawall
  2019-05-13 12:22       ` [Cocci] [4/5] " Markus Elfring
  2019-05-14  5:55       ` Markus Elfring
  0 siblings, 2 replies; 41+ messages in thread
From: Julia Lawall @ 2019-05-13  9:31 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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/201902191014156680299@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 <elfring@users.sourceforge.net>
> ---
>  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(&id->dev)
> +    when != id = (T6)(e)
>      when != platform_device_put(id)
>      when != of_dev_put(id)
>      when != if (id) { ... put_device(&id->dev) ... }
> --
> 2.21.0
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
  2019-05-13  9:05   ` [Cocci] [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one Markus Elfring
@ 2019-05-13  9:32     ` Julia Lawall
  2019-05-13 11:48       ` [Cocci] [3/5] " Markus Elfring
  2019-05-13 11:48       ` Markus Elfring
  0 siblings, 2 replies; 41+ messages in thread
From: Julia Lawall @ 2019-05-13  9:32 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, cocci, Wen Yang



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
>  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(&id->dev) ... }
> -    when != e1 = (T)id
> -    when != e1 = (T)(&id->dev)
> -    when != e1 = get_device(&id->dev)
> -    when != e1 = (T1)platform_get_drvdata(id)
> +    when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->dev) \| (T1)platform_get_drvdata(id) \)
>  (
>    return
>  (    id
> --
> 2.21.0
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment
  2019-05-13  9:01   ` [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment Markus Elfring
@ 2019-05-13  9:33     ` Julia Lawall
  2019-07-06 13:13     ` Masahiro Yamada
  1 sibling, 0 replies; 41+ messages in thread
From: Julia Lawall @ 2019-05-13  9:33 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <julia.lawall@lip6.fr>

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> Suggested-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 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(&id->dev) ... }
>      when != e1 = (T)id
> -    when != e1 = &id->dev
> +    when != e1 = (T)(&id->dev)
>      when != e1 = get_device(&id->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

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

* Re: [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction
  2019-05-13  8:59   ` [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction Markus Elfring
@ 2019-05-13  9:35     ` Julia Lawall
  2019-05-13 11:33       ` [Cocci] [1/5] " Markus Elfring
  2019-07-06 13:13     ` [Cocci] [PATCH 1/5] " Masahiro Yamada
  1 sibling, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-05-13  9:35 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---
>  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
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [1/5] Coccinelle: put_device: Adjust a message construction
  2019-05-13  9:35     ` Julia Lawall
@ 2019-05-13 11:33       ` " Markus Elfring
  2019-05-13 11:36         ` Julia Lawall
  0 siblings, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 11:33 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

>> 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [1/5] Coccinelle: put_device: Adjust a message construction
  2019-05-13 11:33       ` [Cocci] [1/5] " Markus Elfring
@ 2019-05-13 11:36         ` Julia Lawall
  2019-05-13 12:48           ` Markus Elfring
  0 siblings, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-05-13 11:36 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



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

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

* Re: [Cocci] [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
  2019-05-13  9:32     ` Julia Lawall
@ 2019-05-13 11:48       ` " Markus Elfring
  2019-05-13 11:48       ` Markus Elfring
  1 sibling, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 11:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

>> 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(&id->dev) ... }
>> -    when != e1 = (T)id
>> -    when != e1 = (T)(&id->dev)
>> -    when != e1 = get_device(&id->dev)
>> -    when != e1 = (T1)platform_get_drvdata(id)
>> +    when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->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

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

* Re: [Cocci] [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
  2019-05-13  9:32     ` Julia Lawall
  2019-05-13 11:48       ` [Cocci] [3/5] " Markus Elfring
@ 2019-05-13 11:48       ` Markus Elfring
  2019-05-13 11:51         ` Julia Lawall
  1 sibling, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 11:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

>> 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(&id->dev) ... }
>> -    when != e1 = (T)id
>> -    when != e1 = (T)(&id->dev)
>> -    when != e1 = get_device(&id->dev)
>> -    when != e1 = (T1)platform_get_drvdata(id)
>> +    when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->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

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

* Re: [Cocci] [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
  2019-05-13 11:48       ` Markus Elfring
@ 2019-05-13 11:51         ` Julia Lawall
  2019-05-13 12:52           ` Markus Elfring
  0 siblings, 1 reply; 41+ messages in thread
From: Julia Lawall @ 2019-05-13 11:51 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



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(&id->dev) ... }
> >> -    when != e1 = (T)id
> >> -    when != e1 = (T)(&id->dev)
> >> -    when != e1 = get_device(&id->dev)
> >> -    when != e1 = (T1)platform_get_drvdata(id)
> >> +    when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->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

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-13  9:31     ` Julia Lawall
@ 2019-05-13 12:22       ` " Markus Elfring
  2019-05-14  5:55       ` Markus Elfring
  1 sibling, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 12:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

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

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

* Re: [Cocci] [5/5] Coccinelle: put_device: Merge two SmPL when constraints into one
  2019-05-13  9:30     ` Julia Lawall
@ 2019-05-13 12:35       ` " Markus Elfring
  0 siblings, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 12:35 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

>> 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(&id->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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [1/5] Coccinelle: put_device: Adjust a message construction
  2019-05-13 11:36         ` Julia Lawall
@ 2019-05-13 12:48           ` Markus Elfring
  0 siblings, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 12:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

> I realize that you don't like it, although I have no idea why.
> Does it make the code slower?

Would you like to compare the run time characteristics from creating and
looking up an identifier for a Python variable to direct passing of
a concatenated string for the desired function call?


> I think that staying within 80 characters would be a much greater
> benefit that all of these baseless concerns.

Are you aware of another code formatting option?
https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation

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

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

* Re: [Cocci] [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
  2019-05-13 11:51         ` Julia Lawall
@ 2019-05-13 12:52           ` Markus Elfring
  0 siblings, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-13 12:52 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

>> 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
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-13  9:31     ` Julia Lawall
  2019-05-13 12:22       ` [Cocci] [4/5] " Markus Elfring
@ 2019-05-14  5:55       ` Markus Elfring
  2019-05-14  6:52         ` Julia Lawall
  1 sibling, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-14  5:55 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci

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

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-14  5:55       ` Markus Elfring
@ 2019-05-14  6:52         ` Julia Lawall
  2019-05-14  7:49           ` Markus Elfring
  2019-05-14  7:49           ` [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
  0 siblings, 2 replies; 41+ messages in thread
From: Julia Lawall @ 2019-05-14  6:52 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, Wen Yang, cocci



On Tue, 14 May 2019, Markus Elfring wrote:

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

It's ugly.  Much more ugly than msg =

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

I don't understand the question.

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

No idea about this one either.

Basically, if you have T && T, the two T's have to be the same, and T is
not pure.  If you have T || T, then only one will be matched and T remains
pure.  If you have T on two separate ...s then you are in the && case.  If
you have T in two branches of a disjunction or in two whens on the same
... you are in the || case.  Just as you can use the variable e1 over and
over on the same when, you can use the same T.

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

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-14  6:52         ` Julia Lawall
@ 2019-05-14  7:49           ` Markus Elfring
  2019-05-14  9:18             ` [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses wen.yang99
  2019-05-14  7:49           ` [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
  1 sibling, 1 reply; 41+ messages in thread
From: Markus Elfring @ 2019-05-14  7:49 UTC (permalink / raw)
  To: Julia Lawall, Wen Yang
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, cocci

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

Do you find this description inappropriate?


>>> 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.
>
> It's ugly.  Much more ugly than msg =

The clarification of this change reluctance might become more interesting.
I got convinced that there is a need for further software updates.


>> * Can it become required to identify involved source code placeholders
>>   by extra metavariables?
>
> I don't understand the question.

Wen Yang was planning a corresponding modification since 2019-02-19.
https://lore.kernel.org/cocci/201902191014156680299@zte.com.cn/
https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html

I got into the development mood to contribute another concrete update suggestion
for an open issue in affected scripts for the semantic patch language.
Do you recognise the need for the extension of exclusion specifications here?


>> * Would you like to clarify the probability any more how often the shown
>>   type casts will be identical?
>
> No idea about this one either.

I am curious if helpful ideas will be added also by other contributors.


> Basically, if you have T && T, the two T's have to be the same,

Such an expectation might be logical.


> and T is not pure.

This information triggers various communication difficulties.


> If you have T on two separate ...s then you are in the && case.

I agree to this view also according the application of two ellipses
in the SmPL rule “search”.


> If you have T in two branches of a disjunction or in two whens on the same
> ... you are in the || case.

It is clear that disjunctions will check code alternatives here.
The clarification of consequences around the interpretation of “type purity”
might distract from the final solution.


How many (optional) type casts would we like to handle by the discussed
source code search approach?

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

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
  2019-05-14  6:52         ` Julia Lawall
  2019-05-14  7:49           ` Markus Elfring
@ 2019-05-14  7:49           ` Markus Elfring
  1 sibling, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-14  7:49 UTC (permalink / raw)
  To: Julia Lawall, Wen Yang
  Cc: Yi Wang, Michal Marek, Nicolas Palix, linux-kernel, cocci

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

Do you find this description inappropriate?


>>> 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.
>
> It's ugly.  Much more ugly than msg =

The clarification of this change reluctance might become more interesting.
I got convinced that there is a need for further software updates.


>> * Can it become required to identify involved source code placeholders
>>   by extra metavariables?
>
> I don't understand the question.

Wen Yang was planning a corresponding modification since 2019-02-19.
https://lore.kernel.org/cocci/201902191014156680299@zte.com.cn/
https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html

I got into the development mood to contribute another concrete update suggestion
for an open issue in affected scripts for the semantic patch language.
Do you recognise the need for the extension of exclusion specifications here?


>> * Would you like to clarify the probability any more how often the shown
>>   type casts will be identical?
>
> No idea about this one either.

I am curious if helpful ideas will be added also by other contributors.


> Basically, if you have T && T, the two T's have to be the same,

Such an expectation might be logical.


> and T is not pure.

This information triggers various communication difficulties.


> If you have T on two separate ...s then you are in the && case.

I agree to this view also according the application of two ellipses
in the SmPL rule “search”.


> If you have T in two branches of a disjunction or in two whens on the same
> ... you are in the || case.

It is clear that disjunctions will check code alternatives here.
The clarification of consequences around the interpretation of “type purity”
might distract from the final solution.


How many (optional) type casts would we like to handle by the discussed
source code search approach?

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

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses
  2019-05-14  7:49           ` Markus Elfring
@ 2019-05-14  9:18             ` wen.yang99
  2019-05-14  9:51               ` Markus Elfring
  0 siblings, 1 reply; 41+ messages in thread
From: wen.yang99 @ 2019-05-14  9:18 UTC (permalink / raw)
  To: Markus.Elfring; +Cc: wang.yi59, michal.lkml, nicolas.palix, linux-kernel, cocci

[-- Attachment #1.1: Type: text/plain, Size: 1586 bytes --]

> Subject: Re: [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses
> >> Can you agree to any information which I presented in the commit message?
> 
> Do you find this description inappropriate?
> 
> 
> >>> 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.
> >
> > It's ugly.  Much more ugly than msg =
> 
> The clarification of this change reluctance might become more interesting.
> I got convinced that there is a need for further software updates.
> 
> 
> >> * Can it become required to identify involved source code placeholders
> >>   by extra metavariables?
> >
> > I don't understand the question.
> 
> Wen Yang was planning a corresponding modification since 2019-02-19.
> https://lore.kernel.org/cocci/201902191014156680299@zte.com.cn/
> https://systeme.lip6.fr/pipermail/cocci/2019-February/005620.html
> 
Hi Markus,
I did another experiment at that time and found that this modification will
reduce the false positive rate, but it may also reduce the recall rate.

Could we use it to find out as many bugs as possible in the current kernel
and then modify it?

https://systeme.lip6.fr/pipermail/cocci/2019-February/005626.html

Thanks.

--
Regards,
Wen

> 
> I got into the development mood to contribute another concrete update suggestion
> for an open issue in affected scripts for the semantic patch language.
> Do you recognise the need for the extension of exclusion specifications here?
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

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

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

* Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses
  2019-05-14  9:18             ` [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses wen.yang99
@ 2019-05-14  9:51               ` Markus Elfring
  0 siblings, 0 replies; 41+ messages in thread
From: Markus Elfring @ 2019-05-14  9:51 UTC (permalink / raw)
  To: Wen Yang; +Cc: Yi Wang, Michal Marek, Nicolas Palix, LKML, Coccinelle

> I did another experiment at that time and found that this modification will
> reduce the false positive rate,

Thanks for such feedback.

Will my update suggestion influence the current (or future) software situation?


> but it may also reduce the recall rate.

Would you like to explain this information a bit more?


> Could we use it to find out as many bugs as possible in the current kernel
> and then modify it?

I hope so.

* Will the false positive rate influence change acceptance considerably?

* Would you like to work with source code analysis approaches based on
  adjusted confidence settings?

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

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

* Re: [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction
  2019-05-13  8:59   ` [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction Markus Elfring
  2019-05-13  9:35     ` Julia Lawall
@ 2019-07-06 13:13     ` " Masahiro Yamada
  1 sibling, 0 replies; 41+ messages in thread
From: Masahiro Yamada @ 2019-07-06 13:13 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, Linux Kernel Mailing List,
	cocci, Wen Yang

On Mon, May 13, 2019 at 5:59 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> ---

Applied to linux-kbuild.


>  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
>
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci



-- 
Best Regards
Masahiro Yamada
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment
  2019-05-13  9:01   ` [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment Markus Elfring
  2019-05-13  9:33     ` Julia Lawall
@ 2019-07-06 13:13     ` Masahiro Yamada
  1 sibling, 0 replies; 41+ messages in thread
From: Masahiro Yamada @ 2019-07-06 13:13 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Yi Wang, Michal Marek, Nicolas Palix, Linux Kernel Mailing List,
	cocci, Wen Yang

On Mon, May 13, 2019 at 6:02 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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 <elfring@users.sourceforge.net>
> Suggested-by: Julia Lawall <Julia.Lawall@lip6.fr>
> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.1902160934400.3212@hadrien/
> Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005592.html
> ---

Applied to linux-kbuild.

>  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(&id->dev) ... }
>      when != e1 = (T)id
> -    when != e1 = &id->dev
> +    when != e1 = (T)(&id->dev)
>      when != e1 = get_device(&id->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



-- 
Best Regards
Masahiro Yamada
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, back to index

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23  6:14 [Cocci] [PATCH] coccinelle: put_device: reduce false positives Wen Yang
2019-03-23 13:41 ` Julia Lawall
2019-03-23 19:44 ` Markus Elfring
2019-03-23 20:06   ` Julia Lawall
2019-03-26  8:45     ` Dan Carpenter
2019-03-26  9:38       ` Julia Lawall
2019-03-26 10:11         ` Dan Carpenter
2019-03-26 10:15           ` Julia Lawall
2019-03-28 13:08             ` Masahiro Yamada
2019-03-28 14:19               ` Julia Lawall
2019-04-01  6:44               ` [Cocci] Coccinelle: " Markus Elfring
2019-04-01 20:04                 ` Julia Lawall
2019-05-13  8:55 ` [Cocci] [PATCH 0/5] Coccinelle: put_device: Adjustments for a SmPL script Markus Elfring
2019-05-13  8:59   ` [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction Markus Elfring
2019-05-13  9:35     ` Julia Lawall
2019-05-13 11:33       ` [Cocci] [1/5] " Markus Elfring
2019-05-13 11:36         ` Julia Lawall
2019-05-13 12:48           ` Markus Elfring
2019-07-06 13:13     ` [Cocci] [PATCH 1/5] " Masahiro Yamada
2019-05-13  9:01   ` [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment Markus Elfring
2019-05-13  9:33     ` Julia Lawall
2019-07-06 13:13     ` Masahiro Yamada
2019-05-13  9:05   ` [Cocci] [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one Markus Elfring
2019-05-13  9:32     ` Julia Lawall
2019-05-13 11:48       ` [Cocci] [3/5] " Markus Elfring
2019-05-13 11:48       ` Markus Elfring
2019-05-13 11:51         ` Julia Lawall
2019-05-13 12:52           ` Markus Elfring
2019-05-13  9:07   ` [Cocci] [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
2019-05-13  9:31     ` Julia Lawall
2019-05-13 12:22       ` [Cocci] [4/5] " Markus Elfring
2019-05-14  5:55       ` Markus Elfring
2019-05-14  6:52         ` Julia Lawall
2019-05-14  7:49           ` Markus Elfring
2019-05-14  9:18             ` [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses wen.yang99
2019-05-14  9:51               ` Markus Elfring
2019-05-14  7:49           ` [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses Markus Elfring
2019-05-13  9:07   ` [Cocci] [PATCH 4/5] " Markus Elfring
2019-05-13  9:10   ` [Cocci] [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one Markus Elfring
2019-05-13  9:30     ` Julia Lawall
2019-05-13 12:35       ` [Cocci] [5/5] " Markus Elfring

Coccinelle archive on lore.kernel.org

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

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


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


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