coccinelle: put_device: reduce false positives
Subsystems (2)
PATCH 1/1 coccinelle: put_device: reduce false positives
Don't complain about a return when this function returns "&pdev->dev".
--- scripts/coccinelle/free/put_device.cocci | 1 + 1 file changed, 1 insertion(+)
scripts/coccinelle/free/put_device.cocci +1 -0
@@ -32,6 +32,7 @@ if (id == NULL || ...) { ... return ...; } ( id | (T2)dev_get_drvdata(&id->dev) | (T3)platform_get_drvdata(id) +| &id->dev ); | return@p2 ...; )
Signature · 1 line
2.9.5
Quoted 11 lines · Wen Yang
Don't complain about a return when this function returns "
&pdev->dev".Reported-by Julia Lawall <[email protected]>Signed-off-by Wen Yang <[email protected]>Cc Julia Lawall <[email protected]>Cc Gilles Muller <[email protected]>Cc Nicolas Palix <[email protected]>Cc Michal Marek <[email protected]>Cc Masahiro Yamada <[email protected]>
Quoted 20 lines
--- scripts/coccinelle/free/put_device.cocci | 1 + 1 file changed, 1 insertion(+)scripts/coccinelle/free/put_device.cocci +1
-1@@ -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
Quoted 1 line
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
Quoted 3 lines · Markus Elfring
Quoted 1 line
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
Quoted 6 lines · Julia Lawall
Quoted 2 lines · Markus Elfring
Quoted 1 line
Don't complain about a return when this function returns "
&pdev->dev".
Quoted 7 lines
Quoted 1 line
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
Quoted 9 lines · Dan Carpenter
Quoted 8 lines · Julia Lawall
Quoted 3 lines · Markus Elfring
Quoted 1 line
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?
Quoted 8 lines
Quoted 5 lines
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
Quoted 19 lines · Julia Lawall
Quoted 15 lines · Dan Carpenter
Quoted 13 lines · Julia Lawall
Quoted 3 lines · Markus Elfring
Quoted 1 line
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.
Quoted 6 lines
Quoted 2 lines
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
Quoted 27 lines · Dan Carpenter
Quoted 19 lines · Julia Lawall
Quoted 15 lines · Dan Carpenter
Quoted 13 lines · Julia Lawall
Quoted 3 lines · Markus Elfring
Quoted 1 line
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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 5 lines
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
Quoted 38 lines · Julia Lawall
Quoted 27 lines · Dan Carpenter
Quoted 19 lines · Julia Lawall
Quoted 15 lines · Dan Carpenter
Quoted 13 lines · Julia Lawall
Quoted 3 lines · Markus Elfring
Quoted 1 line
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.
Quoted 6 lines
Quoted 2 lines
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.
Quoted 5 lines
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".
Quoted 3 lines
OK, thanks.
julia
I added Fixes: tag,
and applied to linux-kbuild/fixes.
Thanks.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 39 lines · Masahiro Yamada
Quoted 38 lines · Julia Lawall
Quoted 32 lines · Dan Carpenter
Quoted 19 lines · Julia Lawall
Quoted 15 lines · Dan Carpenter
Quoted 13 lines · Julia Lawall
Quoted 3 lines · Markus Elfring
Quoted 1 line
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.
Quoted 6 lines
Quoted 2 lines
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".
Quoted 6 lines
Quoted 3 lines
OK, thanks.
julia
I added Fixes: tag,
and applied to linux-kbuild/fixes.
Thanks!
julia
Quoted 7 lines
Thanks.
--
Best Regards
Masahiro Yamada
Re: Coccinelle: put_device: reduce false positives
In reply to Masahiro YamadaQuoted 2 lines
I added Fixes: tag,
and applied to linux-kbuild/fixes.
Will this extension trigger further adjustments for similar SmPL scripts?
Regards,
Markus
Re: Coccinelle: put_device: reduce false positives
Quoted 7 lines · Markus Elfring
Quoted 2 lines
I added Fixes: tag,
and applied to linux-kbuild/fixes.Will this extension trigger further adjustments for similar SmPL scripts?
If there are false positives caused by this or other scripts, feel free to submit a patch.
julia
cover Coccinelle: put_device: Adjustments for a SmPL script
In reply to Wen YangSome 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
PATCH 1/5 Coccinelle: put_device: Adjust a message construction
From: Markus Elfring <[email protected]>
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.
--- scripts/coccinelle/free/put_device.cocci | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
scripts/coccinelle/free/put_device.cocci +4 -5
@@ -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 1/5] Coccinelle: put_device: Adjust a message construction
Quoted 8 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 May 2019 11:20:48 +0200The 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
Quoted 30 lines
Signed-off-by Markus Elfring <[email protected]>--- scripts/coccinelle/free/put_device.cocci | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)scripts/coccinelle/free/put_device.cocci +4
-6@@ -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: [1/5] Coccinelle: put_device: Adjust a message construction
Quoted 5 lines
Quoted 2 lines
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?
Quoted 2 lines
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: [1/5] Coccinelle: put_device: Adjust a message construction
Quoted 8 lines · Markus Elfring
Quoted 5 lines
Quoted 2 lines
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.
Quoted 5 lines
Quoted 2 lines
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
Quoted 4 lines
Regards,
Markus
Re: [1/5] Coccinelle: put_device: Adjust a message construction
Quoted 2 lines
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?
Quoted 2 lines
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
Re: [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction
In reply to Markus ElfringQuoted 4 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 May 2019 11:20:48 +0200
Quoted 8 lines
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 <[email protected]>---
Applied to linux-kbuild.
Quoted 30 lines
scripts/coccinelle/free/put_device.cocci | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)scripts/coccinelle/free/put_device.cocci +4
-6@@ -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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Signature · 6 lines
Best Regards Masahiro Yamada _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 2/5 Coccinelle: put_device: Add a cast to an expression for an assignment
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- scripts/coccinelle/free/put_device.cocci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coccinelle/free/put_device.cocci +1 -1
@@ -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
Re: [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment
Quoted 6 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 May 2019 13:50:49 +0200Extend a when constraint in a SmPL rule so that an additional cast is optionally excluded from source code searches for an expression in assignments.
Quoted 26 lines
Signed-off-by Markus Elfring <[email protected]>Suggested-by Julia Lawall <[email protected]>--- scripts/coccinelle/free/put_device.cocci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/coccinelle/free/put_device.cocci +1
-2@@ -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
Re: [Cocci] [PATCH 2/5] Coccinelle: put_device: Add a cast to an expression for an assignment
In reply to Markus ElfringQuoted 8 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 May 2019 13:50:49 +0200Extend a when constraint in a SmPL rule so that an additional cast is optionally excluded from source code searches for an expression in assignments.
Quoted 5 lines
Signed-off-by Markus Elfring <[email protected]>Suggested-by Julia Lawall <[email protected]>---
Applied to linux-kbuild.
Quoted 23 lines
scripts/coccinelle/free/put_device.cocci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/coccinelle/free/put_device.cocci +1
-2@@ -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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Signature · 6 lines
Best Regards Masahiro Yamada _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
PATCH 3/5 Coccinelle: put_device: Merge four SmPL when constraints into one
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- scripts/coccinelle/free/put_device.cocci | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
scripts/coccinelle/free/put_device.cocci +1 -4
@@ -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
Re: [PATCH 3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
Quoted 6 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 12 May 2019 18:32:46 +0200An 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
Quoted 26 lines
Signed-off-by Markus Elfring <[email protected]>--- scripts/coccinelle/free/put_device.cocci | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)scripts/coccinelle/free/put_device.cocci +1
-5@@ -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
Re: [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
Quoted 5 lines
Quoted 3 lines
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.
Quoted 1 line
This exceeds 80 characters
The line became 105 characters long.
14 space characters can eventually be omitted.
Quoted 1 line
and provides no readability benefit.
I try to stress SmPL functionality in this use case.
Quoted 10 lines
scripts/coccinelle/free/put_device.cocci if (id == NULL || ...) { ... return ...; } · line 26
Quoted 10 lines
+++
b/scripts/coccinelle/free/put_device.cocciscripts/coccinelle/free/put_device.cocci +1
-4@@ -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
Re: [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
In reply to Julia LawallQuoted 5 lines
Quoted 3 lines
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.
Quoted 1 line
This exceeds 80 characters
The line became 105 characters long.
14 space characters can eventually be omitted.
Quoted 1 line
and provides no readability benefit.
I try to stress SmPL functionality in this use case.
Quoted 10 lines
scripts/coccinelle/free/put_device.cocci if (id == NULL || ...) { ... return ...; } · line 26
Quoted 10 lines
+++
b/scripts/coccinelle/free/put_device.cocciscripts/coccinelle/free/put_device.cocci +1
-4@@ -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
Re: [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
Quoted 11 lines · Markus Elfring
Quoted 5 lines
Quoted 3 lines
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.
Quoted 1 line
This exceeds 80 characters
Quoted 7 lines
The line became 105 characters long.
14 space characters can eventually be omitted.Quoted 1 line
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.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
+++
b/scripts/coccinelle/free/put_device.cocciscripts/coccinelle/free/put_device.cocci +0
-1@@ -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
Quoted 8 lines
Quoted 4 lines
scripts/coccinelle/free/put_device.cocci if (id == NULL || ...) { ... return ...; } · line 26
Quoted 4 lines
scripts/coccinelle/free/put_device.cocci +1
-3- 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
Quoted 6 lines
How long will it take to reconsider corresponding software limitations?
Regards,
Markus
Re: [3/5] Coccinelle: put_device: Merge four SmPL when constraints into one
Quoted 5 lines
Quoted 1 line
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
PATCH 4/5 Coccinelle: put_device: Extend when constraints for two SmPL ellipses
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- scripts/coccinelle/free/put_device.cocci | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/coccinelle/free/put_device.cocci +4 -2
@@ -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
PATCH 4/5 Coccinelle: put_device: Extend when constraints for two SmPL ellipses
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- scripts/coccinelle/free/put_device.cocci | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/coccinelle/free/put_device.cocci +4 -2
@@ -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
Re: [PATCH 4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
Quoted 7 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 13 May 2019 09:47:17 +0200A 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.
Quoted 6 lines
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
Quoted 35 lines
Fixes da9cfb87a44da61f2403c4312916befcb6b6d7e8 ("coccinelle: semantic code search for missing put_device()")Signed-off-by Markus Elfring <[email protected]>--- scripts/coccinelle/free/put_device.cocci | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)scripts/coccinelle/free/put_device.cocci +4
-3@@ -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
Re: [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
Quoted 4 lines
Quoted 2 lines
Take additional casts for these code exclusion specifications into account together with optional parentheses.
NACK.
I find this rejection surprising.
Quoted 1 line
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
…
Quoted 1 line
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
Re: [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
In reply to Julia LawallQuoted 4 lines
Quoted 4 lines
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.
Quoted 8 lines
Quoted 6 lines
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?
Quoted 1 line
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.
Quoted 1 line
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
Re: [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
Quoted 13 lines · Markus Elfring
Quoted 4 lines
Quoted 4 lines
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.
Quoted 8 lines
Quoted 6 lines
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.
Quoted 7 lines
Can you agree to any information which I presented in the commit message?
Quoted 1 line
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 =
Quoted 9 lines
Quoted 3 lines
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.
Quoted 2 lines
* 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
Re: [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
Quoted 1 line
Quoted 1 line
Can you agree to any information which I presented in the commit message?
Do you find this description inappropriate?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
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.
Quoted 4 lines
Quoted 2 lines
* 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/[email protected]/
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?
Quoted 4 lines
Quoted 2 lines
* 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.
Quoted 1 line
Basically, if you have T && T, the two T's have to be the same,
Such an expectation might be logical.
Quoted 1 line
and T is not pure.
This information triggers various communication difficulties.
Quoted 1 line
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”.
Quoted 2 lines
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
Re: [Cocci] [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses
Quoted 17 lines
Subject: Re: [4/5] Coccinelle:
put_device: Extend when constraints for twoSmPL ellipsesQuoted 1 line
Quoted 1 line
Can you agree to any information which I presented in the commit message?
Do you find this description inappropriate?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
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.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
* 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/[email protected]/
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
Quoted 5 lines
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?
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [4/5] Coccinelle: put_device: Extend when constraints for twoSmPL ellipses
Quoted 2 lines
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?
Quoted 1 line
but it may also reduce the recall rate.
Would you like to explain this information a bit more?
Quoted 2 lines
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
Re: [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
In reply to [email protected]Quoted 1 line
Could we use it to find out as many bugs as possible in the current kernel
How do you think about to work with any more source code analysis approaches?
Quoted 1 line
and then modify it?
I guess that you do not need to wait for a solution so long.
Variables which get reassigned in unwanted ways (before the desired call of a resource release function in the discussed use case) can be found also with the help of the semantic patch language (Coccinelle software).
Regards,
Markus
Re: [4/5] Coccinelle: put_device: Extend when constraints for two SmPL ellipses
In reply to Julia LawallQuoted 1 line
Quoted 1 line
Can you agree to any information which I presented in the commit message?
Do you find this description inappropriate?
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
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.
Quoted 4 lines
Quoted 2 lines
* 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/[email protected]/
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?
Quoted 4 lines
Quoted 2 lines
* 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.
Quoted 1 line
Basically, if you have T && T, the two T's have to be the same,
Such an expectation might be logical.
Quoted 1 line
and T is not pure.
This information triggers various communication difficulties.
Quoted 1 line
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”.
Quoted 2 lines
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
PATCH 5/5 Coccinelle: put_device: Merge two SmPL when constraints into one
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
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.
--- scripts/coccinelle/free/put_device.cocci | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/coccinelle/free/put_device.cocci +1 -2
@@ -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
Re: [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one
Quoted 9 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 13 May 2019 09:55:22 +0200A 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 <[email protected]>
NACK. This hurts readability and gives no practical benefit.
julia
Quoted 22 lines
--- scripts/coccinelle/free/put_device.cocci | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)scripts/coccinelle/free/put_device.cocci +1
-3@@ -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
Re: [5/5] Coccinelle: put_device: Merge two SmPL when constraints into one
Quoted 2 lines
Quoted 2 lines
Combine the exclusion specifications into a disjunction for the semantic patch language so that this argument is referenced only once there.
…
Quoted 1 line
NACK. This hurts readability
I suggest to reconsider such readability concerns once more. Can corresponding software limitations be adjusted any further?
Quoted 1 line
and gives no practical benefit.
I guess that you know better which aspects can matter also here for software fine-tuning.
Quoted 8 lines
scripts/coccinelle/free/put_device.cocci id = of_find_device_by_node@p1(x) · line 25
Quoted 8 lines
+++
b/scripts/coccinelle/free/put_device.cocciscripts/coccinelle/free/put_device.cocci +1
-2@@ -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