[PATCH i-g-t 19/33] cocci: Split out for_each_pipe() rules

Lyude lyude at redhat.com
Mon Jun 10 15:03:07 UTC 2019


From: Lyude Paul <lyude at redhat.com>

Signed-off-by: Lyude Paul <lyude at 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

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/*
- at ignore_internal_abort depends on file in "tests/"@
-position p;
-@@
-void __igt_fail_assert(...) { <... abort at p(); ...> }
-
- at depends on patch && file in "tests/"@
-position p != ignore_internal_abort.p;
-@@
--abort at p();
-+igt_fail(IGT_EXIT_FAILURE);
-
- at abort_report depends on report && file in "tests/"@
-position p != ignore_internal_abort.p;
-@@
-abort at p();
-
- at 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)
-
- at 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) {
-...
-}
-
- at 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 { ... }
-
- at 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
+
+ at 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) {
+...
+}
+
+ at 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 { ... }
+
+ at 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")
-- 
2.21.0



More information about the Intel-gfx-trybot mailing list