aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-12-12 06:55:56 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-16 10:33:43 -0500
commitb825b4325354db65fd632b26ba585ced85f33902 (patch)
treef1ef3aa9fed67fb142a7eafe150cfdbd7ebaacc8
parent1d467bb8a8b95caa01a240362589215739505233 (diff)
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 <Julia.Lawall@lip6.fr> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--scripts/coccinelle/misc/boolinit.cocci31
1 files changed, 21 insertions, 10 deletions
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
13virtual org 13virtual org
14virtual report 14virtual report
15 15
16@boolok@
17symbol true,false;
18@@
19(
20true
21|
22false
23)
24
16@depends on patch@ 25@depends on patch@
17bool t; 26bool t;
18symbol true;
19symbol false;
20@@ 27@@
21 28
22( 29(
@@ -63,7 +70,7 @@ bool t;
63+ t 70+ t
64) 71)
65 72
66@depends on patch@ 73@depends on patch && boolok@
67bool b; 74bool b;
68@@ 75@@
69( 76(
@@ -116,19 +123,23 @@ position p;
116* t@p != 0 123* t@p != 0
117) 124)
118 125
119@r3 depends on !patch@ 126@r3 depends on !patch && boolok@
120bool b; 127bool b;
121position p1,p2; 128position p1;
122constant c;
123@@ 129@@
124( 130(
125*b@p1 = 0 131*b@p1 = 0
126| 132|
127*b@p1 = 1 133*b@p1 = 1
128|
129*b@p2 = c
130) 134)
131 135
136@r4 depends on !patch@
137bool b;
138position p2;
139constant c != {0,1};
140@@
141*b@p2 = c
142
132@script:python depends on org@ 143@script:python depends on org@
133p << r1.p; 144p << r1.p;
134@@ 145@@
@@ -148,7 +159,7 @@ p1 << r3.p1;
148cocci.print_main("WARNING: Assignment of bool to 0/1",p1) 159cocci.print_main("WARNING: Assignment of bool to 0/1",p1)
149 160
150@script:python depends on org@ 161@script:python depends on org@
151p2 << r3.p2; 162p2 << r4.p2;
152@@ 163@@
153 164
154cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) 165cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2)
@@ -172,7 +183,7 @@ p1 << r3.p1;
172coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1") 183coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1")
173 184
174@script:python depends on report@ 185@script:python depends on report@
175p2 << r3.p2; 186p2 << r4.p2;
176@@ 187@@
177 188
178coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") 189coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant")