diff options
author | Dmitry Kalinkin <dmitry.kalinkin@gmail.com> | 2015-05-21 07:19:13 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2015-05-21 07:19:13 -0400 |
commit | 4c8f20bb8e0ba6eecf62958bbf0502a2dc445ce6 (patch) | |
tree | 7eac76954e0a70d555a8a75ebb13d7aef8b9d6d3 /scripts | |
parent | 74de120d8096f72bdf95aba7234428c798d931cd (diff) |
coccinelle: api: add vma_pages.cocci
This semantic patch replaces explicit computations of vma page count
with explicit function call.
Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/coccinelle/api/vma_pages.cocci | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/vma_pages.cocci b/scripts/coccinelle/api/vma_pages.cocci new file mode 100644 index 000000000000..3e52e11ea1dc --- /dev/null +++ b/scripts/coccinelle/api/vma_pages.cocci | |||
@@ -0,0 +1,60 @@ | |||
1 | /// | ||
2 | /// Use vma_pages function on vma object instead of explicit computation. | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Keywords: vma_pages vma | ||
6 | // Comment: Based on resource_size.cocci | ||
7 | |||
8 | virtual context | ||
9 | virtual patch | ||
10 | virtual org | ||
11 | virtual report | ||
12 | |||
13 | //---------------------------------------------------------- | ||
14 | // For context mode | ||
15 | //---------------------------------------------------------- | ||
16 | |||
17 | @r_context depends on context && !patch && !org && !report@ | ||
18 | struct vm_area_struct *vma; | ||
19 | @@ | ||
20 | |||
21 | * (vma->vm_end - vma->vm_start) >> PAGE_SHIFT | ||
22 | |||
23 | //---------------------------------------------------------- | ||
24 | // For patch mode | ||
25 | //---------------------------------------------------------- | ||
26 | |||
27 | @r_patch depends on !context && patch && !org && !report@ | ||
28 | struct vm_area_struct *vma; | ||
29 | @@ | ||
30 | |||
31 | - ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) | ||
32 | + vma_pages(vma) | ||
33 | |||
34 | //---------------------------------------------------------- | ||
35 | // For org mode | ||
36 | //---------------------------------------------------------- | ||
37 | |||
38 | @r_org depends on !context && !patch && (org || report)@ | ||
39 | struct vm_area_struct *vma; | ||
40 | position p; | ||
41 | @@ | ||
42 | |||
43 | (vma->vm_end@p - vma->vm_start) >> PAGE_SHIFT | ||
44 | |||
45 | @script:python depends on report@ | ||
46 | p << r_org.p; | ||
47 | x << r_org.vma; | ||
48 | @@ | ||
49 | |||
50 | msg="WARNING: Consider using vma_pages helper on %s" % (x) | ||
51 | coccilib.report.print_report(p[0], msg) | ||
52 | |||
53 | @script:python depends on org@ | ||
54 | p << r_org.p; | ||
55 | x << r_org.vma; | ||
56 | @@ | ||
57 | |||
58 | msg="WARNING: Consider using vma_pages helper on %s" % (x) | ||
59 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
60 | coccilib.org.print_todo(p[0], msg_safe) | ||