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