2 // Replace memcpy with struct assignment.
5 // Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. GPLv2.
6 // URL: http://coccinelle.lip6.fr/
8 // Options: --no-includes --include-headers
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;
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@
28 coccilib.report.print_report(p[0],"Replace memcpy with struct assignment")
35 @script:python depends on org@
38 cocci.print_main("Replace memcpy with struct assignment",p)
41 identifier struct_name;
42 struct struct_name to;
43 struct struct_name from;
46 -memcpy(&(to), &(from), sizeof(to));
49 -memcpy(&(to), &(from), sizeof(from));
52 -memcpy(&(to), &(from), sizeof(struct struct_name));
57 identifier struct_name;
58 struct struct_name to;
59 struct struct_name *from;
62 -memcpy(&(to), from, sizeof(to));
65 -memcpy(&(to), from, sizeof(*from));
68 -memcpy(&(to), from, sizeof(struct struct_name));
73 identifier struct_name;
74 struct struct_name *to;
75 struct struct_name from;
78 -memcpy(to, &(from), sizeof(*to));
81 -memcpy(to, &(from), sizeof(from));
84 -memcpy(to, &(from), sizeof(struct struct_name));
89 identifier struct_name;
90 struct struct_name *to;
91 struct struct_name *from;
94 -memcpy(to, from, sizeof(*to));
97 -memcpy(to, from, sizeof(*from));
100 -memcpy(to, from, sizeof(struct struct_name));