Messages in this thread | | | From | Julia Lawall <> | Subject | [PATCH 0/7] adjust suspicious bit operation | Date | Wed, 6 Jun 2012 23:41:34 +0200 |
| |
These patches relate to conditional tests where & is used with a constant that is always 0 and where | is used with a constant that is always 0 or always non-zero.
The following semantic match finds these problems (http://coccinelle.lip6.fr/):
@and@ identifier i; expression e; position p; @@
((e & i@p) && ...)
@iszera@ identifier and.i; position p; @@
#define i 0
@othera@ identifier and.i; expression e!=0; @@
#define i e
@script:python depends on iszera && !othera@ p << and.p; @@
cocci.print_main("",p)
@or@ identifier i; expression e; position p; @@
((e | i@p) && ...)
@iszero@ identifier or.i; position p; @@
#define i 0
@othero@ identifier or.i; expression e!=0; @@
#define i e
@script:python depends on (othero && !iszero) || (iszero && !othero)@ p << or.p; @@
cocci.print_main("",p)
| |