Coccinelle archive on lore.kernel.org
 help / Atom feed
* [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit
@ 2018-12-12 11:55 Julia Lawall
  2018-12-12 11:55 ` [Cocci] [PATCH 1/2] scripts: coccinelle: only suggest true/false in files that already use them Julia Lawall
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Julia Lawall @ 2018-12-12 11:55 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, Peter Zijlstra, Nicolas Palix, linux-kernel,
	Paul E . McKenney, cocci

Reduce the scope of the rule and improve the warning messages.

julia (2):
  scripts: coccinelle: only suggest true/false in files that already use
    them
  scripts: coccinelle: Correct warning message

 scripts/coccinelle/misc/boolinit.cocci | 43 +++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 16 deletions(-)

-- 
1.9.1

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

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

* [Cocci] [PATCH 1/2] scripts: coccinelle: only suggest true/false in files that already use them
  2018-12-12 11:55 [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Julia Lawall
@ 2018-12-12 11:55 ` Julia Lawall
  2018-12-12 11:55 ` [Cocci] [PATCH 2/2] scripts: coccinelle: Correct warning message Julia Lawall
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2018-12-12 11:55 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, Peter Zijlstra, Nicolas Palix, linux-kernel,
	Paul E . McKenney, cocci

Some code may overall use 0 and 1, so don't introduce occasional
uses of true and false in these cases.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
 scripts/coccinelle/misc/boolinit.cocci | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci
index b9abed4..1b44feb 100644
--- a/scripts/coccinelle/misc/boolinit.cocci
+++ b/scripts/coccinelle/misc/boolinit.cocci
@@ -13,10 +13,17 @@ virtual context
 virtual org
 virtual report
 
+@boolok@
+symbol true,false;
+@@
+(
+true
+|
+false
+)
+
 @depends on patch@
 bool t;
-symbol true;
-symbol false;
 @@
 
 (
@@ -63,7 +70,7 @@ bool t;
 + t
 )
 
-@depends on patch@
+@depends on patch && boolok@
 bool b;
 @@
 (
@@ -116,19 +123,23 @@ position p;
 * t@p != 0
 )
 
-@r3 depends on !patch@
+@r3 depends on !patch && boolok@
 bool b;
-position p1,p2;
-constant c;
+position p1;
 @@
 (
 *b@p1 = 0
 |
 *b@p1 = 1
-|
-*b@p2 = c
 )
 
+@r4 depends on !patch@
+bool b;
+position p2;
+constant c != {0,1};
+@@
+*b@p2 = c
+
 @script:python depends on org@
 p << r1.p;
 @@
@@ -148,7 +159,7 @@ p1 << r3.p1;
 cocci.print_main("WARNING: Assignment of bool to 0/1",p1)
 
 @script:python depends on org@
-p2 << r3.p2;
+p2 << r4.p2;
 @@
 
 cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2)
@@ -172,7 +183,7 @@ p1 << r3.p1;
 coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1")
 
 @script:python depends on report@
-p2 << r3.p2;
+p2 << r4.p2;
 @@
 
 coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant")
-- 
1.9.1

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

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

* [Cocci] [PATCH 2/2] scripts: coccinelle: Correct warning message
  2018-12-12 11:55 [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Julia Lawall
  2018-12-12 11:55 ` [Cocci] [PATCH 1/2] scripts: coccinelle: only suggest true/false in files that already use them Julia Lawall
@ 2018-12-12 11:55 ` Julia Lawall
  2018-12-12 16:46 ` [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Himanshu Jha
  2018-12-15 10:35 ` Masahiro Yamada
  3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2018-12-12 11:55 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, Peter Zijlstra, Nicolas Palix, linux-kernel,
	Paul E . McKenney, cocci

"Assignment" requires the assigned value before the place that
value is stored into.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
 scripts/coccinelle/misc/boolinit.cocci | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci
index 1b44feb..b0584a3 100644
--- a/scripts/coccinelle/misc/boolinit.cocci
+++ b/scripts/coccinelle/misc/boolinit.cocci
@@ -150,19 +150,19 @@ cocci.print_main("WARNING: Comparison to bool",p)
 p << r2.p;
 @@
 
-cocci.print_main("WARNING: Comparison of bool to 0/1",p)
+cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p)
 
 @script:python depends on org@
 p1 << r3.p1;
 @@
 
-cocci.print_main("WARNING: Assignment of bool to 0/1",p1)
+cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1)
 
 @script:python depends on org@
 p2 << r4.p2;
 @@
 
-cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2)
+cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2)
 
 @script:python depends on report@
 p << r1.p;
@@ -174,16 +174,16 @@ coccilib.report.print_report(p[0],"WARNING: Comparison to bool")
 p << r2.p;
 @@
 
-coccilib.report.print_report(p[0],"WARNING: Comparison of bool to 0/1")
+coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable")
 
 @script:python depends on report@
 p1 << r3.p1;
 @@
 
-coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1")
+coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable")
 
 @script:python depends on report@
 p2 << r4.p2;
 @@
 
-coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant")
+coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable")
-- 
1.9.1

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

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

* Re: [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit
  2018-12-12 11:55 [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Julia Lawall
  2018-12-12 11:55 ` [Cocci] [PATCH 1/2] scripts: coccinelle: only suggest true/false in files that already use them Julia Lawall
  2018-12-12 11:55 ` [Cocci] [PATCH 2/2] scripts: coccinelle: Correct warning message Julia Lawall
@ 2018-12-12 16:46 ` Himanshu Jha
  2018-12-15 10:35 ` Masahiro Yamada
  3 siblings, 0 replies; 5+ messages in thread
From: Himanshu Jha @ 2018-12-12 16:46 UTC (permalink / raw)
  To: Julia Lawall, yamada.masahiro
  Cc: Michal Marek, Peter Zijlstra, Nicolas Palix, linux-kernel,
	Paul E . McKenney, cocci

+Cc Masahiro Yamada

On Wed, Dec 12, 2018 at 12:55:55PM +0100, Julia Lawall wrote:
> Reduce the scope of the rule and improve the warning messages.
> 
> julia (2):
>   scripts: coccinelle: only suggest true/false in files that already use
>     them
>   scripts: coccinelle: Correct warning message
> 
>  scripts/coccinelle/misc/boolinit.cocci | 43 +++++++++++++++++++++-------------
>  1 file changed, 27 insertions(+), 16 deletions(-)
> 
> -- 
> 1.9.1
> 
> _______________________________________________
> Cocci mailing list
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci

-- 
Himanshu Jha
Undergraduate Student
Department of Electronics & Communication
Guru Tegh Bahadur Institute of Technology
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit
  2018-12-12 11:55 [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Julia Lawall
                   ` (2 preceding siblings ...)
  2018-12-12 16:46 ` [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Himanshu Jha
@ 2018-12-15 10:35 ` Masahiro Yamada
  3 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2018-12-15 10:35 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Michal Marek, Peter Zijlstra, Nicolas Palix,
	Linux Kernel Mailing List, Paul E . McKenney, cocci

On Wed, Dec 12, 2018 at 9:34 PM Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>
> Reduce the scope of the rule and improve the warning messages.
>
> julia (2):
>   scripts: coccinelle: only suggest true/false in files that already use
>     them
>   scripts: coccinelle: Correct warning message


Applied to linux-kbuild. Thanks!


>  scripts/coccinelle/misc/boolinit.cocci | 43 +++++++++++++++++++++-------------
>  1 file changed, 27 insertions(+), 16 deletions(-)
>
> --
> 1.9.1
>


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

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 11:55 [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Julia Lawall
2018-12-12 11:55 ` [Cocci] [PATCH 1/2] scripts: coccinelle: only suggest true/false in files that already use them Julia Lawall
2018-12-12 11:55 ` [Cocci] [PATCH 2/2] scripts: coccinelle: Correct warning message Julia Lawall
2018-12-12 16:46 ` [Cocci] [PATCH 0/2] scripts: coccinelle: Improve boolinit Himanshu Jha
2018-12-15 10:35 ` Masahiro Yamada

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