Browse Source

cuda_check_return_values.cocci: add patch and context modes.

This only checks very simple cases, but it should be a good start :)
Cyril Roelandt 13 years ago
parent
commit
995dc04f9e
1 changed files with 28 additions and 7 deletions
  1. 28 7
      tools/dev/experimental/cuda_check_return_values.cocci

+ 28 - 7
tools/dev/experimental/cuda_check_return_values.cocci

@@ -13,9 +13,12 @@
 //
 // See the GNU Lesser General Public License in COPYING.LGPL for more details.
 
-virtual report
+virtual context
 virtual org
+virtual patch
+virtual report
 
+/*
 @seek@
 identifier func;
 expression E;
@@ -44,7 +47,11 @@ identifier seek.cuda_func;
 E@p = cuda_func(...);
 + if (STARPU_UNLIKELY(E != cudaSuccess))
 +	STARPU_CUDA_REPORT_ERROR(E);
+*/
+
 
+@initialize:python depends on report || org@
+msg = "Ignoring the return value of %s."
 
 @no_assignment@
 identifier cuda_func =~ "^cuda";
@@ -53,16 +60,30 @@ position p;
 cuda_func@p(...);
 
 
-@script:python depends on no_assignment && report@
+@depends on no_assignment && context@
+identifier no_assignment.cuda_func;
+position no_assignment.p;
+@@
+* cuda_func@p(...);
+
+@script:python depends on no_assignment && org@
 p << no_assignment.p;
 func << no_assignment.cuda_func;
 @@
-msg = "Ignoring the return value of %s." % func
-coccilib.report.print_report(p[0], msg)
+coccilib.org.print_todo(p[0], msg % func)
 
-@script:python depends on no_assignment && org@
+@depends on no_assignment && patch@
+identifier no_assignment.cuda_func;
+position no_assignment.p;
+@@
+-cuda_func@p(
++cudaError_t err = cuda_func(
+...);
++ if (STARPU_UNLIKELY(err != cudaSuccess))
++	STARPU_CUDA_REPORT_ERROR(err);
+
+@script:python depends on no_assignment && report@
 p << no_assignment.p;
 func << no_assignment.cuda_func;
 @@
-msg = "Ignoring the return value of %s." % func
-coccilib.org.print_todo(p[0], msg)
+coccilib.report.print_report(p[0], msg % func)