Release coccinelle-0.1.1
[bpt/coccinelle.git] / tests / ioctl.cocci
CommitLineData
34e49164
C
1@fn@
2identifier xyz_ioctl;
3identifier xyz_ops;
4@@
5
6struct file_operations xyz_ops = {
7 .ioctl = xyz_ioctl,
8};
9
10@safe@
11identifier fn.xyz_ioctl;
12identifier i;
13@@
14
15static int xyz_ioctl(struct inode *i, ...)
16{
17 ... when != i
18}
19
20@count disable braces1, braces2, braces3, braces4@
21identifier fn.xyz_ioctl;
22statement S;
23@@
24
25int 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@
38identifier fn.xyz_ioctl;
39identifier i, f, cmd, arg;
40identifier ret;
41constant cret;
42statement 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@
62identifier fn.xyz_ioctl;
63expression 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@
74identifier xyz_ioctl;
75identifier xyz_ops;
76@@
77
78struct file_operations xyz_ops = {
79- .ioctl = xyz_ioctl,
80+ .unlocked_ioctl = xyz_ioctl,
81};