coccinelle release 0.2.5
[bpt/coccinelle.git] / tests / ioctl.cocci
1 @fn@
2 identifier xyz_ioctl;
3 identifier xyz_ops;
4 @@
5
6 struct file_operations xyz_ops = {
7 .ioctl = xyz_ioctl,
8 };
9
10 @safe@
11 identifier fn.xyz_ioctl;
12 identifier i;
13 @@
14
15 static int xyz_ioctl(struct inode *i, ...)
16 {
17 ... when != i
18 }
19
20 @count disable braces1, braces2, braces3, braces4@
21 identifier fn.xyz_ioctl;
22 statement S;
23 @@
24
25 int xyz_ioctl(...) {
26 <+...
27 (
28 {
29 ... when strict
30 return ...; }
31 |
32 if (...) return ...; else S
33 )
34 ...+>
35 }
36
37 @one depends on safe && !count@
38 identifier fn.xyz_ioctl;
39 identifier i, f, cmd, arg;
40 identifier ret;
41 constant cret;
42 statement S,S1;
43 @@
44
45 -xyz_ioctl(struct inode *i, struct file *f, unsigned cmd, unsigned long arg)
46 +xyz_ioctl(struct file *f, unsigned cmd, unsigned long arg)
47 {
48 ... when != S1
49 + lock_kernel();
50 S
51 ...
52 (
53 + unlock_kernel();
54 return ret;
55 |
56 + unlock_kernel();
57 return cret;
58 )
59 }
60
61 @call depends on one@
62 identifier fn.xyz_ioctl;
63 expression E1, E2, E3, E4;
64 @@
65
66 - xyz_ioctl(E1, E2, E3, E4)
67 + xyz_ioctl(E2, E3, E4)
68
69
70 // be sure the changes can be made before transforming
71 // prototype has to be more complicated, because unsigned int can be
72 // just unsigned
73 @decl depends on one@
74 identifier xyz_ioctl;
75 identifier xyz_ops;
76 @@
77
78 struct file_operations xyz_ops = {
79 - .ioctl = xyz_ioctl,
80 + .unlocked_ioctl = xyz_ioctl,
81 };