소스 검색

fixes for minor warning detected by cppcheck

Nathalie Furmento 8 년 전
부모
커밋
5c18303944

+ 3 - 3
gcc-plugin/examples/cholesky/cholesky.c

@@ -137,7 +137,7 @@ int main(int argc, char **argv)
 		{
 			for(x=0 ; x<nblocks ; x++)
 			{
-                                printf("Block %d,%d :\n", x, y);
+                                printf("Block %u,%u :\n", x, y);
 				for (j = 0; j < BLOCKSIZE; j++)
 				{
 					for (i = 0; i < BLOCKSIZE; i++)
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
 		{
 			for(x=0 ; x<nblocks ; x++)
 			{
-                                printf("Block %d,%d :\n", x, y);
+                                printf("Block %u,%u :\n", x, y);
 				for (j = 0; j < BLOCKSIZE; j++)
 				{
 					for (i = 0; i < BLOCKSIZE; i++)
@@ -237,7 +237,7 @@ int main(int argc, char **argv)
 									float orig = (1.0f/(1.0f+i+j)) + ((i == j)?1.0f*size:0.0f);
 									float err = abs(test_mat[j +i*size] - orig);
 									if (err > 0.00001) {
-										fprintf(stderr, "Error[%d, %d] --> %2.2f != %2.2f (err %2.2f)\n", i, j, test_mat[j +i*size], orig, err);
+										fprintf(stderr, "Error[%u, %u] --> %2.2f != %2.2f (err %2.2f)\n", i, j, test_mat[j +i*size], orig, err);
 										correctness = 0;
 										break;
 									}

+ 1 - 1
socl/examples/basicsplit/basicsplit.c

@@ -203,7 +203,7 @@ int main(int UNUSED(argc), char** UNUSED(argv)) {
   cl_uint niter = 15;
 
    for (i=0; i<niter; i++) {
-      printf("Iteration %d...\n", i);
+      printf("Iteration %u...\n", i);
      add(cq, SIZE, s1, s2, d, 0, NULL, NULL);
       printf("Finishing iteration...\n");
       clFinish(cq);

+ 2 - 2
socl/src/cl_createbuffer.c

@@ -127,8 +127,8 @@ soclCreateBuffer(cl_context   context,
    }
 
    // Access mode
-   mem->mode = flags & CL_MEM_READ_ONLY  ? CL_MEM_READ_ONLY :
-               flags & CL_MEM_WRITE_ONLY ? CL_MEM_WRITE_ONLY : CL_MEM_READ_WRITE;
+   mem->mode = (flags & CL_MEM_READ_ONLY) ? CL_MEM_READ_ONLY :
+	   (flags & CL_MEM_WRITE_ONLY) ? CL_MEM_WRITE_ONLY : CL_MEM_READ_WRITE;
 
    // Perform data copy if necessary
    if (flags & CL_MEM_COPY_HOST_PTR)

+ 2 - 2
src/core/dependencies/tags.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2013, 2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  * Copyright (C) 2016  Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -108,7 +108,7 @@ static void _starpu_tag_free(void *_tag)
 			struct _starpu_cg *cg = tag->tag_successors.succ[succ];
 
 			unsigned ntags = STARPU_ATOMIC_ADD(&cg->ntags, -1);
-			unsigned remaining STARPU_ATTRIBUTE_UNUSED = STARPU_ATOMIC_ADD(&cg->remaining, -1);
+			unsigned STARPU_ATTRIBUTE_UNUSED remaining = STARPU_ATOMIC_ADD(&cg->remaining, -1);
 
 			if (!ntags && (cg->cg_type == STARPU_CG_TAG))
 				/* Last tag this cg depends on, cg becomes unreferenced */

+ 3 - 3
src/core/simgrid.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012-2016  Université de Bordeaux
  * Copyright (C) 2016  	    Inria
- * Copyright (C) 2016  	    CNRS
+ * Copyright (C) 2016, 2017  	    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
@@ -101,7 +101,7 @@ int _starpu_simgrid_get_nbhosts(const char *prefix)
 		STARPU_ASSERT(starpu_mpi_world_rank);
 		snprintf(name, sizeof(name), STARPU_MPI_AS_PREFIX"%u", starpu_mpi_world_rank());
 		hosts = MSG_environment_as_get_hosts(_starpu_simgrid_get_as_by_name(name));
-		len = snprintf(new_prefix, sizeof(new_prefix), "%s-%s", name, prefix);
+		snprintf(new_prefix, sizeof(new_prefix), "%s-%s", name, prefix);
 		prefix = new_prefix;
 		len = strlen(prefix);
 	}
@@ -700,7 +700,7 @@ _starpu_simgrid_get_memnode_host(unsigned node)
 	switch (starpu_node_get_kind(node))
 	{
 		case STARPU_CPU_RAM:
-			fmt = "RAM";
+			fmt = "RAM%u";
 			break;
 		case STARPU_CUDA_RAM:
 			fmt = "CUDA%u";

+ 2 - 1
src/core/topology.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, 2015, 2016 CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 CNRS
  * Copyright (C) 2011, 2016  INRIA
  * Copyright (C) 2016  Uppsala University
  *
@@ -123,6 +123,7 @@ _starpu_get_worker_from_driver(struct starpu_driver *d)
 #endif
 
 			default:
+				(void) worker;
 				_STARPU_DEBUG("Invalid device type\n");
 				return NULL;
 			}

+ 5 - 1
src/core/workers.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, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2010, 2011  INRIA
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011-2012, 2016  INRIA
@@ -2069,6 +2069,7 @@ starpu_driver_run(struct starpu_driver *d)
 		return _starpu_run_opencl(worker);
 #endif
 	default:
+		(void) worker;
 		_STARPU_DEBUG("Invalid device type\n");
 		return -EINVAL;
 	}
@@ -2095,6 +2096,7 @@ starpu_driver_init(struct starpu_driver *d)
 		return _starpu_opencl_driver_init(worker);
 #endif
 	default:
+		(void) worker;
 		return -EINVAL;
 	}
 }
@@ -2120,6 +2122,7 @@ starpu_driver_run_once(struct starpu_driver *d)
 		return _starpu_opencl_driver_run_once(worker);
 #endif
 	default:
+		(void) worker;
 		return -EINVAL;
 	}
 }
@@ -2145,6 +2148,7 @@ starpu_driver_deinit(struct starpu_driver *d)
 		return _starpu_opencl_driver_deinit(worker);
 #endif
 	default:
+		(void) worker;
 		return -EINVAL;
 	}
 }

