8dc1a951bafd5455c86eee64de7e04d7e0d9a348
[bpt/coccinelle.git] / parsing_cocci / test.cocci
1 // Copyright 2010, INRIA, University of Copenhagen
2 // Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
3 // Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
4 // Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
5 // This file is part of Coccinelle.
6 //
7 // Coccinelle is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, according to version 2 of the License.
10 //
11 // Coccinelle is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // The authors reserve the right to distribute this or future versions of
20 // Coccinelle under other licenses.
21
22
23 @@
24 struct SHT sht;
25 local function proc_info_func;
26 @@
27 sht.proc_info = proc_info_func;
28
29 @@
30 identifier buffer, start, offset, length, inout, hostptr, hostno;
31 @@
32 proc_info_func (
33 + struct Scsi_Host *hostptr,
34 char *buffer, char **start, off_t offset, int length,
35 - int hostno,
36 int inout) {
37 ...
38 - struct Scsi_Host *hostptr;
39 ...
40 - hostptr = scsi_host_hn_get(hostno);
41 ...
42 ?- if (!hostptr) { ... }
43 ...
44 ?- scsi_host_put(hostptr);
45 ...
46 }
47
48 @@
49 expression E;
50 @@
51 proc_info_func(...) {
52 <...
53 (
54 \+- E->host_no == hostno
55 + E == shpnt
56 |
57 - hostno
58 + shpnt->host_no
59 )
60 ...>
61 }
62
63 @@
64 struct foo E;
65 @@
66 proc_info_func(...) {
67 <...
68 (
69 \+- E->host_no == hostno
70 + E == shpnt
71 |
72 - hostno
73 + shpnt->host_no
74 )
75 ...>
76 }