[21/33] cocci: Split out igt_swap() rules

Submitted by Lyude Paul on June 10, 2019, 3:03 p.m.

Details

Message ID 20190610150321.512-21-lyude@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in IGT - Trybot

Not browsing as part of any series.

Commit Message

Lyude Paul June 10, 2019, 3:03 p.m.
From: Lyude Paul <lyude@redhat.com>

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 scripts/cocci/igt.cocci      | 27 ---------------------------
 scripts/cocci/igt_swap.cocci | 30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 27 deletions(-)
 create mode 100644 scripts/cocci/igt_swap.cocci

Patch hide | download patch | download mbox

diff --git a/scripts/cocci/igt.cocci b/scripts/cocci/igt.cocci
index 84df03ca..ef3a5a40 100644
--- a/scripts/cocci/igt.cocci
+++ b/scripts/cocci/igt.cocci
@@ -31,33 +31,6 @@  def warn_cmp_macro(p, type_prefix, op, e1, e2):
     msg = 'WARNING: igt_assert_%s%s(%s, %s) should be used instead' % args
     coccilib.report.print_report(p[0], msg)
 
-// Replace open-coded igt_swap()
-@depends on patch@
-type T;
-T a, b, tmp;
-@@
-- tmp = a;
-- a = b;
-- b = tmp;
-+ igt_swap(a, b);
-
-@igt_swap_report depends on report@
-position p;
-type T;
-T a, b, tmp;
-@@
-tmp = a;
-a = b;
-b = tmp@p;
-
-@script:python depends on report@
-p << igt_swap_report.p;
-a << igt_swap_report.a;
-b << igt_swap_report.b;
-@@
-msg = "WARNING: igt_swap(%s, %s) should be used instead" % (a, b)
-coccilib.report.print_report(p[0], msg)
-
 // So we don't complain about #define min(), #define max(), etc.
 @min_max_ignore@
 identifier i =~ "^m(in|ax)$";
diff --git a/scripts/cocci/igt_swap.cocci b/scripts/cocci/igt_swap.cocci
new file mode 100644
index 00000000..9601bfb7
--- /dev/null
+++ b/scripts/cocci/igt_swap.cocci
@@ -0,0 +1,30 @@ 
+// Replace open-coded igt_swap()
+
+virtual report
+virtual patch
+
+@depends on patch@
+type T;
+T a, b, tmp;
+@@
+- tmp = a;
+- a = b;
+- b = tmp;
++ igt_swap(a, b);
+
+@igt_swap_report depends on report@
+position p;
+type T;
+T a, b, tmp;
+@@
+tmp = a;
+a = b;
+b = tmp@p;
+
+@script:python depends on report@
+p << igt_swap_report.p;
+a << igt_swap_report.a;
+b << igt_swap_report.b;
+@@
+msg = "WARNING: igt_swap(%s, %s) should be used instead" % (a, b)
+coccilib.report.print_report(p[0], msg)