ソースを参照

src: fix cppcheck warnings

Nathalie Furmento 8 年 前
コミット
87718074ae
共有48 個のファイルを変更した287 個の追加303 個の削除を含む
  1. 5 2
      src/common/graph.c
  2. 34 18
      src/common/rbtree.c
  3. 8 8
      src/common/utils.c
  4. 6 4
      src/core/dependencies/cg.c
  5. 1 1
      src/core/detect_combined_workers.c
  6. 4 2
      src/core/disk_ops/disk_unistd_o_direct.c
  7. 4 6
      src/core/disk_ops/unistd/disk_unistd_global.c
  8. 1 1
      src/core/jobs.c
  9. 5 5
      src/core/perfmodel/perfmodel_bus.c
  10. 1 2
      src/core/task.c
  11. 1 1
      src/core/workers.c
  12. 1 1
      src/core/workers.h
  13. 2 2
      src/datawizard/coherency.c
  14. 10 12
      src/datawizard/copy_driver.c
  15. 29 25
      src/datawizard/interfaces/block_interface.c
  16. 20 16
      src/datawizard/interfaces/data_interface.c
  17. 12 12
      src/datawizard/interfaces/matrix_interface.c
  18. 3 4
      src/datawizard/interfaces/vector_filters.c
  19. 2 2
      src/datawizard/malloc.c
  20. 5 7
      src/datawizard/memalloc.c
  21. 9 5
      src/datawizard/user_interactions.c
  22. 10 10
      src/debug/traces/starpu_fxt.c
  23. 2 3
      src/drivers/cpu/driver_cpu.c
  24. 3 3
      src/drivers/cuda/driver_cuda.c
  25. 6 6
      src/drivers/driver_common/driver_common.c
  26. 1 1
      src/drivers/gordon/driver_gordon.c
  27. 3 2
      src/drivers/mic/driver_mic_sink.c
  28. 2 6
      src/drivers/mp_common/source_common.c
  29. 5 5
      src/drivers/opencl/driver_opencl.c
  30. 3 4
      src/drivers/opencl/driver_opencl_utils.c
  31. 0 1
      src/drivers/scc/driver_scc_source.c
  32. 1 1
      src/profiling/profiling_helpers.c
  33. 2 2
      src/sched_policies/component_heft.c
  34. 1 1
      src/sched_policies/component_work_stealing.c
  35. 4 4
      src/sched_policies/component_worker.c
  36. 17 20
      src/sched_policies/deque_modeling_policy_data_aware.c
  37. 4 7
      src/sched_policies/eager_central_policy.c
  38. 4 8
      src/sched_policies/eager_central_priority_policy.c
  39. 3 7
      src/sched_policies/fifo_queues.c
  40. 6 9
      src/sched_policies/graph_test_policy.c
  41. 6 9
      src/sched_policies/heteroprio.c
  42. 3 5
      src/sched_policies/parallel_eager.c
  43. 2 3
      src/sched_policies/parallel_heft.c
  44. 2 2
      src/sched_policies/prio_deque.c
  45. 6 6
      src/sched_policies/scheduler_maker.c
  46. 18 33
      src/sched_policies/work_stealing_policy.c
  47. 6 4
      src/util/openmp_runtime_support_environment.c
  48. 4 5
      src/util/starpu_task_insert_utils.c

+ 5 - 2
src/common/graph.c

@@ -63,9 +63,9 @@ void _starpu_graph_wrlock(void)
 }
 
 void _starpu_graph_drop_node(struct _starpu_graph_node *node);
