diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2018-12-12 06:55:56 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-12-16 10:33:43 -0500 |
commit | b825b4325354db65fd632b26ba585ced85f33902 (patch) | |
tree | f1ef3aa9fed67fb142a7eafe150cfdbd7ebaacc8 | |
parent | 1d467bb8a8b95caa01a240362589215739505233 (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.cocci | 31 |
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 | |||
13 | virtual org | 13 | virtual org |
14 | virtual report | 14 | virtual report |
15 | 15 | ||
16 | @boolok@ | ||
17 | symbol true,false; | ||
18 | @@ | ||
19 | ( | ||
20 | true | ||
21 | | | ||
22 | false | ||
23 | ) | ||
24 | |||
16 | @depends on patch@ | 25 | @depends on patch@ |
17 | bool t; | 26 | bool t; |
18 | symbol true; | ||
19 | symbol 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@ |
67 | bool b; | 74 | bool 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@ |
120 | bool b; | 127 | bool b; |
121 | position p1,p2; | 128 | position p1; |
122 | constant 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@ | ||
137 | bool b; | ||
138 | position p2; | ||
139 | constant c != {0,1}; | ||
140 | @@ | ||
141 | *b@p2 = c | ||
142 | |||
132 | @script:python depends on org@ | 143 | @script:python depends on org@ |
133 | p << r1.p; | 144 | p << r1.p; |
134 | @@ | 145 | @@ |
@@ -148,7 +159,7 @@ p1 << r3.p1; | |||
148 | cocci.print_main("WARNING: Assignment of bool to 0/1",p1) | 159 | cocci.print_main("WARNING: Assignment of bool to 0/1",p1) |
149 | 160 | ||
150 | @script:python depends on org@ | 161 | @script:python depends on org@ |
151 | p2 << r3.p2; | 162 | p2 << r4.p2; |
152 | @@ | 163 | @@ |
153 | 164 | ||
154 | cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) | 165 | cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) |
@@ -172,7 +183,7 @@ p1 << r3.p1; | |||
172 | coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1") | 183 | coccilib.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@ |
175 | p2 << r3.p2; | 186 | p2 << r4.p2; |
176 | @@ | 187 | @@ |
177 | 188 | ||
178 | coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") | 189 | coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") |