[16/33] cocci: Split opencoded igt_(warn|fail|skip)_on_f rule out

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

Details

Message ID 20190610150321.512-16-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                     | 72 --------------------
 scripts/cocci/igt_fail_warn_skip_on_f.cocci | 75 +++++++++++++++++++++
 2 files changed, 75 insertions(+), 72 deletions(-)
 create mode 100644 scripts/cocci/igt_fail_warn_skip_on_f.cocci

Patch hide | download patch | download mbox

diff --git a/scripts/cocci/igt.cocci b/scripts/cocci/igt.cocci
index 8ba294cd..b11c46bd 100644
--- a/scripts/cocci/igt.cocci
+++ b/scripts/cocci/igt.cocci
@@ -31,78 +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 calls to igt_fail() with macro versions
-@depends on patch@
-expression Ec;
-expression list[n] Ep;
-@@
-- if (Ec) {
-(
-- igt_warn( Ep );
-|
-- igt_info( Ep );
-|
-- igt_debug( Ep );
-)
-- igt_fail(...);
-- }
-+ igt_fail_on_f(Ec, Ep);
-
-@opencode_log_then_fail_report depends on report@
-identifier func =~ "^igt_(warn|info|debug)$";
-position p;
-@@
-if (...) {
-  func@p(...);
-  igt_fail(...);
-}
-
-@script:python depends on report@
-p << opencode_log_then_fail_report.p;
-@@
-coccilib.report.print_report(p[0], "WARNING: igt_fail_on_f() should be used instead")
-
-@depends on patch@
-expression Ec;
-@@
-- if (Ec) {
-- igt_fail(...);
-- }
-+ igt_fail_on(Ec);
-
-@depends on patch@
-expression Ec;
-expression list[n] Ep;
-@@
-- if (Ec) {
-- igt_skip(Ep);
-- }
-+ igt_skip_on_f(Ec, Ep);
-
-@depends on patch@
-expression Ec;
-expression list[n] Ep;
-@@
-- if (Ec) {
-- igt_warn(Ep);
-- }
-+ igt_warn_on_f(Ec, Ep);
-
-@warn_skip_opencode_report depends on report@
-identifier func =~ "^igt_(warn|skip)$";
-position p;
-@@
-if (...) {
-  func@p(...);
-}
-
-@script:python depends on report@
-func << warn_skip_opencode_report.func;
-p << warn_skip_opencode_report.p;
-@@
-msg="WARNING: %s_on_f() should be used instead" % func
-coccilib.report.print_report(p[0], msg)
-
 // Enforce use of logging functions
 @depends on patch && !(file in "igt_core.c")@
 expression list[n] Ep;
diff --git a/scripts/cocci/igt_fail_warn_skip_on_f.cocci b/scripts/cocci/igt_fail_warn_skip_on_f.cocci
new file mode 100644
index 00000000..d506c98a
--- /dev/null
+++ b/scripts/cocci/igt_fail_warn_skip_on_f.cocci
@@ -0,0 +1,75 @@ 
+// Replace open coded calls to igt_fail() and friends with macro versions
+
+virtual report
+virtual patch
+
+@depends on patch@
+expression Ec;
+expression list[n] Ep;
+@@
+- if (Ec) {
+(
+- igt_warn( Ep );
+|
+- igt_info( Ep );
+|
+- igt_debug( Ep );
+)
+- igt_fail(...);
+- }
++ igt_fail_on_f(Ec, Ep);
+
+@opencode_log_then_fail_report depends on report@
+identifier func =~ "^igt_(warn|info|debug)$";
+position p;
+@@
+if (...) {
+  func@p(...);
+  igt_fail(...);
+}
+
+@script:python depends on report@
+p << opencode_log_then_fail_report.p;
+@@
+coccilib.report.print_report(p[0], "WARNING: igt_fail_on_f() should be used instead")
+
+@depends on patch@
+expression Ec;
+@@
+- if (Ec) {
+- igt_fail(...);
+- }
++ igt_fail_on(Ec);
+
+@depends on patch@
+expression Ec;
+expression list[n] Ep;
+@@
+- if (Ec) {
+- igt_skip(Ep);
+- }
++ igt_skip_on_f(Ec, Ep);
+
+@depends on patch@
+expression Ec;
+expression list[n] Ep;
+@@
+- if (Ec) {
+- igt_warn(Ep);
+- }
++ igt_warn_on_f(Ec, Ep);
+
+@warn_skip_opencode_report depends on report@
+identifier func =~ "^igt_(warn|skip)$";
+position p;
+@@
+if (...) {
+  func@p(...);
+}
+
+@script:python depends on report@
+func << warn_skip_opencode_report.func;
+p << warn_skip_opencode_report.p;
+@@
+msg="WARNING: %s_on_f() should be used instead" % func
+coccilib.report.print_report(p[0], msg)