[19/33] cocci: Split out for_each_pipe() rules

Submitted by Lyude Paul on June 7, 2019, 11:08 p.m.

Details

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

Not browsing as part of any series.

Commit Message

Lyude Paul June 7, 2019, 11:08 p.m.
From: Lyude Paul <lyude@redhat.com>

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

Patch hide | download patch | download mbox

diff --git a/scripts/cocci/igt.cocci b/scripts/cocci/igt.cocci
index ffdf67d3..4628e3ab 100644
--- a/scripts/cocci/igt.cocci
+++ b/scripts/cocci/igt.cocci
@@ -31,52 +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)
 
-// No abort for tests, really. Should only be used for internal library checks
-// in lib/*
-@ignore_internal_abort depends on file in "tests/"@
-position p;
-@@
-void __igt_fail_assert(...) { <... abort@p(); ...> }
-
-@depends on patch && file in "tests/"@
-position p != ignore_internal_abort.p;
-@@
--abort@p();
-+igt_fail(IGT_EXIT_FAILURE);
-
-@abort_report depends on report && file in "tests/"@
-position p != ignore_internal_abort.p;
-@@
-abort@p();
-
-@script:python depends on report@
-p << abort_report.p;
-@@
-msg="WARNING: abort() is not allowed, use igt_fail(IGT_EXIT_FAILURE) instead"
-coccilib.report.print_report(p[0], msg)
-
-@depends on patch@
-iterator name for_each_pipe;
-igt_display_t *display;
-expression pipe;
-@@
-- for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++) {
-+ for_each_pipe (display, pipe) {
-...
-}
-
-@for_each_pipe_report depends on report@
-igt_display *display;
-expression pipe;
-position p;
-@@
-for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++)@p { ... }
-
-@script:python depends on report@
-p << for_each_pipe_report.p;
-@@
-coccilib.report.print_report(p[0], "WARNING: for_each_pipe() should be used instead")
-
 // Tests and test libraries really shouldn't use plain assert!
 @depends on report && file in "tests/"@
 expression E;
diff --git a/scripts/cocci/igt_for_each_pipe.cocci b/scripts/cocci/igt_for_each_pipe.cocci
new file mode 100644
index 00000000..89d059d4
--- /dev/null
+++ b/scripts/cocci/igt_for_each_pipe.cocci
@@ -0,0 +1,26 @@ 
+// Enforce usage of for_each_pipe() iterator macro
+
+virtual report
+virtual patch
+
+@depends on patch@
+iterator name for_each_pipe;
+igt_display_t *display;
+expression pipe;
+@@
+- for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++) {
++ for_each_pipe (display, pipe) {
+...
+}
+
+@for_each_pipe_report depends on report@
+igt_display *display;
+expression pipe;
+position p;
+@@
+for (pipe = 0; pipe < igt_display_get_n_pipes(display); pipe++)@p { ... }
+
+@script:python depends on report@
+p << for_each_pipe_report.p;
+@@
+coccilib.report.print_report(p[0], "WARNING: for_each_pipe() should be used instead")