[17/33] cocci: Split out igt logging function rules

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

Details

Message ID 20190610150321.512-17-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               | 40 -------------------------
 scripts/cocci/igt_logging_funcs.cocci | 43 +++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 40 deletions(-)
 create mode 100644 scripts/cocci/igt_logging_funcs.cocci

Patch hide | download patch | download mbox

diff --git a/scripts/cocci/igt.cocci b/scripts/cocci/igt.cocci
index b11c46bd..ffdf67d3 100644
--- a/scripts/cocci/igt.cocci
+++ b/scripts/cocci/igt.cocci
@@ -31,46 +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)
 
-// Enforce use of logging functions
-@depends on patch && !(file in "igt_core.c")@
-expression list[n] Ep;
-@@
-(
-- \( fprintf(stderr, Ep) \| perror(Ep) \);
-+ igt_warn(Ep);
-|
-- \( fprintf(stdout, Ep) \| printf(Ep) \);
-+ igt_info(Ep);
-)
-
-@no_fprintf_report depends on report && !(file in "igt_core.c")@
-position p;
-identifier i =~ "^std(out|err)$";
-@@
-fprintf@p(i, ...);
-
-@script:python depends on report@
-p << no_fprintf_report.p;
-i << no_fprintf_report.i;
-@@
-should_use = "igt_info" if i == "stdout" else "igt_warn"
-msg = "WARNING: %s() should be used instead" % should_use
-coccilib.report.print_report(p[0], msg)
-
-@no_printf_perror_report depends on report && !(file in "igt_core.c")@
-position p;
-identifier func =~ "^p(rintf|error)$";
-@@
-func@p(...);
-
-@script:python depends on report@
-p << no_printf_perror_report.p;
-func << no_printf_perror_report.func;
-@@
-should_use = "igt_info" if func == "printf" else "igt_warn"
-msg = "WARNING: %s() should be used instead" % should_use
-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/"@
diff --git a/scripts/cocci/igt_logging_funcs.cocci b/scripts/cocci/igt_logging_funcs.cocci
new file mode 100644
index 00000000..01a6d002
--- /dev/null
+++ b/scripts/cocci/igt_logging_funcs.cocci
@@ -0,0 +1,43 @@ 
+// Enforce usage of logging functions
+
+virtual report
+virtual patch
+
+@depends on patch && !(file in "igt_core.c")@
+expression list[n] Ep;
+@@
+(
+- \( fprintf(stderr, Ep) \| perror(Ep) \);
++ igt_warn(Ep);
+|
+- \( fprintf(stdout, Ep) \| printf(Ep) \);
++ igt_info(Ep);
+)
+
+@no_fprintf_report depends on report && !(file in "igt_core.c")@
+position p;
+identifier i =~ "^std(out|err)$";
+@@
+fprintf@p(i, ...);
+
+@script:python depends on report@
+p << no_fprintf_report.p;
+i << no_fprintf_report.i;
+@@
+should_use = "igt_info" if i == "stdout" else "igt_warn"
+msg = "WARNING: %s() should be used instead" % should_use
+coccilib.report.print_report(p[0], msg)
+
+@no_printf_perror_report depends on report && !(file in "igt_core.c")@
+position p;
+identifier func =~ "^p(rintf|error)$";
+@@
+func@p(...);
+
+@script:python depends on report@
+p << no_printf_perror_report.p;
+func << no_printf_perror_report.func;
+@@
+should_use = "igt_info" if func == "printf" else "igt_warn"
+msg = "WARNING: %s() should be used instead" % should_use
+coccilib.report.print_report(p[0], msg)