+ 2 - 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, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016, 2017  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2016  Uppsala University
  *
@@ -267,8 +267,6 @@ done:
 
 static void init_device_context(unsigned devid, unsigned memnode)
 {
-	unsigned i;
-
 #ifndef STARPU_SIMGRID
 	cudaError_t cures;
 
@@ -351,6 +349,7 @@ static void init_device_context(unsigned devid, unsigned memnode)
 	if (STARPU_UNLIKELY(cures))
 		STARPU_CUDA_REPORT_ERROR(cures);
 
+	unsigned i;
 	for (i = 0; i < ncudagpus; i++)
 	{
 		cures = starpu_cudaStreamCreate(&in_peer_transfer_streams[i][devid]);

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

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2017  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2014, 2016  INRIA
  *
@@ -580,7 +580,7 @@ int _starpu_get_multi_worker_task(struct _starpu_worker *workers, struct starpu_
 
 	_starpu_worker_set_status_wakeup(workerid);
 	worker->spinning_backoff = BACKOFF_MIN;
-#endif /* STARPU_SIMGRID */
+#endif /* !STARPU_SIMGRID */
 
 	STARPU_PTHREAD_MUTEX_UNLOCK_SCHED(&workers[0].sched_mutex);
 #endif /* !STARPU_NON_BLOCKING_DRIVERS */

+ 2 - 2
src/sched_policies/component_worker.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2014, 2015, 2016, 2017  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011-2013  INRIA
  * Copyright (C) 2013  Simon Archipoff
@@ -683,7 +683,7 @@ static int combined_worker_push_task(struct starpu_sched_component * component,
 		task_alias[i]->task->workerid = combined_worker->combined_workerid[i];
 		task_alias[i]->left = task_alias[i-1];
 		task_alias[i - 1]->right = task_alias[i];
-		task_alias[i]->pntasks = &task_alias[0]->ntasks;
+		task_alias[i]->pntasks = &(task_alias[0]->ntasks);
 	}
 
 	starpu_pthread_mutex_t * mutex_to_unlock = NULL;

+ 4 - 2
src/sched_policies/work_stealing_policy.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, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016, 2017  CNRS
  * Copyright (C) 2011, 2012, 2016  INRIA
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -589,10 +589,12 @@ int ws_push_task(struct starpu_task *task)
 {
 	unsigned sched_ctx_id = task->sched_ctx;
 	struct _starpu_work_stealing_data *ws = (struct _starpu_work_stealing_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
-	int workerid = -1;
+	int workerid;
 
 #ifdef USE_LOCALITY
 	workerid = select_worker_locality(ws, task, sched_ctx_id);
+#else
+	workerid = -1;
 #endif
 	if (workerid == -1)
 		workerid = starpu_worker_get_id();

+ 57 - 3
tools/cppcheck/suppressions.txt

@@ -1,12 +1,66 @@
 memleakOnRealloc
 knownConditionTrueFalse
 variableScope
+unusedStructMember
+ConfigurationNotChecked
+
+*:tools/dev/*
+*:starpufft/*
+*:min-dgels/*
+*:starpu-top/*
+*:socl/src/CL/*
+
+// TODO. We should cppcheck the code
+*:sc_hypervisor/*
+
+varFuncNullUB:examples/sched_ctx/two_cpu_contexts.c:76
+negativeIndex:examples/stencil/stencil-tasks.c:200
+negativeIndex:examples/stencil/stencil-tasks.c:203
 constStatement:examples/stencil/*
+
 unreadVariable:tests/openmp/*
 unusedLabel:tests/datawizard/gpu_register.c
 unusedLabel:tests/datawizard/gpu_ptr_register.c
-varFuncNullUB:examples/sched_ctx/two_cpu_contexts.c:76
-negativeIndex:examples/stencil/stencil-tasks.c:200
-negativeIndex:examples/stencil/stencil-tasks.c:203
+redundantAssignment:tests/datawizard/interfaces/test_interfaces.c:752
+redundantAssignment:tests/datawizard/mpi_like_async.c:165
+redundantAssignment:tests/datawizard/mpi_like_async.c:211
+unusedPrivateFunction:tests/main/combined_workers/bfs/timer.h:45
+redundantAssignment:tests/main/driver_api/init_run_deinit.c
+redundantAssignment:tests/main/driver_api/run_driver.c
+
+uselessAssignmentPtrArg:mpi/src/starpu_mpi.c:155
+unreadVariable:mpi/src/starpu_mpi.c:849
+
+redundantAssignment:src/core/workers.c:249
+redundantAssignment:src/core/workers.c:245
+redundantAssignment:src/core/workers.c:253
+invalidPointerCast:src/core/perfmodel/perfmodel_nan.c:74
+unreadVariable:src/core/dependencies/tags.c:111
+uselessAssignmentPtrArg:src/core/sched_ctx_list.c:144
+unusedStructMember:src/core/perfmodel/perfmodel_bus.c:62
+unusedStructMember:src/core/perfmodel/perfmodel_bus.c:63
+unusedStructMember:src/core/perfmodel/perfmodel_bus.c:64
+unusedStructMember:src/core/perfmodel/perfmodel_bus.c:65
+unusedStructMember:src/core/perfmodel/perfmodel_bus.c:66
+unusedStructMember:src/core/simgrid.c:225
+unusedStructMember:src/core/simgrid.c:226
+
+// TODO: this could be an error?
+redundantCopy:src/core/disk_ops/disk_leveldb.cpp:192
+
+nullPointerRedundantCheck:src/common/rbtree.c
+unreadVariable:src/datawizard/interfaces/*
+unreadVariable:src/drivers/driver_common/driver_common.c:482
+clarifyCondition:src/drivers/opencl/driver_opencl.c:936
+unreadVariable:src/drivers/opencl/driver_opencl.c:767
+clarifyCondition:src/drivers/cuda/driver_cuda.c:506
+arithOperationsOnVoidPointer:src/drivers/scc/*
+nullPointerRedundantCheck:src/sched_policies/deque_modeling_policy_data_aware.c:197
+sizeofDereferencedVoidPointer:src/util/fstarpu.c
+
+allocaCalled:gcc-plugin/src/*
+unusedVariable:gcc-plugin/tests/*
+unreadVariable:gcc-plugin/tests/*
 
+pointerSize:socl/src/cl_getcontextinfo.c:33
 

+ 1 - 1
tools/starpu_fxt_stats.c

@@ -193,7 +193,7 @@ int main(int argc, char **argv)
 		{
 			if (transfers[src][dst] != 0)
 			{
-				fprintf(fd_out, "%u -> %u \t %lu MB\n", src, dst, transfers[src][dst]/(1024*1024));
+				fprintf(fd_out, "%u -> %u \t %lu MB\n", src, dst, (unsigned long)(transfers[src][dst]/(1024*1024)));
 			}
 		}
 	}