1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Bool initializations should use true and false. Bool tests don't need
3 /// comparisons. Based on contributions from Joe Perches, Rusty Russell
7 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
8 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
9 // URL: http://coccinelle.lip6.fr/
10 // Options: --include-headers
56 @depends on patch disable is_zero, isnt_zero@
74 @depends on patch && boolok@
87 // ---------------------------------------------------------------------
89 @r1 depends on !patch@
112 @r2 depends on !patch disable is_zero, isnt_zero@
127 @r3 depends on !patch && boolok@
137 @r4 depends on !patch@
149 @script:python depends on org@
153 cocci.print_main("WARNING: Comparison to bool",p)
155 @script:python depends on org@
159 cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p)
161 @script:python depends on org@
165 cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1)
167 @script:python depends on org@
171 cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2)
173 @script:python depends on report@
177 coccilib.report.print_report(p[0],"WARNING: Comparison to bool")
179 @script:python depends on report@
183 coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable")
185 @script:python depends on report@
189 coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable")
191 @script:python depends on report@
195 coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable")