Commit | Line | Data |
---|---|---|
951c7801 C |
1 | // |
2 | // open.cocci (based on kmalloc 7) | |
3 | // | |
4 | // | |
5 | ||
6 | virtual diff,org | |
7 | ||
8 | @r exists@ | |
9 | local idexpression x; | |
10 | statement S; | |
11 | expression E; | |
12 | identifier f,l; | |
13 | position p1,p2,p3; | |
14 | expression *ptr != NULL; | |
15 | @@ | |
16 | ||
17 | ( | |
18 | if ((x@p1 = \(open\|fopen\)(...)) == NULL) S | |
19 | | | |
20 | x@p1 = \(open\|fopen\)(...); | |
21 | ... | |
22 | if (x == NULL) S | |
23 | ) | |
24 | <... when != x | |
25 | when != if (...) { <+...x...+> } | |
26 | ( | |
27 | goto@p3 l; | |
28 | | | |
29 | x->f = E | |
30 | ) | |
31 | ...> | |
32 | ( | |
33 | return \(0\|<+...x...+>\|ptr\); | |
34 | | | |
35 | return@p2 ...; | |
36 | ) | |
37 | ||
38 | @script:python depends on org@ | |
39 | p1 << r.p1; | |
40 | p2 << r.p2; | |
41 | p3 << r.p3; | |
42 | @@ | |
43 | ||
44 | cocci.print_main("",p1) | |
45 | cocci.print_secs("", p2) | |
46 | cocci.print_secs("goto", p3) | |
47 | cocci.include_match(False) | |
48 | ||
49 | @script:python depends on org@ | |
50 | p1 << r.p1; | |
51 | p2 << r.p2; | |
52 | @@ | |
53 | ||
54 | cocci.print_main("",p1) | |
55 | cocci.print_secs("", p2) | |
56 | ||
57 | @with_goto depends on diff@ | |
58 | expression x; | |
59 | identifier l; | |
60 | position r.p1, r.p2, r.p3; | |
61 | @@ | |
62 | ||
63 | *x@p1 | |
9f8e26f4 | 64 | <... |
951c7801 | 65 | *goto@p3 l; |
9f8e26f4 | 66 | ...> |
951c7801 | 67 | *return@p2 ...; |