Skip to content

Commit

Permalink
scripts: coccinelle: only suggest true/false in files that already us…
Browse files Browse the repository at this point in the history
…e 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 <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
JuliaLawall authored and masahir0y committed Dec 16, 2018
1 parent 1d467bb commit b825b43
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions scripts/coccinelle/misc/boolinit.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -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;
@@

(
Expand Down Expand Up @@ -63,7 +70,7 @@ bool t;
+ t
)

@depends on patch@
@depends on patch && boolok@
bool b;
@@
(
Expand Down Expand Up @@ -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;
@@
Expand All @@ -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)
Expand All @@ -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")

0 comments on commit b825b43

Please sign in to comment.