Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 589b38626859682dda0b4289ae4806af > files > 219

coccinelle-examples-1.0.7-2.mga7.i586.rpm

// - if(copy_from_user(&x, arg))   does not work. 
// the if-isomorphism does not work :(

@@ 
type T; 
identifier x, fld, arg;
function ioctl; // should be caracterised by another rule
@@


 ioctl(..., void *arg, ...) {
 <...
- T x;
+ T *x = arg;
 ...
- if(copy_from_user(&x, arg)!=0) 
- { ... return ...; } 
 <...
(
- x.fld
+ x->fld
| 
- &x
+ x
)
 ...>
- if(copy_to_user(arg, &x))
- { ... return ...; }
 ...>
 }