Browse Source

Fix calls to memset.

The third argument must be something like "size * sizeof(*ptr)", not just "size". This should be done even if ptr has type "char *", otherwise we might change the type and forget to update the call to memset().

This patch has been generated by this semantic patch :

@@
identifier func;
identifier nelems;
identifier p;
expression buffer;
type t;
@@
func(...)
{
...
p = (t) STARPU_VECTOR_GET_PTR(...)
...
nelems = STARPU_VECTOR_GET_NX(...)
...
memset(p,...,
-nelems
+nelems * sizeof(*p)
 );
...
}
Cyril Roelandt 13 years ago
parent
commit
974a90787d

+ 1 - 1
tests/datawizard/data_invalidation.c

@@ -89,7 +89,7 @@ static void cpu_memset_codelet(void *descr[], __attribute__ ((unused)) void *_ar
 	char *buf = (char *)STARPU_VECTOR_GET_PTR(descr[0]);
 	unsigned length = STARPU_VECTOR_GET_NX(descr[0]);
 
-	memset(buf, 42, length);
+	memset(buf, 42, length * sizeof(*buf));
 }
 
 static struct starpu_codelet memset_cl =

+ 1 - 1
tests/datawizard/lazy_allocation.c

@@ -84,7 +84,7 @@ static void cpu_memset_codelet(void *descr[], __attribute__ ((unused)) void *_ar
 	char *buf = (char *)STARPU_VECTOR_GET_PTR(descr[0]);
 	unsigned length = STARPU_VECTOR_GET_NX(descr[0]);
 
-	memset(buf, 42, length);
+	memset(buf, 42, length * sizeof(*buf));
 }
 
 static struct starpu_codelet memset_cl =

+ 1 - 1
tests/perfmodels/non_linear_regression_based.c

@@ -39,7 +39,7 @@ static void memset_cpu(void *descr[], void *arg)
 	int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
 	unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
 
-	memset(ptr, 42, n);
+	memset(ptr, 42, n * sizeof(*ptr));
 }
 
 static struct starpu_perfmodel model =

+ 1 - 1
tests/perfmodels/regression_based.c

@@ -39,7 +39,7 @@ static void memset_cpu(void *descr[], void *arg)
 	int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
 	unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
 
-	memset(ptr, 42, n);
+	memset(ptr, 42, n * sizeof(*ptr));
 }
 
 static struct starpu_perfmodel model =