mfd: wm8350-i2c: Make sure the i2c regmap functions are compiled
[linux/fpc-iii.git] / scripts / coccinelle / misc / memcpy-assign.cocci
blobafd058be497fbfcd95bdce249095100533f998bc
1 //
2 // Replace memcpy with struct assignment.
3 //
4 // Confidence: High
5 // Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6.  GPLv2.
6 // URL: http://coccinelle.lip6.fr/
7 // Comments:
8 // Options: --no-includes --include-headers
10 virtual patch
11 virtual report
12 virtual context
13 virtual org
15 @r1 depends on !patch@
16 identifier struct_name;
17 struct struct_name to;
18 struct struct_name from;
19 struct struct_name *top;
20 struct struct_name *fromp;
21 position p;
23 memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\))
25 @script:python depends on report@
26 p << r1.p;
28 coccilib.report.print_report(p[0],"Replace memcpy with struct assignment")
30 @depends on context@
31 position r1.p;
33 *memcpy@p(...);
35 @script:python depends on org@
36 p << r1.p;
38 cocci.print_main("Replace memcpy with struct assignment",p)
40 @depends on patch@
41 identifier struct_name;
42 struct struct_name to;
43 struct struct_name from;
46 -memcpy(&(to), &(from), sizeof(to));
47 +to = from;
49 -memcpy(&(to), &(from), sizeof(from));
50 +to = from;
52 -memcpy(&(to), &(from), sizeof(struct struct_name));
53 +to = from;
56 @depends on patch@
57 identifier struct_name;
58 struct struct_name to;
59 struct struct_name *from;
62 -memcpy(&(to), from, sizeof(to));
63 +to = *from;
65 -memcpy(&(to), from, sizeof(*from));
66 +to = *from;
68 -memcpy(&(to), from, sizeof(struct struct_name));
69 +to = *from;
72 @depends on patch@
73 identifier struct_name;
74 struct struct_name *to;
75 struct struct_name from;
78 -memcpy(to, &(from), sizeof(*to));
79 + *to = from;
81 -memcpy(to, &(from), sizeof(from));
82 + *to = from;
84 -memcpy(to, &(from), sizeof(struct struct_name));
85 + *to = from;
88 @depends on patch@
89 identifier struct_name;
90 struct struct_name *to;
91 struct struct_name *from;
94 -memcpy(to, from, sizeof(*to));
95 + *to = *from;
97 -memcpy(to, from, sizeof(*from));
98 + *to = *from;
100 -memcpy(to, from, sizeof(struct struct_name));
101 + *to = *from;