0001 // SPDX-License-Identifier: GPL-2.0
0002 ///
0003 /// Use vma_pages function on vma object instead of explicit computation.
0004 ///
0005 // Confidence: High
0006 // Keywords: vma_pages vma
0007 // Comment: Based on resource_size.cocci
0008
0009 virtual context
0010 virtual patch
0011 virtual org
0012 virtual report
0013
0014 //----------------------------------------------------------
0015 // For context mode
0016 //----------------------------------------------------------
0017
0018 @r_context depends on context && !patch && !org && !report@
0019 struct vm_area_struct *vma;
0020 @@
0021
0022 * (vma->vm_end - vma->vm_start) >> PAGE_SHIFT
0023
0024 //----------------------------------------------------------
0025 // For patch mode
0026 //----------------------------------------------------------
0027
0028 @r_patch depends on !context && patch && !org && !report@
0029 struct vm_area_struct *vma;
0030 @@
0031
0032 - ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT)
0033 + vma_pages(vma)
0034
0035 //----------------------------------------------------------
0036 // For org mode
0037 //----------------------------------------------------------
0038
0039 @r_org depends on !context && !patch && (org || report)@
0040 struct vm_area_struct *vma;
0041 position p;
0042 @@
0043
0044 (vma->vm_end@p - vma->vm_start) >> PAGE_SHIFT
0045
0046 @script:python depends on report@
0047 p << r_org.p;
0048 x << r_org.vma;
0049 @@
0050
0051 msg="WARNING: Consider using vma_pages helper on %s" % (x)
0052 coccilib.report.print_report(p[0], msg)
0053
0054 @script:python depends on org@
0055 p << r_org.p;
0056 x << r_org.vma;
0057 @@
0058
0059 msg="WARNING: Consider using vma_pages helper on %s" % (x)
0060 msg_safe=msg.replace("[","@(").replace("]",")")
0061 coccilib.org.print_todo(p[0], msg_safe)