summaryrefslogtreecommitdiff
path: root/lib/igt.cocci
diff options
context:
space:
mode:
authorThomas Wood <thomas.wood@intel.com>2015-03-25 16:42:57 +0000
committerThomas Wood <thomas.wood@intel.com>2015-03-26 15:50:59 +0000
commit47f6b1305cc3752f318a555b932e194e1500c1d8 (patch)
tree18660c1faf9eadd6ef2bcbe9730eb1fa6c5ced7f /lib/igt.cocci
parent0c4dd28d2d3b39216f9d041119ebf34cc44b7df7 (diff)
igt.cocci: check the return values of various functions
Add rules to fix unused-result warnings when compiling with _FORTIFY_SOURCE defined and apply them to the library and tests. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'lib/igt.cocci')
-rw-r--r--lib/igt.cocci28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/igt.cocci b/lib/igt.cocci
index 7dc398d0..156f0cf2 100644
--- a/lib/igt.cocci
+++ b/lib/igt.cocci
@@ -173,3 +173,31 @@ int E3, E4;
- igt_assert(E3 < E4);
+ igt_assert_lt(E3, E4);
)
+
+// avoid unused-result warnings when compiling with _FORTIFY_SOURCE defined
+@@
+identifier func =~ "^(read|write)$";
+expression list[2] E;
+expression size;
+@@
+-func(E, size);
++igt_assert_eq(func(E, size), size);
+
+@@
+expression ptr, size, nmemb, stream;
+@@
+-fread(ptr, size, nmemb, stream);
++igt_assert_eq(fread(ptr, size, nmemb, stream), nmemb);
+
+@@
+expression list E;
+@@
+-fgets(E);
++igt_assert_neq(fgets(E), NULL);
+
+@@
+identifier func =~ "^v?asprintf$";
+expression list E;
+@@
+-func(E);
++igt_assert_neq(func(E), -1);