diff options
author | Peter Senna Tschudin <peter.senna@gmail.com> | 2014-03-18 17:11:32 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2014-03-29 16:35:09 -0400 |
commit | 0a830dad5e3ceffc1f12f3e674322182d809e3a9 (patch) | |
tree | 6e3634d5057b50a675a793cc9e3caa0299aebc1c /scripts/coccinelle | |
parent | ae63b2d7bdd9bd66b88843be0daf8e37d8f0b574 (diff) |
Coccicheck: Remove memcpy to struct assignment test
The Coccinelle script scripts/coccinelle/misc/memcpy-assign.cocci look
for opportunities to replace a call to memcpy by a struct assignment.
This patch removes memcpy-assign.cocci as it is not clear that this
convention has an impact on the generated code.
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r-- | scripts/coccinelle/misc/memcpy-assign.cocci | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/scripts/coccinelle/misc/memcpy-assign.cocci b/scripts/coccinelle/misc/memcpy-assign.cocci deleted file mode 100644 index afd058be497f..000000000000 --- a/scripts/coccinelle/misc/memcpy-assign.cocci +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
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 | ||
9 | |||
10 | virtual patch | ||
11 | virtual report | ||
12 | virtual context | ||
13 | virtual org | ||
14 | |||
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; | ||
22 | @@ | ||
23 | memcpy@p(\(&(to)\|top\), \(&(from)\|fromp\), \(sizeof(to)\|sizeof(from)\|sizeof(struct struct_name)\|sizeof(*top)\|sizeof(*fromp)\)) | ||
24 | |||
25 | @script:python depends on report@ | ||
26 | p << r1.p; | ||
27 | @@ | ||
28 | coccilib.report.print_report(p[0],"Replace memcpy with struct assignment") | ||
29 | |||
30 | @depends on context@ | ||
31 | position r1.p; | ||
32 | @@ | ||
33 | *memcpy@p(...); | ||
34 | |||
35 | @script:python depends on org@ | ||
36 | p << r1.p; | ||
37 | @@ | ||
38 | cocci.print_main("Replace memcpy with struct assignment",p) | ||
39 | |||
40 | @depends on patch@ | ||
41 | identifier struct_name; | ||
42 | struct struct_name to; | ||
43 | struct struct_name from; | ||
44 | @@ | ||
45 | ( | ||
46 | -memcpy(&(to), &(from), sizeof(to)); | ||
47 | +to = from; | ||
48 | | | ||
49 | -memcpy(&(to), &(from), sizeof(from)); | ||
50 | +to = from; | ||
51 | | | ||
52 | -memcpy(&(to), &(from), sizeof(struct struct_name)); | ||
53 | +to = from; | ||
54 | ) | ||
55 | |||
56 | @depends on patch@ | ||
57 | identifier struct_name; | ||
58 | struct struct_name to; | ||
59 | struct struct_name *from; | ||
60 | @@ | ||
61 | ( | ||
62 | -memcpy(&(to), from, sizeof(to)); | ||
63 | +to = *from; | ||
64 | | | ||
65 | -memcpy(&(to), from, sizeof(*from)); | ||
66 | +to = *from; | ||
67 | | | ||
68 | -memcpy(&(to), from, sizeof(struct struct_name)); | ||
69 | +to = *from; | ||
70 | ) | ||
71 | |||
72 | @depends on patch@ | ||
73 | identifier struct_name; | ||
74 | struct struct_name *to; | ||
75 | struct struct_name from; | ||
76 | @@ | ||
77 | ( | ||
78 | -memcpy(to, &(from), sizeof(*to)); | ||
79 | + *to = from; | ||
80 | | | ||
81 | -memcpy(to, &(from), sizeof(from)); | ||
82 | + *to = from; | ||
83 | | | ||
84 | -memcpy(to, &(from), sizeof(struct struct_name)); | ||
85 | + *to = from; | ||
86 | ) | ||
87 | |||
88 | @depends on patch@ | ||
89 | identifier struct_name; | ||
90 | struct struct_name *to; | ||
91 | struct struct_name *from; | ||
92 | @@ | ||
93 | ( | ||
94 | -memcpy(to, from, sizeof(*to)); | ||
95 | + *to = *from; | ||
96 | | | ||
97 | -memcpy(to, from, sizeof(*from)); | ||
98 | + *to = *from; | ||
99 | | | ||
100 | -memcpy(to, from, sizeof(struct struct_name)); | ||
101 | + *to = *from; | ||
102 | ) | ||
103 | |||