[24/33] cocci: Split out _FORTIFY_SOURCE rules

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

Details

Message ID 20190607230821.4488-24-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                | 41 ------------------------
 scripts/cocci/igt_fortify_source.cocci | 44 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 41 deletions(-)
 create mode 100644 scripts/cocci/igt_fortify_source.cocci

Patch hide | download patch | download mbox

diff --git a/scripts/cocci/igt.cocci b/scripts/cocci/igt.cocci
index 42609da6..86f0c1ed 100644
--- a/scripts/cocci/igt.cocci
+++ b/scripts/cocci/igt.cocci
@@ -6,47 +6,6 @@ 
 virtual report
 virtual patch
 
-// avoid unused-result warnings when compiling with _FORTIFY_SOURCE defined
-@depends on patch@
-identifier func =~ "^(read|write)$";
-expression list[2] E;
-expression size;
-@@
--func(E, size);
-+igt_assert_eq(func(E, size), size);
-
-@depends on patch@
-expression ptr, size, nmemb, stream;
-@@
--fread(ptr, size, nmemb, stream);
-+igt_assert_eq(fread(ptr, size, nmemb, stream), nmemb);
-
-@depends on patch@
-expression list E;
-@@
--fgets(E);
-+igt_assert(fgets(E));
-
-@depends on patch@
-identifier func =~ "^v?asprintf$";
-expression list E;
-@@
--func(E);
-+igt_assert_neq(func(E), -1);
-
-@unused_res_fortify_source_report depends on report@
-identifier func =~ "^(f?read|write|fgets|v?asprintf)$";
-position p;
-@@
-func@p(...);
-
-@script:python depends on report@
-p << unused_res_fortify_source_report.p;
-func << unused_res_fortify_source_report.func;
-@@
-msg = "WARNING: %s() result unused, will throw warning with _FORTIFY_SOURCE defined" % func
-coccilib.report.print_report(p[0], msg)
-
 // replace open-coded do_ioctl
 @depends on patch@
 expression a, b, c, e;
diff --git a/scripts/cocci/igt_fortify_source.cocci b/scripts/cocci/igt_fortify_source.cocci
new file mode 100644
index 00000000..0cedfc64
--- /dev/null
+++ b/scripts/cocci/igt_fortify_source.cocci
@@ -0,0 +1,44 @@ 
+// avoid unused-result warnings when compiling with _FORTIFY_SOURCE defined
+
+virtual report
+virtual patch
+
+@depends on patch@
+identifier func =~ "^(read|write)$";
+expression list[2] E;
+expression size;
+@@
+-func(E, size);
++igt_assert_eq(func(E, size), size);
+
+@depends on patch@
+expression ptr, size, nmemb, stream;
+@@
+-fread(ptr, size, nmemb, stream);
++igt_assert_eq(fread(ptr, size, nmemb, stream), nmemb);
+
+@depends on patch@
+expression list E;
+@@
+-fgets(E);
++igt_assert(fgets(E));
+
+@depends on patch@
+identifier func =~ "^v?asprintf$";
+expression list E;
+@@
+-func(E);
++igt_assert_neq(func(E), -1);
+
+@unused_res_fortify_source_report depends on report@
+identifier func =~ "^(f?read|write|fgets|v?asprintf)$";
+position p;
+@@
+func@p(...);
+
+@script:python depends on report@
+p << unused_res_fortify_source_report.p;
+func << unused_res_fortify_source_report.func;
+@@
+msg = "WARNING: %s() result unused, will throw warning with _FORTIFY_SOURCE defined" % func
+coccilib.report.print_report(p[0], msg)