+
 void _starpu_graph_drop_dropped_nodes(void)
 {
-	struct _starpu_graph_node *node, *next;
 	struct _starpu_graph_node_multilist_dropped dropping;
 
 	STARPU_PTHREAD_MUTEX_LOCK(&dropped_lock);
@@ -76,6 +76,8 @@ void _starpu_graph_drop_dropped_nodes(void)
 	/* And now process it if it's not empty.  */
 	if (!_starpu_graph_node_multilist_empty_dropped(&dropping))
 	{
+		struct _starpu_graph_node *node, *next;
+
 		STARPU_PTHREAD_RWLOCK_WRLOCK(&graph_lock);
 		for (node = _starpu_graph_node_multilist_begin_dropped(&dropping);
 		     node != _starpu_graph_node_multilist_end_dropped(&dropping);
@@ -327,7 +329,6 @@ void _starpu_graph_compute_descendants(void)
 	struct _starpu_graph_node **current_set = NULL, **next_set = NULL, **swap_set;
 	unsigned current_n, next_n, i, j;
 	unsigned current_alloc = 0, next_alloc = 0, swap_alloc;
-	unsigned descendants;
 
 	_starpu_graph_wrlock();
 
@@ -342,6 +343,8 @@ void _starpu_graph_compute_descendants(void)
 	     node != _starpu_graph_node_multilist_end_all(&all);
 	     node = _starpu_graph_node_multilist_next_all(node))
 	{
+		unsigned descendants;
+
 		/* Mark all nodes as unseen */
 		for (node2 = _starpu_graph_node_multilist_begin_all(&all);
 		     node2 != _starpu_graph_node_multilist_end_all(&all);

+ 34 - 18
src/common/rbtree.c

@@ -116,8 +116,7 @@ static inline void starpu_rbtree_set_black(struct starpu_rbtree_node *node)
  * The direction parameter defines the rotation direction and is either
  * STARPU_RBTREE_LEFT or STARPU_RBTREE_RIGHT.
  */
-static void starpu_rbtree_rotate(struct starpu_rbtree *tree, struct starpu_rbtree_node *node,
-                          int direction)
+static void starpu_rbtree_rotate(struct starpu_rbtree *tree, struct starpu_rbtree_node *node, int direction)
 {
     struct starpu_rbtree_node *parent, *rnode;
     int left, right;
@@ -161,8 +160,10 @@ void starpu_rbtree_insert_rebalance(struct starpu_rbtree *tree, struct starpu_rb
     else
         parent->children[index] = node;
 
-    for (;;) {
-        if (parent == NULL) {
+    for (;;)
+    {
+        if (parent == NULL)
+	{
             starpu_rbtree_set_black(node);
             break;
         }
@@ -181,7 +182,8 @@ void starpu_rbtree_insert_rebalance(struct starpu_rbtree *tree, struct starpu_rb
         /*
          * Uncle is red. Flip colors and repeat at grand parent.
          */
-        if ((uncle != NULL) && starpu_rbtree_is_red(uncle)) {
+        if ((uncle != NULL) && starpu_rbtree_is_red(uncle))
+	{
             starpu_rbtree_set_black(uncle);
             starpu_rbtree_set_black(parent);
             starpu_rbtree_set_red(grand_parent);
@@ -193,7 +195,8 @@ void starpu_rbtree_insert_rebalance(struct starpu_rbtree *tree, struct starpu_rb
         /*
          * Node is the right child of its parent. Rotate left at parent.
          */
-        if (parent->children[right] == node) {
+        if (parent->children[right] == node)
+	{
             starpu_rbtree_rotate(tree, parent, left);
             tmp = node;
             node = parent;
@@ -222,7 +225,8 @@ void starpu_rbtree_remove(struct starpu_rbtree *tree, struct starpu_rbtree_node
         child = node->children[STARPU_RBTREE_RIGHT];
     else if (node->children[STARPU_RBTREE_RIGHT] == NULL)
         child = node->children[STARPU_RBTREE_LEFT];
-    else {
+    else
+    {
         struct starpu_rbtree_node *successor;
 
         /*
@@ -254,7 +258,8 @@ void starpu_rbtree_remove(struct starpu_rbtree *tree, struct starpu_rbtree_node
 
         if (node == parent)
             parent = successor;
-        else {
+        else
+	{
             successor->children[STARPU_RBTREE_RIGHT] = node->children[STARPU_RBTREE_RIGHT];
             starpu_rbtree_set_parent(successor->children[STARPU_RBTREE_RIGHT], successor);
             parent->children[STARPU_RBTREE_LEFT] = child;
@@ -289,8 +294,10 @@ update_color:
     if (color == STARPU_RBTREE_COLOR_RED)
         return;
 
-    for (;;) {
-        if ((child != NULL) && starpu_rbtree_is_red(child)) {
+    for (;;)
+    {
+        if ((child != NULL) && starpu_rbtree_is_red(child))
+	{
             starpu_rbtree_set_black(child);
             break;
         }
@@ -307,7 +314,8 @@ update_color:
          * Brother is red. Recolor and rotate left at parent so that brother
          * becomes black.
          */
-        if (starpu_rbtree_is_red(brother)) {
+        if (starpu_rbtree_is_red(brother))
+	{
             starpu_rbtree_set_black(brother);
             starpu_rbtree_set_red(parent);
             starpu_rbtree_rotate(tree, parent, left);
@@ -320,7 +328,8 @@ update_color:
         if (((brother->children[STARPU_RBTREE_LEFT] == NULL)
              || starpu_rbtree_is_black(brother->children[STARPU_RBTREE_LEFT]))
             && ((brother->children[STARPU_RBTREE_RIGHT] == NULL)
-                || starpu_rbtree_is_black(brother->children[STARPU_RBTREE_RIGHT]))) {
+                || starpu_rbtree_is_black(brother->children[STARPU_RBTREE_RIGHT])))
+	{
             starpu_rbtree_set_red(brother);
             child = parent;
             parent = starpu_rbtree_parent(child);
@@ -331,7 +340,8 @@ update_color:
          * Brother's right child is black. Recolor and rotate right at brother.
          */
         if ((brother->children[right] == NULL)
-            || starpu_rbtree_is_black(brother->children[right])) {
+            || starpu_rbtree_is_black(brother->children[right]))
+	{
             starpu_rbtree_set_black(brother->children[left]);
             starpu_rbtree_set_red(brother);
             starpu_rbtree_rotate(tree, brother, right);
@@ -395,16 +405,20 @@ struct starpu_rbtree_node * starpu_rbtree_walk(struct starpu_rbtree_node *node,
     if (node == NULL)
         return NULL;
 
-    if (node->children[left] != NULL) {
+    if (node->children[left] != NULL)
+    {
         node = node->children[left];
 
         while (node->children[right] != NULL)
             node = node->children[right];
-    } else {
+    }
+    else
+    {
         struct starpu_rbtree_node *parent;
         int index;
 
-        for (;;) {
+        for (;;)
+	{
             parent = starpu_rbtree_parent(node);
 
             if (parent == NULL)
@@ -430,11 +444,13 @@ static struct starpu_rbtree_node * starpu_rbtree_find_deepest(struct starpu_rbtr
 
     assert(node != NULL);
 
-    for (;;) {
+    for (;;)
+    {
         parent = node;
         node = node->children[STARPU_RBTREE_LEFT];
 
-        if (node == NULL) {
+        if (node == NULL)
+	{
             node = parent->children[STARPU_RBTREE_RIGHT];
 
             if (node == NULL)

+ 8 - 8
src/common/utils.c

@@ -176,7 +176,7 @@ char *_starpu_mktemp(const char *directory, int flags, int *fd)
 		errno = err;
 		return NULL;
 	}
-	
+
 #if !defined(STARPU_HAVE_WINDOWS) && !defined (HAVE_MKOSTEMP)
 #if defined (O_DIRECT)
 	if ((flags & O_DIRECT) != 0)
@@ -190,13 +190,13 @@ char *_starpu_mktemp(const char *directory, int flags, int *fd)
 			free(baseCpy);
 			errno = err;
 			return NULL;
-		}		
+		}
 	}
 #elif defined (STARPU_HAVE_DARWIN) //MACOS
 	if ((flags & F_NOCACHE) != 0)
 	{
 		int flag = fcntl(*fd, F_GETFL);
-		flag |= F_NOCACHE;
+		//flag |= F_NOCACHE;
 		if (fcntl(*fd, F_SETFL, F_NOCACHE) < 0)
 		{
 			int err = errno;
@@ -205,13 +205,13 @@ char *_starpu_mktemp(const char *directory, int flags, int *fd)
 			errno = err;
 			return NULL;
 		}
-	}	
+	}
 #else
 	/* nothing for now */
-#endif	
-#endif	  
-	
-	
+#endif
+#endif
+
+
 	return baseCpy;
 }
 

+ 6 - 4
src/core/dependencies/cg.c

@@ -170,10 +170,6 @@ void _starpu_notify_cg(struct _starpu_cg *cg)
 		ANNOTATE_HAPPENS_AFTER(&cg->remaining);
 		cg->remaining = cg->ntags;
 
-		struct _starpu_tag *tag;
-		struct _starpu_cg_list *tag_successors, *job_successors;
-		struct _starpu_job *j;
-
 		/* the group is now completed */
 		switch (cg->cg_type)
 		{
@@ -190,6 +186,9 @@ void _starpu_notify_cg(struct _starpu_cg *cg)
 
 			case STARPU_CG_TAG:
 			{
+				struct _starpu_cg_list *tag_successors;
+				struct _starpu_tag *tag;
+
 				tag = cg->succ.tag;
 				tag_successors = &tag->tag_successors;
 
@@ -209,6 +208,9 @@ void _starpu_notify_cg(struct _starpu_cg *cg)
 
  		        case STARPU_CG_TASK:
 			{
+				struct _starpu_cg_list *job_successors;
+				struct _starpu_job *j;
+
 				j = cg->succ.job;
 
 				STARPU_PTHREAD_MUTEX_LOCK(&j->sync_mutex);

+ 1 - 1
src/core/detect_combined_workers.c

@@ -274,7 +274,7 @@ static void find_and_assign_combinations_without_hwloc(int *workerids, int nwork
 #ifdef STARPU_USE_MIC
 		else if(worker->arch == STARPU_MIC_WORKER)
 		{
-			for(j=0; mic_id[j] != worker->devid && mic_id[j] != -1 && j<nb_mics; j++);
+			for(j=0; j<nb_mics && mic_id[j] != worker->devid && mic_id[j] != -1; j++);
 			if(j<nb_mics)
 			{
 				if(mic_id[j] == -1)

+ 4 - 2
src/core/disk_ops/disk_unistd_o_direct.c

@@ -81,7 +81,8 @@ static void *starpu_unistd_o_direct_plug(void *parameter, starpu_ssize_t size)
 #ifdef HAVE_AIO_H
 void *starpu_unistd_o_direct_global_async_read(void *base, void *obj, void *buf, off_t offset, size_t size)
 {
-	STARPU_ASSERT_MSG((size % getpagesize()) == 0, "The unistd_o_direct variant can only read a multiple of page size %u Bytes (Here %u). Use the non-o_direct unistd variant if your data is not a multiple of %u", getpagesize(), (int) size, getpagesize());
+	STARPU_ASSERT_MSG((size % getpagesize()) == 0, "The unistd_o_direct variant can only read a multiple of page size %lu Bytes (Here %lu). Use the non-o_direct unistd variant if your data is not a multiple of %lu",
+			  getpagesize(), (unsigned long) size, getpagesize());
 
 	STARPU_ASSERT_MSG((((uintptr_t) buf) % getpagesize()) == 0, "You have to use starpu_malloc function");
 
@@ -90,7 +91,8 @@ void *starpu_unistd_o_direct_global_async_read(void *base, void *obj, void *buf,
 
 void *starpu_unistd_o_direct_global_async_write(void *base, void *obj, void *buf, off_t offset, size_t size)
 {
-	STARPU_ASSERT_MSG((size % getpagesize()) == 0, "The unistd_o_direct variant can only write a multiple of page size %u Bytes (Here %u). Use the non-o_direct unistd variant if your data is not a multiple of %u", getpagesize(), (int) size, getpagesize());
+	STARPU_ASSERT_MSG((size % getpagesize()) == 0, "The unistd_o_direct variant can only write a multiple of page size %lu Bytes (Here %lu). Use the non-o_direct unistd variant if your data is not a multiple of %lu",
+			  getpagesize(), (unsigned long) size, getpagesize());
 
 	STARPU_ASSERT_MSG((((uintptr_t)buf) % getpagesize()) == 0, "You have to use starpu_malloc function");
 

+ 4 - 6
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -197,10 +197,9 @@ int starpu_unistd_global_read(void *base STARPU_ATTRIBUTE_UNUSED, void *obj, voi
 #ifdef HAVE_PREAD
 	if (fd >= 0)
 		nb = pread(fd, buf, size, offset);
-	else
 #endif
 	{
-		if (fd >= 0)
+		if (tmp->descriptor >= 0)
 			STARPU_PTHREAD_MUTEX_LOCK(&tmp->mutex);
 		else
 			fd = _starpu_unistd_reopen(obj);
@@ -258,15 +257,14 @@ int starpu_unistd_global_full_read(void *base STARPU_ATTRIBUTE_UNUSED, void *obj
 {
         struct starpu_unistd_global_obj *tmp = (struct starpu_unistd_global_obj *) obj;
 	int fd = tmp->descriptor;
-	int ret;
-	struct stat st;
 
 	if (fd < 0)
 		fd = _starpu_unistd_reopen(obj);
 #ifdef STARPU_HAVE_WINDOWS
 	*size = _filelength(fd);
 #else
-	ret = fstat(fd, &st);
+	struct stat st;
+	int ret = fstat(fd, &st);
 	STARPU_ASSERT(ret==0);
 
 	*size = st.st_size;
@@ -292,7 +290,7 @@ int starpu_unistd_global_write(void *base STARPU_ATTRIBUTE_UNUSED, void *obj, co
 	else
 #endif
 	{
-		if (fd >= 0)
+		if (tmp->descriptor >= 0)
 			STARPU_PTHREAD_MUTEX_LOCK(&tmp->mutex);
 		else
 			fd = _starpu_unistd_reopen(obj);

+ 1 - 1
src/core/jobs.c

@@ -713,7 +713,7 @@ int _starpu_push_local_task(struct _starpu_worker *worker, struct starpu_task *t
 
 	if (task->execute_on_a_specific_worker && task->workerorder)
 	{
-		STARPU_ASSERT_MSG(task->workerorder >= worker->current_ordered_task_order, "worker order values must not have duplicates (%d pushed to worker %d, but %d already passed)", task->workerorder, worker->workerid, worker->current_ordered_task_order);
+		STARPU_ASSERT_MSG(task->workerorder >= worker->current_ordered_task_order, "worker order values must not have duplicates (%u pushed to worker %d, but %d already passed)", task->workerorder, worker->workerid, worker->current_ordered_task_order);
 		/* Put it in the ordered task ring */
 		unsigned needed = task->workerorder - worker->current_ordered_task_order + 1;
 		if (worker->local_ordered_tasks_size < needed)

+ 5 - 5
src/core/perfmodel/perfmodel_bus.c

@@ -808,7 +808,7 @@ static void load_bus_affinity_file_content(void)
 		unsigned dummy;
 
 		_starpu_drop_comments(f);
-		ret = fscanf(f, "%d\t", &dummy);
+		ret = fscanf(f, "%u\t", &dummy);
 		STARPU_ASSERT(ret == 1);
 
 		STARPU_ASSERT(dummy == gpu);
@@ -832,7 +832,7 @@ static void load_bus_affinity_file_content(void)
 		unsigned dummy;
 
 		_starpu_drop_comments(f);
-		ret = fscanf(f, "%d\t", &dummy);
+		ret = fscanf(f, "%u\t", &dummy);
 		STARPU_ASSERT(ret == 1);
 
 		STARPU_ASSERT(dummy == gpu);
@@ -1611,13 +1611,13 @@ static void check_bus_config_file(void)
                 ret = fscanf(f, "%u\t", &read_cpus);
 		STARPU_ASSERT(ret == 1);
                 _starpu_drop_comments(f);
-		ret = fscanf(f, "%d\t", &read_cuda);
+		ret = fscanf(f, "%u\t", &read_cuda);
 		STARPU_ASSERT(ret == 1);
                 _starpu_drop_comments(f);
-		ret = fscanf(f, "%d\t", &read_opencl);
+		ret = fscanf(f, "%u\t", &read_opencl);
 		STARPU_ASSERT(ret == 1);
                 _starpu_drop_comments(f);
-		ret = fscanf(f, "%d\t", &read_mic);
+		ret = fscanf(f, "%u\t", &read_mic);
 		if (ret == 0)
 			read_mic = 0;
                 _starpu_drop_comments(f);

+ 1 - 2
src/core/task.c

@@ -714,8 +714,7 @@ int starpu_task_submit_to_ctx(struct starpu_task *task, unsigned sched_ctx_id)
  * skipping dependencies completely (when it knows what it is doing).  */
 int _starpu_task_submit_nodeps(struct starpu_task *task)
 {
-	int ret;
-	ret = _starpu_task_submit_head(task);
+	int ret = _starpu_task_submit_head(task);
 	STARPU_ASSERT(ret == 0);
 
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);

+ 1 - 1
src/core/workers.c

@@ -1699,7 +1699,7 @@ int starpu_worker_get_id(void)
 unsigned _starpu_worker_get_id_check(const char *f, int l)
 {
 	int id = _starpu_worker_get_id();
-	STARPU_ASSERT_MSG(id>=0, "%s:%u Cannot be called from outside a worker\n", f, l);
+	STARPU_ASSERT_MSG(id>=0, "%s:%d Cannot be called from outside a worker\n", f, l);
 	return id;
 }
 

+ 1 - 1
src/core/workers.h

@@ -569,7 +569,7 @@ static inline int _starpu_worker_get_id(void)
 static inline unsigned __starpu_worker_get_id_check(const char *f, int l)
 {
 	int id = starpu_worker_get_id();
-	STARPU_ASSERT_MSG(id>=0, "%s:%u Cannot be called from outside a worker\n", f, l);
+	STARPU_ASSERT_MSG(id>=0, "%s:%d Cannot be called from outside a worker\n", f, l);
 	return id;
 }
 #define _starpu_worker_get_id_check(f,l) __starpu_worker_get_id_check(f,l)

+ 2 - 2
src/datawizard/coherency.c

@@ -364,7 +364,7 @@ static int determine_request_path(starpu_data_handle_t handle,
 		}
 		else
 		{
-			STARPU_ASSERT_MSG(can_copy(src_interface, src_node, dst_interface, dst_node, dst_node), "interface %d refuses all kinds of transfers from node %u to node %u\n", handle->ops->interfaceid, src_node, dst_node);
+			STARPU_ASSERT_MSG(can_copy(src_interface, src_node, dst_interface, dst_node, dst_node), "interface %d refuses all kinds of transfers from node %d to node %d\n", handle->ops->interfaceid, src_node, dst_node);
 			handling_nodes[0] = dst_node;
 		}
 
@@ -381,7 +381,7 @@ static int determine_request_path(starpu_data_handle_t handle,
 		}
 		else
 		{
-			STARPU_ASSERT_MSG(can_copy(src_interface, src_node, dst_interface, dst_node, src_node), "interface %d refuses all kinds of transfers from node %u to node %u\n", handle->ops->interfaceid, src_node, dst_node);
+			STARPU_ASSERT_MSG(can_copy(src_interface, src_node, dst_interface, dst_node, src_node), "interface %d refuses all kinds of transfers from node %d to node %d\n", handle->ops->interfaceid, src_node, dst_node);
 			handling_nodes[1] = src_node;
 		}
 

+ 10 - 12
src/datawizard/copy_driver.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2013, 2016  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -465,9 +465,9 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 			STARPU_ASSERT(ret == 0);
 		}
 		break;
-		
+
 	case _STARPU_MEMORY_NODE_TUPLE(STARPU_DISK_RAM,STARPU_CPU_RAM):
-		if(copy_methods->any_to_any) 
+		if(copy_methods->any_to_any)
 			ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, req && !starpu_asynchronous_copy_disabled()  ? &req->async_channel : NULL);
 		else
 		{
@@ -478,7 +478,7 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 			if (ret == 0)
 			{
 				/* read is already finished, we can already unpack */
-				handle->ops->unpack_data(handle, dst_node, ptr, size); 
+				handle->ops->unpack_data(handle, dst_node, ptr, size);
 				/* ptr is allocated in full_read */
 				free(ptr);
 			}
@@ -488,15 +488,15 @@ static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 		}
 		break;
 
-	case _STARPU_MEMORY_NODE_TUPLE(STARPU_DISK_RAM,STARPU_DISK_RAM):	
+	case _STARPU_MEMORY_NODE_TUPLE(STARPU_DISK_RAM,STARPU_DISK_RAM):
 		ret = copy_methods->any_to_any(src_interface, src_node, dst_interface, dst_node, req ? &req->async_channel : NULL);
 		break;
-		
+
 	default:
 		STARPU_ABORT();
 		break;
 	}
-	
+
 	return ret;
 #endif /* !SIMGRID */
 }
@@ -515,9 +515,6 @@ int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT _starpu_driver_copy_data_1_to_1(starpu_d
 		STARPU_ASSERT(src_replicate->refcnt);
 	}
 
-	int ret_alloc, ret_copy;
-	unsigned long STARPU_ATTRIBUTE_UNUSED com_id = 0;
-
 	unsigned src_node = src_replicate->memory_node;
 	unsigned dst_node = dst_replicate->memory_node;
 
@@ -528,7 +525,7 @@ int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT _starpu_driver_copy_data_1_to_1(starpu_d
 			/* We're not supposed to allocate there at the moment */
 			return -ENOMEM;
 
-		ret_alloc = _starpu_allocate_memory_on_node(handle, dst_replicate, req ? req->prefetch : 0);
+		int ret_alloc = _starpu_allocate_memory_on_node(handle, dst_replicate, req ? req->prefetch : 0);
 		if (ret_alloc)
 			return -ENOMEM;
 	}
@@ -540,6 +537,7 @@ int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT _starpu_driver_copy_data_1_to_1(starpu_d
 	 * we do not perform any transfer */
 	if (!donotread)
 	{
+		unsigned long STARPU_ATTRIBUTE_UNUSED com_id = 0;
 		size_t size = _starpu_data_get_size(handle);
 		_starpu_bus_update_profiling_info((int)src_node, (int)dst_node, size);
 
@@ -553,7 +551,7 @@ int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT _starpu_driver_copy_data_1_to_1(starpu_d
 		dst_replicate->initialized = 1;
 
 		_STARPU_TRACE_START_DRIVER_COPY(src_node, dst_node, size, com_id, prefetch, handle);
-		ret_copy = copy_data_1_to_1_generic(handle, src_replicate, dst_replicate, req);
+		int ret_copy = copy_data_1_to_1_generic(handle, src_replicate, dst_replicate, req);
 		if (!req)
 			/* Synchronous, this is already finished */
 			_STARPU_TRACE_END_DRIVER_COPY(src_node, dst_node, size, com_id, prefetch);

+ 29 - 25
src/datawizard/interfaces/block_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -698,8 +698,6 @@ static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_int
 	uint32_t ldy_dst = dst_block->ldy;
 	uint32_t ldz_dst = dst_block->ldz;
 
-	unsigned y, z;
-
 	if (ldy_src == nx && ldy_dst == nx && ldz_src == ny && ldz_dst == ny)
 	{
 		/* Optimise non-partitioned and z-partitioned case */
@@ -709,30 +707,36 @@ static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_int
 				ret = -EAGAIN;
 	}
 	else
-	for (z = 0; z < nz; z++)
 	{
-		if (ldy_src == nx && ldy_dst == nx)
+		unsigned z;
+		for (z = 0; z < nz; z++)
 		{
-			/* Optimise y-partitioned case */
-			uint32_t src_offset = z*ldz_src*elemsize;
-			uint32_t dst_offset = z*ldz_dst*elemsize;
-
-			if (starpu_interface_copy(src_block->dev_handle, src_block->offset + src_offset, src_node,
-			                          dst_block->dev_handle, dst_block->offset + dst_offset, dst_node,
-			                          nx*ny*elemsize, async_data))
-				ret = -EAGAIN;
-		}
-		else
-		for (y = 0; y < ny; y++)
-		{
-			/* Eerf, x-partitioned case */
-			uint32_t src_offset = (y*ldy_src + z*ldz_src)*elemsize;
-			uint32_t dst_offset = (y*ldy_dst + z*ldz_dst)*elemsize;
-
-			if (starpu_interface_copy(src_block->dev_handle, src_block->offset + src_offset, src_node,
-			                          dst_block->dev_handle, dst_block->offset + dst_offset, dst_node,
-			                          nx*elemsize, async_data))
-				ret = -EAGAIN;
+			if (ldy_src == nx && ldy_dst == nx)
+			{
+				/* Optimise y-partitioned case */
+				uint32_t src_offset = z*ldz_src*elemsize;
+				uint32_t dst_offset = z*ldz_dst*elemsize;
+
+				if (starpu_interface_copy(src_block->dev_handle, src_block->offset + src_offset, src_node,
+							  dst_block->dev_handle, dst_block->offset + dst_offset, dst_node,
+							  nx*ny*elemsize, async_data))
+					ret = -EAGAIN;
+			}
+			else
+			{
+				unsigned y;
+				for (y = 0; y < ny; y++)
+				{
+					/* Eerf, x-partitioned case */
+					uint32_t src_offset = (y*ldy_src + z*ldz_src)*elemsize;
+					uint32_t dst_offset = (y*ldy_dst + z*ldz_dst)*elemsize;
+
+					if (starpu_interface_copy(src_block->dev_handle, src_block->offset + src_offset, src_node,
+								  dst_block->dev_handle, dst_block->offset + dst_offset, dst_node,
+								  nx*elemsize, async_data))
+						ret = -EAGAIN;
+				}
+			}
 		}
 	}
 

+ 20 - 16
src/datawizard/interfaces/data_interface.c

@@ -556,7 +556,6 @@ void _starpu_data_unregister_ram_pointer(starpu_data_handle_t handle)
 void _starpu_data_free_interfaces(starpu_data_handle_t handle)
 {
 	unsigned node;
-	unsigned worker;
 	unsigned nworkers = starpu_worker_get_count();
 
 	for (node = 0; node < STARPU_MAXNODES; node++)
@@ -564,6 +563,7 @@ void _starpu_data_free_interfaces(starpu_data_handle_t handle)
 
 	if (handle->per_worker)
 	{
+		unsigned worker;
 		for (worker = 0; worker < nworkers; worker++)
 			free(handle->per_worker[worker].data_interface);
 		free(handle->per_worker);
@@ -836,15 +836,17 @@ retry_busy:
 		if (local->allocated && local->automatically_allocated)
 			_starpu_request_mem_chunk_removal(handle, local, node, size);
 	}
-	unsigned worker;
-	unsigned nworkers = starpu_worker_get_count();
 	if (handle->per_worker)
-	for (worker = 0; worker < nworkers; worker++)
 	{
-		struct _starpu_data_replicate *local = &handle->per_worker[worker];
-		/* free the data copy in a lazy fashion */
-		if (local->allocated && local->automatically_allocated)
-			_starpu_request_mem_chunk_removal(handle, local, starpu_worker_get_memory_node(worker), size);
+		unsigned worker;
+		unsigned nworkers = starpu_worker_get_count();
+		for (worker = 0; worker < nworkers; worker++)
+		{
+			struct _starpu_data_replicate *local = &handle->per_worker[worker];
+			/* free the data copy in a lazy fashion */
+			if (local->allocated && local->automatically_allocated)
+				_starpu_request_mem_chunk_removal(handle, local, starpu_worker_get_memory_node(worker), size);
+		}
 	}
 	_starpu_data_free_interfaces(handle);
 
@@ -960,18 +962,20 @@ static void _starpu_data_invalidate(void *data)
 		local->state = STARPU_INVALID;
 	}
 
-	unsigned worker;
-	unsigned nworkers = starpu_worker_get_count();
 	if (handle->per_worker)
-	for (worker = 0; worker < nworkers; worker++)
 	{
-		struct _starpu_data_replicate *local = &handle->per_worker[worker];
+		unsigned worker;
+		unsigned nworkers = starpu_worker_get_count();
+		for (worker = 0; worker < nworkers; worker++)
+		{
+			struct _starpu_data_replicate *local = &handle->per_worker[worker];
 
-		if (local->mc && local->allocated && local->automatically_allocated)
-			/* free the data copy in a lazy fashion */
-			_starpu_request_mem_chunk_removal(handle, local, starpu_worker_get_memory_node(worker), size);
+			if (local->mc && local->allocated && local->automatically_allocated)
+				/* free the data copy in a lazy fashion */
+				_starpu_request_mem_chunk_removal(handle, local, starpu_worker_get_memory_node(worker), size);
 
-		local->state = STARPU_INVALID;
+			local->state = STARPU_INVALID;
+		}
 	}
 
 	_starpu_spin_unlock(&handle->header_lock);

+ 12 - 12
src/datawizard/interfaces/matrix_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -559,7 +559,6 @@ static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_int
 	struct starpu_matrix_interface *dst_matrix = (struct starpu_matrix_interface *) dst_interface;
 	int ret = 0;
 
-	unsigned y;
 	uint32_t nx = dst_matrix->nx;
 	uint32_t ny = dst_matrix->ny;
 	size_t elemsize = dst_matrix->elemsize;
@@ -577,16 +576,17 @@ static int copy_any_to_any(void *src_interface, unsigned src_node, void *dst_int
 	}
 	else
 	{
-	     for (y = 0; y < ny; y++)
-	     {
-		     uint32_t src_offset = y*ld_src*elemsize;
-		     uint32_t dst_offset = y*ld_dst*elemsize;
-
-		     if (starpu_interface_copy(src_matrix->dev_handle, src_matrix->offset + src_offset, src_node,
-					       dst_matrix->dev_handle, dst_matrix->offset + dst_offset, dst_node,
-					       nx*elemsize, async_data))
-			     ret = -EAGAIN;
-	     }
+		unsigned y;
+		for (y = 0; y < ny; y++)
+		{
+			uint32_t src_offset = y*ld_src*elemsize;
+			uint32_t dst_offset = y*ld_dst*elemsize;
+
+			if (starpu_interface_copy(src_matrix->dev_handle, src_matrix->offset + src_offset, src_node,
+						  dst_matrix->dev_handle, dst_matrix->offset + dst_offset, dst_node,
+						  nx*elemsize, async_data))
+				ret = -EAGAIN;
+		}
 	}
 
 	_STARPU_TRACE_DATA_COPY(src_node, dst_node, (size_t)nx*ny*elemsize);

+ 3 - 4
src/datawizard/interfaces/vector_filters.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2013, 2016  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011  CNRS
+ * Copyright (C) 2010, 2011, 2016  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -87,7 +87,7 @@ void starpu_vector_filter_block_shadow(void *father_interface, void *child_inter
 void starpu_vector_filter_divide_in_2(void *father_interface, void *child_interface, struct starpu_data_filter *f, unsigned id, STARPU_ATTRIBUTE_UNUSED unsigned nchunks)
 {
         /* there cannot be more than 2 chunks */
-	STARPU_ASSERT_MSG(id < 2, "Only %d parts", id);
+	STARPU_ASSERT_MSG(id < 2, "Only %u parts", id);
 
 	struct starpu_vector_interface *vector_father = (struct starpu_vector_interface *) father_interface;
 	struct starpu_vector_interface *vector_child = (struct starpu_vector_interface *) child_interface;
@@ -141,8 +141,6 @@ void starpu_vector_filter_list(void *father_interface, void *child_interface, st
 
 	size_t elemsize = vector_father->elemsize;
 
-	unsigned current_pos = 0;
-
 	uint32_t chunk_size = length_tab[id];
 
 	STARPU_ASSERT_MSG(vector_father->id == STARPU_VECTOR_INTERFACE_ID, "%s can only be applied on a vector data", __func__);
@@ -153,6 +151,7 @@ void starpu_vector_filter_list(void *father_interface, void *child_interface, st
 	if (vector_father->dev_handle)
 	{
 		/* compute the current position */
+		unsigned current_pos = 0;
 		unsigned i;
 		for (i = 0; i < id; i++)
 			current_pos += length_tab[i];

+ 2 - 2
src/datawizard/malloc.c

@@ -315,7 +315,7 @@ end:
 #endif
 	if (ret == 0)
 	{
-		STARPU_ASSERT_MSG(*A, "Failed to allocated memory of size %ld b\n", dim);
+		STARPU_ASSERT_MSG(*A, "Failed to allocated memory of size %ld b\n", (unsigned long)dim);
 	}
 	else if (flags & STARPU_MALLOC_COUNT)
 	{
@@ -1037,7 +1037,7 @@ starpu_free_on_node_flags(unsigned dst_node, uintptr_t addr, size_t size, int fl
 
 void starpu_malloc_on_node_set_default_flags(unsigned node, int flags)
 {
-	STARPU_ASSERT_MSG(node < STARPU_MAXNODES, "bogus node value %d given to starpu_malloc_on_node_set_default_flags\n", node);
+	STARPU_ASSERT_MSG(node < STARPU_MAXNODES, "bogus node value %u given to starpu_malloc_on_node_set_default_flags\n", node);
 	malloc_on_node_default_flags[node] = flags;
 }
 

+ 5 - 7
src/datawizard/memalloc.c

@@ -240,10 +240,6 @@ static unsigned may_free_subtree(starpu_data_handle_t handle, unsigned node)
 static int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT transfer_subtree_to_node(starpu_data_handle_t handle, unsigned src_node,
 				     unsigned dst_node)
 {
-	unsigned i;
-	unsigned last = 0;
-	unsigned cnt;
-
 	STARPU_ASSERT(dst_node != src_node);
 
 	if (handle->nchildren == 0)
@@ -279,12 +275,15 @@ static int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT transfer_subtree_to_node(starpu_d
 
 		if (src_replicate->state == STARPU_SHARED)
 		{
+			unsigned i;
+			unsigned last = 0;
+			unsigned cnt = 0;
+
 			/* some other node may have the copy */
 			_STARPU_TRACE_DATA_INVALIDATE(handle, src_node);
 			src_replicate->state = STARPU_INVALID;
 
 			/* count the number of copies */
-			cnt = 0;
 			for (i = 0; i < STARPU_MAXNODES; i++)
 			{
 				if (handle->per_node[i].state == STARPU_SHARED)
@@ -307,11 +306,10 @@ static int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT transfer_subtree_to_node(starpu_d
 	{
 		/* transfer all sub-subtrees children */
 		unsigned child;
-		int res;
 		for (child = 0; child < handle->nchildren; child++)
 		{
 			starpu_data_handle_t child_handle = starpu_data_get_child(handle, child);
-			res = transfer_subtree_to_node(child_handle, src_node, dst_node);
+			int res = transfer_subtree_to_node(child_handle, src_node, dst_node);
 			if (res == 0)
 				return 0;
 			/* There is no way children have disappeared since we

+ 9 - 5
src/datawizard/user_interactions.c

@@ -477,7 +477,7 @@ int starpu_data_idle_prefetch_on_node(starpu_data_handle_t handle, unsigned node
 
 static void _starpu_data_wont_use(void *data)
 {
-	unsigned node, worker, nworkers = starpu_worker_get_count();
+	unsigned node;
 	starpu_data_handle_t handle = data;
 
 	_starpu_spin_lock(&handle->header_lock);
@@ -488,11 +488,15 @@ static void _starpu_data_wont_use(void *data)
 			_starpu_memchunk_wont_use(local->mc, node);
 	}
 	if (handle->per_worker)
-	for (worker = 0; worker < nworkers; worker++)
 	{
-		struct _starpu_data_replicate *local = &handle->per_worker[worker];
-		if (local->allocated && local->automatically_allocated)
-			_starpu_memchunk_wont_use(local->mc, starpu_worker_get_memory_node(worker));
+		unsigned nworkers = starpu_worker_get_count();
+		unsigned worker;
+		for (worker = 0; worker < nworkers; worker++)
+		{
+			struct _starpu_data_replicate *local = &handle->per_worker[worker];
+			if (local->allocated && local->automatically_allocated)
+				_starpu_memchunk_wont_use(local->mc, starpu_worker_get_memory_node(worker));
+		}
 	}
 	_starpu_spin_unlock(&handle->header_lock);
 	starpu_data_release_on_node(handle, STARPU_ACQUIRE_ALL_NODES);

+ 10 - 10
src/debug/traces/starpu_fxt.c

@@ -1251,15 +1251,17 @@ static void handle_codelet_details(struct fxt_ev_64 *ev, struct starpu_fxt_optio
 
 	if (worker < 0) return;
 
-	int i;
 	char parameters[256];
 	size_t eaten = 0;
 	if (!last_codelet_parameter[worker])
 		eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "nodata");
 	else
-	for (i = 0; i < last_codelet_parameter[worker] && i < MAX_PARAMETERS; i++)
 	{
-		eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "%s%s", i?"_":"", last_codelet_parameter_description[worker][i]);
+		int i;
+		for (i = 0; i < last_codelet_parameter[worker] && i < MAX_PARAMETERS; i++)
+		{
+			eaten += snprintf(parameters + eaten, sizeof(parameters) - eaten - 1, "%s%s", i?"_":"", last_codelet_parameter_description[worker][i]);
+		}
 	}
 	parameters[sizeof(parameters)-1] = 0;
 
@@ -1689,19 +1691,17 @@ static void handle_start_driver_copy(struct fxt_ev_64 *ev, struct starpu_fxt_opt
 
 static void handle_work_stealing(struct fxt_ev_64 *ev, struct starpu_fxt_options *options)
 {
-	unsigned dst = ev->param[0];
-	unsigned src = ev->param[1];
-	unsigned size = 0;
-
-	char *prefix = options->file_prefix;
-
-
 	if (out_paje_file)
 	{
+		unsigned dst = ev->param[0];
+		unsigned src = ev->param[1];
+		char *prefix = options->file_prefix;
+		unsigned size = 0;
 		double time = get_event_time_stamp(ev, options);
 #ifdef STARPU_HAVE_POTI
 		char paje_value[STARPU_POTI_STR_LEN], paje_key[STARPU_POTI_STR_LEN], src_worker_container[STARPU_POTI_STR_LEN], dst_worker_container[STARPU_POTI_STR_LEN];
 		char program_container[STARPU_POTI_STR_LEN];
+
 		snprintf(paje_value, STARPU_POTI_STR_LEN, "%u", size);
 		snprintf(paje_key, STARPU_POTI_STR_LEN, "steal_%u", steal_number);
 		program_container_alias(program_container, STARPU_POTI_STR_LEN, prefix);

+ 2 - 3
src/drivers/cpu/driver_cpu.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010-2015  CNRS
+ * Copyright (C) 2010-2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2014  INRIA
  *
@@ -51,7 +51,6 @@
 
 static int execute_job_on_cpu(struct _starpu_job *j, struct starpu_task *worker_task, struct _starpu_worker *cpu_args, int rank, struct starpu_perfmodel_arch* perf_arch)
 {
-	int ret;
 	int is_parallel_task = (j->task_size > 1);
 	int profiling = starpu_profiling_status_get();
 	struct timespec codelet_start, codelet_end;
@@ -70,7 +69,7 @@ static int execute_job_on_cpu(struct _starpu_job *j, struct starpu_task *worker_
 
 	if (rank == 0 && !continuation_wake_up)
 	{
-		ret = _starpu_fetch_task_input(j);
+		int ret = _starpu_fetch_task_input(j);
 		if (ret != 0)
 		{
 			/* there was not enough memory so the codelet cannot be executed right now ... */

+ 3 - 3
src/drivers/cuda/driver_cuda.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011, 2012, 2013, 2014  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -99,7 +99,6 @@ static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 	starpu_ssize_t limit;
 	size_t STARPU_ATTRIBUTE_UNUSED totalGlobalMem = 0;
 	size_t STARPU_ATTRIBUTE_UNUSED to_waste = 0;
-	char name[30];
 
 #ifdef STARPU_SIMGRID
 	totalGlobalMem = _starpu_simgrid_get_memsize("CUDA", devid);
@@ -111,6 +110,7 @@ static void _starpu_cuda_limit_gpu_mem_if_needed(unsigned devid)
 	limit = starpu_get_env_number("STARPU_LIMIT_CUDA_MEM");
 	if (limit == -1)
 	{
+		char name[30];
 		sprintf(name, "STARPU_LIMIT_CUDA_%u_MEM", devid);
 		limit = starpu_get_env_number(name);
 	}
@@ -247,7 +247,6 @@ done:
 #ifndef STARPU_SIMGRID
 static void init_device_context(unsigned devid)
 {
-	int workerid;
 	unsigned i;
 
 	cudaError_t cures;
@@ -260,6 +259,7 @@ static void init_device_context(unsigned devid)
 	if (starpu_get_env_number("STARPU_ENABLE_CUDA_GPU_GPU_DIRECT") != 0)
 	{
 		int nworkers = starpu_worker_get_count();
+		int workerid;
 		for (workerid = 0; workerid < nworkers; workerid++)
 		{
 			struct _starpu_worker *worker = _starpu_get_worker_struct(workerid);

+ 6 - 6
src/drivers/driver_common/driver_common.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2014, 2016  INRIA
  *
@@ -38,7 +38,6 @@ void _starpu_driver_start_job(struct _starpu_worker *worker, struct _starpu_job
 {
 	struct starpu_task *task = j->task;
 	struct starpu_codelet *cl = task->cl;
-	struct starpu_profiling_task_info *profiling_info;
 	int starpu_top=_starpu_top_status_get();
 	int workerid = worker->workerid;
 	unsigned calibrate_model = 0;
@@ -60,7 +59,7 @@ void _starpu_driver_start_job(struct _starpu_worker *worker, struct _starpu_job
 		STARPU_AYU_RUNTASK(j->job_id);
 		cl->per_worker_stats[workerid]++;
 
-		profiling_info = task->profiling_info;
+		struct starpu_profiling_task_info *profiling_info = task->profiling_info;
 
 		if ((profiling && profiling_info) || calibrate_model || starpu_top)
 		{
@@ -108,7 +107,6 @@ void _starpu_driver_end_job(struct _starpu_worker *worker, struct _starpu_job *j
 {
 	struct starpu_task *task = j->task;
 	struct starpu_codelet *cl = task->cl;
-	struct starpu_profiling_task_info *profiling_info = task->profiling_info;
 	int starpu_top=_starpu_top_status_get();
 	int workerid = worker->workerid;
 	unsigned calibrate_model = 0;
@@ -134,6 +132,7 @@ void _starpu_driver_end_job(struct _starpu_worker *worker, struct _starpu_job *j
 
 	if (rank == 0)
 	{
+		struct starpu_profiling_task_info *profiling_info = task->profiling_info;
 		if ((profiling && profiling_info) || calibrate_model || starpu_top)
 		{
 			_starpu_clock_gettime(codelet_end);
@@ -175,7 +174,6 @@ void _starpu_driver_update_job_feedback(struct _starpu_job *j, struct _starpu_wo
 {
 	struct starpu_profiling_task_info *profiling_info = j->task->profiling_info;
 	struct timespec measured_ts;
-	double measured;
 	int workerid = worker->workerid;
 	struct starpu_codelet *cl = j->task->cl;
 	int calibrate_model = 0;
@@ -190,6 +188,8 @@ void _starpu_driver_update_job_feedback(struct _starpu_job *j, struct _starpu_wo
 
 	if ((profiling && profiling_info) || calibrate_model)
 	{
+		double measured;
+
 		starpu_timespec_sub(codelet_end, codelet_start, &measured_ts);
 		measured = starpu_timing_timespec_to_us(&measured_ts);
 
@@ -258,7 +258,7 @@ void _starpu_driver_update_job_feedback(struct _starpu_job *j, struct _starpu_wo
 			j->cumulated_energy_consumed += energy_consumed;
 			do_update_energy_model = 0;
 		}
-		else 
+		else
 		{
 			if (j->discontinuous)
 			{

+ 1 - 1
src/drivers/gordon/driver_gordon.c

@@ -277,7 +277,7 @@ int inject_task_list(struct _starpu_job_list *list, struct _starpu_worker *worke
 {
 	/* first put back all tasks that can not be performed by Gordon */
 	unsigned nvalids = 0;
-	unsigned ninvalids = 0;
+//	unsigned ninvalids = 0;
 	struct _starpu_job *j;
 
 	// TODO !

+ 3 - 2
src/drivers/mic/driver_mic_sink.c

@@ -87,7 +87,7 @@ void _starpu_mic_sink_init(struct _starpu_mp_node *node)
  */
 void _starpu_mic_sink_launch_workers(struct _starpu_mp_node *node)
 {
-	int i, ret;
+	int i;
 	struct arg_sink_thread * arg;
 	cpu_set_t cpuset;
 	starpu_pthread_attr_t attr;
@@ -96,6 +96,8 @@ void _starpu_mic_sink_launch_workers(struct _starpu_mp_node *node)
 	/*for each core init the mutex, the task pointer and launch the thread */
 	for(i=0; i<node->nb_cores; i++)
 	{
+		int ret;
+
 		//init the set
 		CPU_ZERO(&cpuset);
 		CPU_SET(i,&cpuset);
@@ -114,7 +116,6 @@ void _starpu_mic_sink_launch_workers(struct _starpu_mp_node *node)
 		STARPU_ASSERT(ret == 0);
 		((starpu_pthread_t *)node->thread_table)[i] = thread;
 	}
-
 }
 
 /* Deinitialize the MIC sink, close all the connections.

+ 2 - 6
src/drivers/mp_common/source_common.c

@@ -403,8 +403,6 @@ static int _starpu_src_common_execute(struct _starpu_job *j,
 		struct _starpu_worker *worker,
 		struct _starpu_mp_node * node)
 {
-	int ret;
-
 	STARPU_ASSERT(j);
 	struct starpu_task *task = j->task;
 
@@ -413,7 +411,7 @@ static int _starpu_src_common_execute(struct _starpu_job *j,
 	STARPU_ASSERT(task);
 	if (worker->current_rank == 0)
 	{
-		ret = _starpu_fetch_task_input(j);
+		int ret = _starpu_fetch_task_input(j);
 		if (ret != 0)
 		{
 			/* there was not enough memory, so the input of
@@ -427,7 +425,6 @@ static int _starpu_src_common_execute(struct _starpu_job *j,
 
 	_starpu_driver_start_job(worker, j, &worker->perf_arch, &j->cl_start, 0, profiling);
 
-
 	//_STARPU_DEBUG("\nworkerid:%d, rank:%d, type:%d,	cb_workerid:%d, task_size:%d\n\n",worker->devid,worker->current_rank,task->cl->type,j->combined_workerid,j->task_size);
 
 	_starpu_src_common_execute_kernel(node, kernel, worker->subworkerid, task->cl->type,
@@ -687,7 +684,6 @@ void _starpu_src_common_worker(struct _starpu_worker_set * worker_set,
 	while (_starpu_machine_is_running())
 	{
 		int res = 0;
-		struct _starpu_job * j;
 
 		_starpu_may_pause();
 
@@ -723,7 +719,7 @@ void _starpu_src_common_worker(struct _starpu_worker_set * worker_set,
 			{
 				if(tasks[i] != NULL)
 				{
-					j = _starpu_get_job_associated_to_task(tasks[i]);
+					struct _starpu_job * j = _starpu_get_job_associated_to_task(tasks[i]);
 					_starpu_set_local_worker_key(&worker_set->workers[i]);
 					res =  _starpu_src_common_execute(j, &worker_set->workers[i], mp_node);
 					switch (res)

+ 5 - 5
src/drivers/opencl/driver_opencl.c

@@ -76,7 +76,6 @@ static void _starpu_opencl_limit_gpu_mem_if_needed(unsigned devid)
 	starpu_ssize_t limit;
 	size_t STARPU_ATTRIBUTE_UNUSED totalGlobalMem = 0;
 	size_t STARPU_ATTRIBUTE_UNUSED to_waste = 0;
-	char name[30];
 
 #ifdef STARPU_SIMGRID
 	totalGlobalMem = _starpu_simgrid_get_memsize("OpenCL", devid);
@@ -93,6 +92,7 @@ static void _starpu_opencl_limit_gpu_mem_if_needed(unsigned devid)
 	limit = starpu_get_env_number("STARPU_LIMIT_OPENCL_MEM");
 	if (limit == -1)
 	{
+		char name[30];
 		sprintf(name, "STARPU_LIMIT_OPENCL_%u_MEM", devid);
 		limit = starpu_get_env_number(name);
 	}
@@ -518,9 +518,9 @@ void _starpu_opencl_init(void)
                 err = clGetPlatformIDs(_STARPU_OPENCL_PLATFORM_MAX, platform_id, &nb_platforms);
                 if (STARPU_UNLIKELY(err != CL_SUCCESS)) nb_platforms=0;
                 _STARPU_DEBUG("Platforms detected: %u\n", nb_platforms);
-		_STARPU_DEBUG("CPU device type: %s\n", device_type&CL_DEVICE_TYPE_CPU?"requested":"not requested");
-		_STARPU_DEBUG("GPU device type: %s\n", device_type&CL_DEVICE_TYPE_GPU?"requested":"not requested");
-		_STARPU_DEBUG("Accelerator device type: %s\n", device_type&CL_DEVICE_TYPE_ACCELERATOR?"requested":"not requested");
+		_STARPU_DEBUG("CPU device type: %s\n", (device_type&CL_DEVICE_TYPE_CPU)?"requested":"not requested");
+		_STARPU_DEBUG("GPU device type: %s\n", (device_type&CL_DEVICE_TYPE_GPU)?"requested":"not requested");
+		_STARPU_DEBUG("Accelerator device type: %s\n", (device_type&CL_DEVICE_TYPE_ACCELERATOR)?"requested":"not requested");
 
                 // Get devices
                 nb_devices = 0;
@@ -556,7 +556,7 @@ void _starpu_opencl_init(void)
 				if (platform_valid)
 					_STARPU_DEBUG("Platform: %s - %s\n", name, vendor);
 				else
-					_STARPU_DEBUG("Platform invalid\n");
+					_STARPU_DEBUG("Platform invalid: %s - %s\n", name, vendor);
 #endif
 				if (platform_valid && nb_devices <= STARPU_MAXOPENCLDEVS)
 				{

+ 3 - 4
src/drivers/opencl/driver_opencl_utils.c

@@ -152,7 +152,7 @@ char *_starpu_opencl_load_program_source(const char *filename)
 	FILE        *fh;
 	char        *source;
 	int         x;
-	char        c;
+	int         c;
 	int         err;
 
 	fh = fopen(filename, "r");
@@ -163,9 +163,9 @@ char *_starpu_opencl_load_program_source(const char *filename)
 	STARPU_ASSERT_MSG(err == 0, "could not open file %s\n", filename);
 	_STARPU_MALLOC(source, statbuf.st_size + 1);
 
-	for(c=(char)fgetc(fh), x=0 ; c != EOF ; c =(char)fgetc(fh), x++)
+	for(c=fgetc(fh), x=0 ; c != EOF ; c =fgetc(fh), x++)
 	{
-		source[x] = c;
+		source[x] = (char)c;
 	}
 	source[x] = '\0';
 
@@ -178,7 +178,6 @@ char *_starpu_opencl_load_program_source(const char *filename)
 	return source;
 }
 
-
 static
 char *_starpu_opencl_load_program_binary(const char *filename, size_t *len)
 {

+ 0 - 1
src/drivers/scc/driver_scc_source.c

@@ -286,7 +286,6 @@ void *_starpu_scc_src_worker(void *arg)
 	int devid = args->devid;
 	int workerid = args->workerid;
 	struct _starpu_machine_config *config = args->config;
-	unsigned memnode = args->memory_node;
 	unsigned baseworkerid = args - config->workers;
 	unsigned subworkerid = args->subworkerid;
 	unsigned i;

+ 1 - 1
src/profiling/profiling_helpers.c

@@ -117,7 +117,7 @@ void starpu_profiling_worker_helper_display_summary(void)
 			fprintf(stderr, "\ttotal: %.2lf ms executing: %.2lf ms sleeping: %.2lf ms overhead %.2lf ms\n",
 				total_time, executing_time, sleeping_time, total_time - executing_time - sleeping_time);
 			if (info.used_cycles || info.stall_cycles)
-				fprintf(stderr, "\t%lu Mcy %lu Mcy stall\n", info.used_cycles/1000000, info.stall_cycles/1000000);
+				fprintf(stderr, "\t%llu Mcy %llu Mcy stall\n", (unsigned long long)info.used_cycles/1000000, (unsigned long long)info.stall_cycles/1000000);
 			if (info.energy_consumed)
 				fprintf(stderr, "\t%f J consumed\n", info.energy_consumed);
 			if (info.flops)

+ 2 - 2
src/sched_policies/component_heft.c

@@ -43,8 +43,7 @@ static int heft_progress_one(struct starpu_sched_component *component)
 	starpu_pthread_mutex_t * mutex = &data->mutex;
 	struct _starpu_prio_deque * prio = &data->prio;
 	struct starpu_task * (tasks[NTASKS]);
-
-	unsigned ntasks, n, i;
+	unsigned ntasks;
 
 	STARPU_PTHREAD_MUTEX_LOCK(mutex);
 	/* Try to look at NTASKS from the queue */
@@ -64,6 +63,7 @@ static int heft_progress_one(struct starpu_sched_component *component)
 	{
 		struct _starpu_mct_data * d = data->mct_data;
 		struct starpu_sched_component * best_component = NULL;
+		unsigned n, i;
 
 		/* Estimated task duration for each child */
 		double estimated_lengths[component->nchildren * ntasks];

+ 1 - 1
src/sched_policies/component_work_stealing.c

@@ -226,7 +226,7 @@ double _ws_estimated_load(struct starpu_sched_component * component)
 static int push_task(struct starpu_sched_component * component, struct starpu_task * task)
 {
 	struct _starpu_work_stealing_data * wsd = component->data;
-	int ret = -1;
+	int ret;
 	int i = wsd->last_push_child;
 	i = (i+1)%component->nchildren;
 

+ 4 - 4
src/sched_policies/component_worker.c

@@ -313,13 +313,13 @@ struct _starpu_combined_worker * _starpu_sched_component_combined_worker_get_com
 
 void _starpu_sched_component_lock_worker(unsigned sched_ctx_id, int workerid)
 {
-	STARPU_ASSERT(0 <= workerid && workerid < (int) starpu_worker_get_count());
+	STARPU_ASSERT(workerid >= 0 && workerid < (int) starpu_worker_get_count());
 	struct _starpu_worker_component_data * data = starpu_sched_component_worker_get(sched_ctx_id, workerid)->data;
 	STARPU_PTHREAD_MUTEX_LOCK(&data->lock);
 }
 void _starpu_sched_component_unlock_worker(unsigned sched_ctx_id, int workerid)
 {
-	STARPU_ASSERT(0 <= workerid && workerid < (int)starpu_worker_get_count());
+	STARPU_ASSERT(workerid >= 0  && workerid < (int)starpu_worker_get_count());
 	struct _starpu_worker_component_data * data = starpu_sched_component_worker_get(sched_ctx_id, workerid)->data;
 	STARPU_PTHREAD_MUTEX_UNLOCK(&data->lock);
 }
@@ -580,7 +580,7 @@ static void _worker_component_deinit_data(struct starpu_sched_component * compon
 
 static struct starpu_sched_component * starpu_sched_component_worker_create(struct starpu_sched_tree *tree, int workerid)
 {
-	STARPU_ASSERT(0 <=  workerid && workerid < (int) starpu_worker_get_count());
+	STARPU_ASSERT(workerid >= 0 && workerid < (int) starpu_worker_get_count());
 
 	if(_worker_components[tree->sched_ctx_id][workerid])
 		return _worker_components[tree->sched_ctx_id][workerid];
@@ -766,7 +766,7 @@ static double combined_worker_estimated_load(struct starpu_sched_component * com
 
 static struct starpu_sched_component  * starpu_sched_component_combined_worker_create(struct starpu_sched_tree *tree, int workerid)
 {
-	STARPU_ASSERT(0 <= workerid && workerid <  STARPU_NMAXWORKERS);
+	STARPU_ASSERT(workerid >= 0 && workerid <  STARPU_NMAXWORKERS);
 
 	if(_worker_components[tree->sched_ctx_id][workerid])
 		return _worker_components[tree->sched_ctx_id][workerid];

+ 17 - 20
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -225,7 +225,7 @@ static struct starpu_task *dmda_pop_task(unsigned sched_ctx_id)
 	/* Take the opportunity to update start time */
 	fifo->exp_start = STARPU_MAX(starpu_timing_now(), fifo->exp_start);
 
-	STARPU_ASSERT_MSG(fifo, "worker %d does not belong to ctx %d anymore.\n", workerid, sched_ctx_id);
+	STARPU_ASSERT_MSG(fifo, "worker %u does not belong to ctx %u anymore.\n", workerid, sched_ctx_id);
 
 	task = _starpu_fifo_pop_local_task(fifo);
 	if (task)
@@ -404,8 +404,8 @@ static int push_task_on_best_worker(struct starpu_task *task, int best_workerid,
 static int _dm_push_task(struct starpu_task *task, unsigned prio, unsigned sched_ctx_id)
 {
 	struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-	unsigned worker, worker_ctx = 0;
 	int best = -1;
+	unsigned worker_ctx = 0;
 
 	double best_exp_end = 0.0;
 	double model_best = 0.0;
@@ -419,8 +419,6 @@ static int _dm_push_task(struct starpu_task *task, unsigned prio, unsigned sched
 	int unknown = 0;
 
 	unsigned best_impl = 0;
-	unsigned nimpl;
-	unsigned impl_mask;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 
 	struct starpu_sched_ctx_iterator it;
@@ -428,7 +426,9 @@ static int _dm_push_task(struct starpu_task *task, unsigned prio, unsigned sched
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned nimpl;
+		unsigned impl_mask;
+		unsigned worker = workers->get_next(workers, &it);
 		struct _starpu_fifo_taskq *fifo  = dt->queue_array[worker];
 		unsigned memory_node = starpu_worker_get_memory_node(worker);
 		struct starpu_perfmodel_arch* perf_arch = starpu_worker_get_perf_archtype(worker, sched_ctx_id);
@@ -559,10 +559,8 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 
 	/* A priori, we know all estimations */
 	int unknown = 0;
-	unsigned worker, worker_ctx = 0;
+	unsigned worker_ctx = 0;
 
-	unsigned nimpl;
-	unsigned impl_mask;
 	int task_prio = 0;
 
 	starpu_task_bundle_t bundle = task->bundle;
@@ -577,7 +575,9 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned nimpl;
+		unsigned impl_mask;
+		unsigned worker = workers->get_next(workers, &it);
 		struct _starpu_fifo_taskq *fifo = dt->queue_array[worker];
 		struct starpu_perfmodel_arch* perf_arch = starpu_worker_get_perf_archtype(worker, sched_ctx_id);
 		unsigned memory_node = starpu_worker_get_memory_node(worker);
@@ -594,7 +594,7 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 				/* no one on that queue may execute this task */
 				continue;
 			}
-			STARPU_ASSERT_MSG(fifo != NULL, "worker %d ctx %d\n", worker, sched_ctx_id);
+			STARPU_ASSERT_MSG(fifo != NULL, "worker %u ctx %u\n", worker, sched_ctx_id);
 
 			int fifo_ntasks = fifo->ntasks;
 			double prev_exp_len = fifo->exp_len;
@@ -726,7 +726,6 @@ static void compute_all_performance_predictions(struct starpu_task *task,
 static double _dmda_push_task(struct starpu_task *task, unsigned prio, unsigned sched_ctx_id, unsigned simulate, unsigned sorted_decision)
 {
 	/* find the queue */
-	unsigned worker, worker_ctx = 0;
 	int best = -1, best_in_ctx = -1;
 	int selected_impl = 0;
 	double model_best = 0.0;
@@ -768,17 +767,17 @@ static double _dmda_push_task(struct starpu_task *task, unsigned prio, unsigned
 					    &forced_impl, sched_ctx_id, sorted_decision);
 
 
-	double best_fitness = -1;
-
-	unsigned nimpl;
-	unsigned impl_mask;
 	if (forced_best == -1)
 	{
+		double best_fitness = -1;
+		unsigned worker_ctx = 0;
 		struct starpu_sched_ctx_iterator it;
 		workers->init_iterator_for_parallel_tasks(workers, &it, task);
 		while(workers->has_next(workers, &it))
 		{
-			worker = workers->get_next(workers, &it);
+			unsigned worker = workers->get_next(workers, &it);
+			unsigned nimpl;
+			unsigned impl_mask;
 
 			if (!starpu_worker_can_execute_task_impl(worker, task, &impl_mask))
 				continue;
@@ -904,11 +903,10 @@ static void dmda_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nwo
 {
 	struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
 
-	int workerid;
 	unsigned i;
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		/* if the worker has alreadry belonged to this context
 		   the queue and the synchronization variables have been already initialized */
 		if(dt->queue_array[workerid] == NULL)
@@ -932,11 +930,10 @@ static void dmda_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned
 {
 	struct _starpu_dmda_data *dt = (struct _starpu_dmda_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
 
-	int workerid;
 	unsigned i;
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		if(dt->queue_array[workerid] != NULL)
 		{
 			if(dt->num_priorities != -1)

+ 4 - 7
src/sched_policies/eager_central_policy.c

@@ -83,9 +83,8 @@ static int push_task_eager_policy(struct starpu_task *task)
 
 	/*if there are no tasks block */
 	/* wake people waiting for a task */
-	unsigned worker = 0;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
-	
+
 	struct starpu_sched_ctx_iterator it;
 #ifndef STARPU_NON_BLOCKING_DRIVERS
 	char dowake[STARPU_NMAXWORKERS] = { 0 };
@@ -94,7 +93,7 @@ static int push_task_eager_policy(struct starpu_task *task)
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
 		if (!starpu_bitmap_get(data->waiters, worker))
@@ -123,7 +122,7 @@ static int push_task_eager_policy(struct starpu_task *task)
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		if (dowake[worker])
 			if (starpu_wake_worker(worker))
 				break; // wake up a single worker
@@ -195,12 +194,10 @@ static struct starpu_task *pop_task_eager_policy(unsigned sched_ctx_id)
 
 static void eager_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
-
-	int workerid;
 	unsigned i;
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		int curr_workerid = _starpu_worker_get_id();
 		if(workerid != curr_workerid)
 			starpu_wake_worker(workerid);

+ 4 - 8
src/sched_policies/eager_central_priority_policy.c

@@ -137,7 +137,6 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 
 	/*if there are no tasks block */
 	/* wake people waiting for a task */
-	unsigned worker = 0;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 
 	struct starpu_sched_ctx_iterator it;
@@ -148,7 +147,7 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
 		if (!starpu_bitmap_get(data->waiters, worker))
@@ -177,7 +176,7 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		if (dowake[worker])
 			if (starpu_wake_worker(worker))
 				break; // wake up a single worker
@@ -254,14 +253,13 @@ static struct starpu_task *_starpu_priority_pop_task(unsigned sched_ctx_id)
 	if (!chosen_task && skipped)
 	{
 		/* Notify another worker to do that task */
-		unsigned worker = 0;
 		struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 
 		struct starpu_sched_ctx_iterator it;
 		workers->init_iterator_for_parallel_tasks(workers, &it, chosen_task);
 		while(workers->has_next(workers, &it))
 		{
-			worker = workers->get_next(workers, &it);
+			unsigned worker = workers->get_next(workers, &it);
 
 			if(worker != workerid)
 			{
@@ -303,12 +301,10 @@ static struct starpu_task *_starpu_priority_pop_task(unsigned sched_ctx_id)
 
 static void eager_center_priority_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
-
-        int workerid;
 	unsigned i;
         for (i = 0; i < nworkers; i++)
         {
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		int curr_workerid = _starpu_worker_get_id();
 		if(workerid != curr_workerid)
 			starpu_wake_worker(workerid);

+ 3 - 7
src/sched_policies/fifo_queues.c

@@ -282,17 +282,13 @@ struct starpu_task *_starpu_fifo_pop_local_task(struct _starpu_fifo_taskq *fifo_
 /* pop every task that can be executed on the calling driver */
 struct starpu_task *_starpu_fifo_pop_every_task(struct _starpu_fifo_taskq *fifo_queue, int workerid)
 {
-	struct starpu_task_list *old_list;
-	unsigned size;
-
+	unsigned size = fifo_queue->ntasks;
 	struct starpu_task *new_list = NULL;
-	struct starpu_task *new_list_tail = NULL;
-
-	size = fifo_queue->ntasks;
 
 	if (size > 0)
 	{
-		old_list = &fifo_queue->taskq;
+		struct starpu_task_list *old_list = &fifo_queue->taskq;
+		struct starpu_task *new_list_tail = NULL;
 		unsigned new_list_size = 0;
 
 		struct starpu_task *task, *next_task;

+ 6 - 9
src/sched_policies/graph_test_policy.c

@@ -96,13 +96,12 @@ static struct _starpu_prio_deque *select_prio(unsigned sched_ctx_id, struct _sta
 	double gpu_speed = 0.;
 
 	/* Compute how fast CPUs can compute it, and how fast GPUs can compute it */
-	unsigned worker;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 	struct starpu_sched_ctx_iterator it;
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		if (!starpu_worker_can_execute_task(worker, task, 0))
 			/* This worker can not execute this task, don't count it */
 			continue;
@@ -181,7 +180,6 @@ static void do_schedule_graph_test_policy(unsigned sched_ctx_id)
 	}
 
 	/* And unleash the beast! */
-	unsigned worker;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 	struct starpu_sched_ctx_iterator it;
 #ifdef STARPU_NON_BLOCKING_DRIVERS
@@ -189,7 +187,7 @@ static void do_schedule_graph_test_policy(unsigned sched_ctx_id)
 	while(workers->has_next(workers, &it))
 	{
 		/* Tell each worker is shouldn't sleep any more */
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		starpu_bitmap_unset(data->waiters, worker);
 	}
 #endif
@@ -200,7 +198,7 @@ static void do_schedule_graph_test_policy(unsigned sched_ctx_id)
 	while(workers->has_next(workers, &it))
 	{
 		/* Wake each worker */
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		starpu_wake_worker(worker);
 	}
 #endif
@@ -231,9 +229,8 @@ static int push_task_graph_test_policy(struct starpu_task *task)
 
 	/*if there are no tasks block */
 	/* wake people waiting for a task */
-	unsigned worker = 0;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
-	
+
 	struct starpu_sched_ctx_iterator it;
 #ifndef STARPU_NON_BLOCKING_DRIVERS
 	char dowake[STARPU_NMAXWORKERS] = { 0 };
@@ -242,7 +239,7 @@ static int push_task_graph_test_policy(struct starpu_task *task)
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
 		if (!starpu_bitmap_get(data->waiters, worker))
@@ -277,7 +274,7 @@ static int push_task_graph_test_policy(struct starpu_task *task)
 	workers->init_iterator_for_parallel_tasks(workers, &it, task);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		if (dowake[worker])
 			if (starpu_wake_worker(worker))
 				break; // wake up a single worker

+ 6 - 9
src/sched_policies/heteroprio.c

@@ -260,7 +260,7 @@ static void initialize_heteroprio_policy(unsigned sched_ctx_id)
 				nb_arch_on_bucket += 1;
 			}
 		}
-		STARPU_ASSERT_MSG(check_all_archs[idx_prio] == nb_arch_on_bucket, "check_all_archs[idx_prio(%d)] = %d != nb_arch_on_bucket = %d\n", idx_prio, check_all_archs[idx_prio], nb_arch_on_bucket);
+		STARPU_ASSERT_MSG(check_all_archs[idx_prio] == nb_arch_on_bucket, "check_all_archs[idx_prio(%u)] = %u != nb_arch_on_bucket = %u\n", idx_prio, check_all_archs[idx_prio], nb_arch_on_bucket);
 	}
 }
 
@@ -293,11 +293,10 @@ static void add_workers_heteroprio_policy(unsigned sched_ctx_id, int *workerids,
 {
 	struct _starpu_heteroprio_data *hp = (struct _starpu_heteroprio_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
 
-	int workerid;
 	unsigned i;
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		memset(&hp->workers_heteroprio[workerid], 0, sizeof(hp->workers_heteroprio[workerid]));
 		/* if the worker has already belonged to this context
 		   the queue and the synchronization variables have been already initialized */
@@ -338,12 +337,11 @@ static void add_workers_heteroprio_policy(unsigned sched_ctx_id, int *workerids,
 static void remove_workers_heteroprio_policy(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
 	struct _starpu_heteroprio_data *hp = (struct _starpu_heteroprio_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-
-	int workerid;
 	unsigned i;
+
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		if(hp->workers_heteroprio[workerid].tasks_queue != NULL)
 		{
 			_starpu_destroy_fifo(hp->workers_heteroprio[workerid].tasks_queue);
@@ -386,7 +384,6 @@ static int push_task_heteroprio_policy(struct starpu_task *task)
 
 	/*if there are no tasks_queue block */
 	/* wake people waiting for a task */
-	unsigned worker = 0;
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 
 	struct starpu_sched_ctx_iterator it;
@@ -397,7 +394,7 @@ static int push_task_heteroprio_policy(struct starpu_task *task)
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 
 #ifdef STARPU_NON_BLOCKING_DRIVERS
 		if (!starpu_bitmap_get(hp->waiters, worker))
@@ -426,7 +423,7 @@ static int push_task_heteroprio_policy(struct starpu_task *task)
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
 		if (dowake[worker])
 			if (starpu_wake_worker(worker))
 				break; // wake up a single worker

+ 3 - 5
src/sched_policies/parallel_eager.c

@@ -108,11 +108,10 @@ static void peager_add_workers(unsigned sched_ctx_id, int *workerids, unsigned n
 static void peager_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
 	struct _starpu_peager_data *data = (struct _starpu_peager_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-	int workerid;
 	unsigned i;
 	for(i = 0; i < nworkers; i++)
         {
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		if(!starpu_worker_is_combined_worker(workerid))
 			_starpu_destroy_fifo(data->local_fifo[workerid]);
 	}
@@ -145,7 +144,7 @@ static void deinitialize_peager_policy(unsigned sched_ctx_id)
 static int push_task_peager_policy(struct starpu_task *task)
 {
 	unsigned sched_ctx_id = task->sched_ctx;
-	int ret_val = -1;
+	int ret_val;
 
 	struct _starpu_peager_data *data = (struct _starpu_peager_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
 
@@ -160,12 +159,11 @@ static int push_task_peager_policy(struct starpu_task *task)
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 
 	struct starpu_sched_ctx_iterator it;
-	int worker = -1;
 
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		int worker = workers->get_next(workers, &it);
 		int master = data->master_id[worker];
 		/* If this is not a CPU or a MIC, then the worker simply grabs tasks from the fifo */
 		if ((!starpu_worker_is_combined_worker(worker) &&

+ 2 - 3
src/sched_policies/parallel_heft.c

@@ -418,10 +418,10 @@ static int _parallel_heft_push_task(struct starpu_task *task, unsigned prio, uns
 		forced_nimpl = nimpl_best;
 	}
 
-	double best_fitness = -1;
 
 	if (forced_best == -1)
 	{
+		double best_fitness = -1;
 		worker_ctx = 0;
 		while(workers->has_next(workers, &it))
 		{
@@ -503,11 +503,10 @@ static int parallel_heft_push_task(struct starpu_task *task)
 
 static void parallel_heft_add_workers(__attribute__((unused)) unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
-	int workerid;
 	unsigned i;
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		struct _starpu_worker *workerarg = _starpu_get_worker_struct(workerid);
 		/* init these structures only once for each worker */
 		if(!workerarg->has_prev_init)

+ 2 - 2
src/sched_policies/prio_deque.c

@@ -137,7 +137,7 @@ struct starpu_task * _starpu_prio_deque_pop_task(struct _starpu_prio_deque * pde
 struct starpu_task * _starpu_prio_deque_pop_task_for_worker(struct _starpu_prio_deque * pdeque, int workerid)
 {
 	STARPU_ASSERT(pdeque);
-	STARPU_ASSERT(0 <= workerid && (unsigned) workerid < starpu_worker_get_count());
+	STARPU_ASSERT(workerid >= 0 && (unsigned) workerid < starpu_worker_get_count());
 	REMOVE_TASK(pdeque, head, prev, pred_can_execute, &workerid);
 }
 
@@ -151,6 +151,6 @@ struct starpu_task * _starpu_prio_deque_deque_task(struct _starpu_prio_deque * p
 struct starpu_task * _starpu_prio_deque_deque_task_for_worker(struct _starpu_prio_deque * pdeque, int workerid)
 {
 	STARPU_ASSERT(pdeque);
-	STARPU_ASSERT(0 <= workerid && (unsigned) workerid < starpu_worker_get_count());
+	STARPU_ASSERT(workerid >= 0 && (unsigned) workerid < starpu_worker_get_count());
 	REMOVE_TASK(pdeque, tail, next, pred_can_execute, &workerid);
 }

+ 6 - 6
src/sched_policies/scheduler_maker.c

@@ -127,7 +127,7 @@ static int is_same_kind_of_all(struct starpu_sched_component * root, struct _sta
 		struct _starpu_worker * w = root->data;
 		return w->perf_arch.type == w_ref->perf_arch.type;
 	}
-	
+
 	int i;
 	for(i = 0;i < root->nchildren; i++)
 		if(!is_same_kind_of_all(root->children[i], w_ref))
@@ -150,7 +150,7 @@ static struct starpu_sched_component * find_mem_component(struct starpu_sched_co
 			tmp = tmp->parent;
 		}
 		while(!component);
-		
+
 	}
 	return component;
 }
@@ -243,7 +243,7 @@ static void helper_display_scheduler(FILE* out, unsigned depth, struct starpu_sc
 struct starpu_sched_tree * starpu_sched_component_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_component_specs specs)
 {
 	struct starpu_sched_tree * tree = starpu_sched_tree_create(sched_ctx_id);
-	
+
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
 	hwloc_topology_t topology = config->topology.hwtopology;
 
@@ -252,12 +252,12 @@ struct starpu_sched_tree * starpu_sched_component_make_scheduler(unsigned sched_
 
 	tree->root = list.arr[0];
 	destroy_list(&list);
-	
+
 	unsigned i;
 	for(i = 0; i < starpu_worker_get_count(); i++)
 	{
-		struct _starpu_worker * worker = _starpu_get_worker_struct(i);
-		struct starpu_sched_component * worker_component = starpu_sched_component_worker_get(sched_ctx_id, i);
+		struct _starpu_worker *worker = _starpu_get_worker_struct(i);
+		struct starpu_sched_component *worker_component = starpu_sched_component_worker_get(sched_ctx_id, i);
 		STARPU_ASSERT(worker);
 		set_worker_leaf(tree->root,worker_component, sched_ctx_id, specs);
 	}

+ 18 - 33
src/sched_policies/work_stealing_policy.c

@@ -60,7 +60,8 @@
 #define MAX_LOCALITY 8
 
 /* Entry for queued_tasks_per_data: records that a queued task is accessing the data with locality flag */
-struct locality_entry {
+struct locality_entry
+{
 	UT_hash_handle hh;
 	starpu_data_handle_t data;
 	struct starpu_task *task;
@@ -185,10 +186,10 @@ static unsigned select_worker_locality(struct _starpu_work_stealing_data *ws, st
 	unsigned i, n;
 	unsigned ndata[STARPU_NMAXWORKERS] = { 0 };
 	int best_worker = -1;
-	unsigned best_ndata = 0;
 
 	n = 0;
 	for (i = 0; i < nbuffers; i++)
+	{
 		if (STARPU_TASK_GET_MODE(task, i) & STARPU_LOCALITY)
 		{
 			starpu_data_handle_t data = STARPU_TASK_GET_HANDLE(task, i);
@@ -197,15 +198,16 @@ static unsigned select_worker_locality(struct _starpu_work_stealing_data *ws, st
 				ndata[locality]++;
 			n++;
 		}
+	}
 
 	if (n)
 	{
 		/* Some locality buffers, choose worker which has most of them */
-
 		struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 		struct starpu_sched_ctx_iterator it;
-		workers->init_iterator(workers, &it);
+		unsigned best_ndata = 0;
 
+		workers->init_iterator(workers, &it);
 		while(workers->has_next(workers, &it))
 		{
 			int workerid = workers->get_next(workers, &it);
@@ -412,8 +414,6 @@ static float overload_metric(struct _starpu_work_stealing_data *ws, unsigned sch
  */
 static int select_victim_overload(struct _starpu_work_stealing_data *ws, unsigned sched_ctx_id)
 {
-	unsigned worker;
-	float  worker_ratio;
 	unsigned best_worker = 0;
 	float best_ratio = FLT_MIN;
 
@@ -423,14 +423,13 @@ static int select_victim_overload(struct _starpu_work_stealing_data *ws, unsigne
 		return select_victim_round_robin(ws, sched_ctx_id);
 
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
-
 	struct starpu_sched_ctx_iterator it;
 
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-                worker = workers->get_next(workers, &it);
-		worker_ratio = overload_metric(ws, sched_ctx_id, worker);
+                unsigned worker = workers->get_next(workers, &it);
+		float worker_ratio = overload_metric(ws, sched_ctx_id, worker);
 
 		if (worker_ratio > best_ratio && ws->per_worker[worker].busy)
 		{
@@ -452,8 +451,6 @@ static int select_victim_overload(struct _starpu_work_stealing_data *ws, unsigne
 static unsigned select_worker_overload(struct _starpu_work_stealing_data *ws, struct starpu_task *task, unsigned sched_ctx_id)
 {
 	struct _starpu_work_stealing_data *ws = (struct _starpu_work_stealing_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-	unsigned worker;
-	float  worker_ratio;
 	unsigned best_worker = 0;
 	float best_ratio = FLT_MAX;
 
@@ -463,18 +460,15 @@ static unsigned select_worker_overload(struct _starpu_work_stealing_data *ws, st
 		return select_worker_round_robin(task, sched_ctx_id);
 
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
-
 	struct starpu_sched_ctx_iterator it;
 
 	workers->init_iterator(workers, &it);
 	while(workers->has_next(workers, &it))
 	{
-		worker = workers->get_next(workers, &it);
+		unsigned worker = workers->get_next(workers, &it);
+		float worker_ratio = overload_metric(ws, sched_ctx_id, worker);
 
-		worker_ratio = overload_metric(ws, sched_ctx_id, worker);
-
-		if (worker_ratio < best_ratio &&
-			starpu_worker_can_execute_task_first_impl(worker, task, NULL))
+		if (worker_ratio < best_ratio && starpu_worker_can_execute_task_first_impl(worker, task, NULL))
 		{
 			best_worker = worker;
 			best_ratio = worker_ratio;
@@ -638,17 +632,15 @@ int ws_push_task(struct starpu_task *task)
 static void ws_add_workers(unsigned sched_ctx_id, int *workerids,unsigned nworkers)
 {
 	struct _starpu_work_stealing_data *ws = (struct _starpu_work_stealing_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-
 	unsigned i;
-	int workerid;
 
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 		starpu_sched_ctx_worker_shares_tasks_lists(workerid, sched_ctx_id);
 		ws->per_worker[workerid].queue_array = _starpu_create_fifo();
 
-		/* Tell helgrid that we are fine with getting outdated values,
+		/* Tell helgrind that we are fine with getting outdated values,
 		 * this is just an estimation */
 		STARPU_HG_DISABLE_CHECKING(ws->per_worker[workerid].queue_array->ntasks);
 		STARPU_PTHREAD_MUTEX_INIT(&ws->per_worker[workerid].worker_mutex, NULL);
@@ -660,13 +652,11 @@ static void ws_add_workers(unsigned sched_ctx_id, int *workerids,unsigned nworke
 static void ws_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
 	struct _starpu_work_stealing_data *ws = (struct _starpu_work_stealing_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-
 	unsigned i;
-	int workerid;
 
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
+		int workerid = workerids[i];
 
 		if (ws->per_worker[workerid].queue_array != NULL)
 		{
@@ -727,12 +717,10 @@ struct starpu_sched_policy _starpu_sched_ws_policy =
 static int lws_select_victim(struct _starpu_work_stealing_data *ws, unsigned sched_ctx_id, int workerid)
 {
 	int nworkers = starpu_sched_ctx_get_nworkers(sched_ctx_id);
-	int neighbor;
 	int i;
-
 	for (i = 0; i < nworkers; i++)
 	{
-		neighbor = ws->per_worker[workerid].proxlist[i];
+		int neighbor = ws->per_worker[workerid].proxlist[i];
 		int ntasks = ws->per_worker[neighbor].queue_array->ntasks;
 		if (ntasks && ws->per_worker[workerid].busy)
 			return neighbor;
@@ -754,17 +742,14 @@ static void lws_add_workers(unsigned sched_ctx_id, int *workerids,
 	 * stolen */
 	struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 	struct starpu_tree *tree = (struct starpu_tree*)workers->collection_private;
-	int workerid;
 	unsigned i;
 	for (i = 0; i < nworkers; i++)
 	{
-		workerid = workerids[i];
-		_STARPU_MALLOC(ws->per_worker[workerid].proxlist, nworkers*sizeof(int));
+		int workerid = workerids[i];
+		_STARPU_MALLOC(ws->per_worker[workerid].proxlist, STARPU_NMAXWORKERS*sizeof(int));
 		int bindid;
 
-		struct starpu_tree *neighbour = NULL;
 		struct starpu_sched_ctx_iterator it;
-
 		workers->init_iterator(workers, &it);
 
 		bindid   = starpu_worker_get_bindid(workerid);
@@ -772,7 +757,7 @@ static void lws_add_workers(unsigned sched_ctx_id, int *workerids,
 		int cnt = 0;
 		for(;;)
 		{
-			neighbour = (struct starpu_tree*)it.value;
+			struct starpu_tree *neighbour = (struct starpu_tree*)it.value;
 			int *neigh_workerids;
 			int neigh_nworkers = starpu_bindid_get_workerids(neighbour->id, &neigh_workerids);
 			int w;

+ 6 - 4
src/util/openmp_runtime_support_environment.c

@@ -542,7 +542,6 @@ static void read_proc_bind_var()
 	static const char *strings[] = { "false", "true", "master", "close", "spread", NULL };
 	const int max_levels = _initial_icv_values.max_active_levels_var + 1;
 	int *bind_list = NULL;
-	int level = 0;
 	char *env;
 
 	_STARPU_CALLOC(bind_list, max_levels, sizeof(*bind_list));
@@ -551,9 +550,11 @@ static void read_proc_bind_var()
 	if (env)
 	{
 		char *saveptr, *token;
+		int level = 0;
 
 		token = strtok_r(env, ",", &saveptr);
-		for (; token != NULL; token = strtok_r(NULL, ",", &saveptr)) {
+		for (; token != NULL; token = strtok_r(NULL, ",", &saveptr))
+		{
 			int value;
 
 			if (!read_string_var(token, strings, &value))
@@ -572,7 +573,6 @@ static void read_num_threads_var()
 {
 	const int max_levels = _initial_icv_values.max_active_levels_var + 1;
 	int *num_threads_list = NULL;
-	int level = 0;
 	char *env;
 
 	_STARPU_CALLOC(num_threads_list, max_levels, sizeof(*num_threads_list));
@@ -581,9 +581,11 @@ static void read_num_threads_var()
 	if (env)
 	{
 		char *saveptr, *token;
+		int level = 0;
 
 		token = strtok_r(env, ",", &saveptr);
-		for (; token != NULL; token = strtok_r(NULL, ",", &saveptr)) {
+		for (; token != NULL; token = strtok_r(NULL, ",", &saveptr))
+		{
 			int value;
 
 			if (!read_int_var(token, &value))

+ 4 - 5
src/util/starpu_task_insert_utils.c

@@ -215,9 +215,8 @@ void _starpu_task_insert_check_nb_buffers(struct starpu_codelet *cl, struct star
 static inline void starpu_task_insert_process_data_arg(struct starpu_codelet *cl, struct starpu_task **task, int arg_type, starpu_data_handle_t handle, int *current_buffer, int *allocated_buffers)
 {
 	enum starpu_data_access_mode mode = (enum starpu_data_access_mode) arg_type & ~STARPU_SSEND;
-	STARPU_ASSERT_MSG(cl->nbuffers == STARPU_VARIABLE_NBUFFERS || *current_buffer < cl->nbuffers, "Too many data passed to starpu_task_insert");
-
 	STARPU_ASSERT(cl != NULL);
+	STARPU_ASSERT_MSG(cl->nbuffers == STARPU_VARIABLE_NBUFFERS || *current_buffer < cl->nbuffers, "Too many data passed to starpu_task_insert");
 
 	_starpu_task_insert_check_nb_buffers(cl, task, allocated_buffers, *current_buffer);
 
@@ -506,7 +505,7 @@ int _fstarpu_task_insert_create(struct starpu_codelet *cl, struct starpu_task **
 		{
 			arg_i++;
 			starpu_data_handle_t handle = arglist[arg_i];
-			starpu_task_insert_process_data_arg(cl, &(*task), arg_type, handle, &current_buffer, &allocated_buffers);
+			starpu_task_insert_process_data_arg(cl, task, arg_type, handle, &current_buffer, &allocated_buffers);
 		}
 		else if (arg_type == STARPU_DATA_ARRAY)
 		{
@@ -514,7 +513,7 @@ int _fstarpu_task_insert_create(struct starpu_codelet *cl, struct starpu_task **
 			starpu_data_handle_t *handles = arglist[arg_i];
 			arg_i++;
 			int nb_handles = *(int *)arglist[arg_i];
-			starpu_task_insert_process_data_array_arg(cl, &(*task), nb_handles, handles, &current_buffer, &allocated_buffers);
+			starpu_task_insert_process_data_array_arg(cl, task, nb_handles, handles, &current_buffer, &allocated_buffers);
 		}
 		else if (arg_type == STARPU_DATA_MODE_ARRAY)
 		{
@@ -522,7 +521,7 @@ int _fstarpu_task_insert_create(struct starpu_codelet *cl, struct starpu_task **
 			struct starpu_data_descr *descrs = arglist[arg_i];
 			arg_i++;
 			int nb_descrs = *(int *)arglist[arg_i];
-			starpu_task_insert_process_data_mode_array_arg(cl, &(*task), nb_descrs, descrs, &current_buffer, &allocated_buffers);
+			starpu_task_insert_process_data_mode_array_arg(cl, task, nb_descrs, descrs, &current_buffer, &allocated_buffers);
 		}
 		else if (arg_type == STARPU_VALUE)
 		{