Coccinelle release 0.2.5-rc3
[bpt/coccinelle.git] / tests / null.cocci
1 // The first two rules only work when there is only one reference.
2
3 @@
4 expression *x;
5 type T;
6 expression e;
7 expression f;
8 @@
9 if(x == NULL) {
10 ... when != x = e
11 (
12 return x;
13 |
14 (
15 *x
16 |
17 *((T)x)
18 |
19 f(...,x,...)
20 |
21 f(...,(T)x,...)
22 )
23 )
24 ...
25 }
26
27 @@
28 expression *x;
29 type T;
30 expression e;
31 expression f;
32 statement S;
33 @@
34 if(x != NULL) S else {
35 ... when != x = e
36 (
37 return x;
38 |
39 (
40 *x
41 |
42 *((T)x)
43 |
44 f(...,x,...)
45 |
46 f(...,(T)x,...)
47 )
48 )
49 ...
50 }
51
52 @@
53 expression *x;
54 type T1, T2, T3;
55 expression e;
56 expression f;
57 statement S;
58 @@
59 x = (T1) kmalloc(...);
60 ... when != \( if(x == NULL) { ... return ...; } \| if(x == NULL) S else { ... return ...; } \| x = e; \)
61 (
62 return x;
63 |
64 (
65 *x
66 |
67 *((T2)x)
68 |
69 f(...,x,...)
70 |
71 f(...,(T3)x,...)
72 )
73 )