From b825b4325354db65fd632b26ba585ced85f33902 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 12 Dec 2018 12:55:56 +0100 Subject: scripts: coccinelle: only suggest true/false in files that already use them 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 Signed-off-by: Masahiro Yamada --- scripts/coccinelle/misc/boolinit.cocci | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci index b9abed49cd95..1b44feb7926c 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") -- cgit v1.2.3 From 518d8a5644197abd3d5efb23c71afff25194da7e Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 12 Dec 2018 12:55:57 +0100 Subject: scripts: coccinelle: Correct warning message "Assignment" requires the assigned value before the place that value is stored into. Signed-off-by: Julia Lawall Signed-off-by: Masahiro Yamada --- scripts/coccinelle/misc/boolinit.cocci | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci index 1b44feb7926c..b0584a33c921 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") -- cgit v1.2.3