Ver código fonte

fixes for minor warning detected by cppcheck

Nathalie Furmento 8 anos atrás
pai
commit
a6993f6e69

+ 3 - 3
examples/pi/pi.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2011, 2013-2015  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 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
@@ -146,7 +146,7 @@ int main(int argc, char **argv)
 	starpu_vector_data_register(&sobol_qrng_direction_handle, STARPU_MAIN_RAM,
 		(uintptr_t)sobol_qrng_directions, n_dimensions*n_directions, sizeof(unsigned));
 
-	unsigned *cnt_array = malloc(ntasks*sizeof(unsigned));
+	unsigned *cnt_array = calloc(ntasks, sizeof(unsigned));
 	STARPU_ASSERT(cnt_array);
 	starpu_data_handle_t cnt_array_handle;
 	starpu_vector_data_register(&cnt_array_handle, STARPU_MAIN_RAM, (uintptr_t)cnt_array, ntasks, sizeof(unsigned));
@@ -161,7 +161,7 @@ int main(int argc, char **argv)
 		.filter_func = starpu_vector_filter_block,
 		.nchildren = ntasks
 	};
-	
+
 	starpu_data_partition(cnt_array_handle, &f);
 
 	double start;

+ 3 - 1
examples/sched_ctx/nested_sched_ctxs.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2015  Université de Bordeaux
- * Copyright (C) 2010-2014, 2016  CNRS
+ * Copyright (C) 2010-2014, 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
@@ -51,8 +51,10 @@ int parallel_code(int sched_ctx)
 static void sched_ctx_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 	int w = starpu_worker_get_id();
+	(void) w;
 	unsigned sched_ctx = (uintptr_t)arg;
 	int n = parallel_code(sched_ctx);
+	(void) n;
 	//printf("w %d executed %d it \n", w, n);
 }
 

+ 5 - 3
examples/sched_ctx/parallel_code.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2014, 2016  Université de Bordeaux
- * Copyright (C) 2010-2016  CNRS
+ * Copyright (C) 2010-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
@@ -87,8 +87,8 @@ int main(int argc, char **argv)
 		return 77;
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
 
-	int nprocs1 = 1;
-	int nprocs2 = 1;
+	int nprocs1;
+	int nprocs2;
 	int *procs1, *procs2;
 
 #ifdef STARPU_USE_CPU
@@ -103,6 +103,8 @@ int main(int argc, char **argv)
 	for(j = nprocs1; j < nprocs1+nprocs2; j++)
 		procs2[k++] = j;
 #else
+	nprocs1 = 1;
+	nprocs2 = 1;
 	procs1 = (int*)malloc(nprocs1*sizeof(int));
 	procs2 = (int*)malloc(nprocs2*sizeof(int));
 	procs1[0] = 0;

+ 4 - 3
examples/sched_ctx/two_cpu_contexts.c

@@ -73,6 +73,7 @@ int main(int argc, char **argv)
 	}
 
         /* create sched context 1 with default policy, by giving a NULL policy name */
+	// cppcheck-suppress varFuncNullUB
 	unsigned sched_ctx1 = starpu_sched_ctx_create(procs1, nprocs1, "ctx1", STARPU_SCHED_CTX_POLICY_NAME, NULL, 0);
         /* create sched context 2 with a user selected policy name */
 	unsigned sched_ctx2 = starpu_sched_ctx_create(procs2, nprocs2, "ctx2", STARPU_SCHED_CTX_POLICY_NAME, "eager", 0);
@@ -85,14 +86,14 @@ int main(int argc, char **argv)
 	for (i=0; i < n; i++)
 	{
 		int arg_id = 1*1000 + i;
-		ret = starpu_insert_task(&sched_ctx_codelet, STARPU_VALUE, &arg_id, sizeof(int), STARPU_SCHED_CTX, sched_ctx1, NULL);
+		ret = starpu_task_insert(&sched_ctx_codelet, STARPU_VALUE, &arg_id, sizeof(int), STARPU_SCHED_CTX, sched_ctx1, 0);
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
 	for (i=0; i < n; i++)
 	{
 		int arg_id = 2*1000 + i;
-		ret = starpu_insert_task(&sched_ctx_codelet, STARPU_VALUE, &arg_id, sizeof(int), STARPU_SCHED_CTX, sched_ctx2, NULL);
+		ret = starpu_task_insert(&sched_ctx_codelet, STARPU_VALUE, &arg_id, sizeof(int), STARPU_SCHED_CTX, sched_ctx2, 0);
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 
@@ -101,7 +102,7 @@ int main(int argc, char **argv)
 	for (i=0; i < n; i++)
 	{
 		int arg_id = 1*10000 + i;
-		ret = starpu_insert_task(&sched_ctx_codelet, STARPU_VALUE, &arg_id, sizeof(int), STARPU_SCHED_CTX, sched_ctx1, NULL);
+		ret = starpu_task_insert(&sched_ctx_codelet, STARPU_VALUE, &arg_id, sizeof(int), STARPU_SCHED_CTX, sched_ctx1, 0);
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	}
 

+ 3 - 1
examples/spmv/matrix_market/example_read.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  CNRS
+ * Copyright (C) 2010, 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
@@ -13,6 +13,7 @@
  *
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
+
 #include "mm_to_bcsr.h"
 
 int main(int argc, char *argv[])
@@ -30,6 +31,7 @@ int main(int argc, char *argv[])
 
 	bcsr_t *bcsr;
 	bcsr = mm_file_to_bcsr(argv[1], c, r);
+	(void) bcsr;
 
 	return 0;
 }

+ 5 - 3
examples/stencil/implicit-stencil-kernels.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2015  Université de Bordeaux
- * Copyright (C) 2012, 2013, 2016  CNRS
+ * Copyright (C) 2012, 2013, 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
@@ -571,6 +571,7 @@ static void dummy_func_bottom_cuda(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *
 	unsigned z;
 	starpu_codelet_unpack_args(arg, &z);
 	struct block_description *block = get_block_description(z);
+	(void) block;
 
 	int workerid = starpu_worker_get_id_check();
 	bottom_per_worker[workerid]++;
@@ -605,9 +606,10 @@ static void dummy_func_top_opencl(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *a
 /* bottom save, OPENCL version */
 static void dummy_func_bottom_opencl(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
-    unsigned z;
-    starpu_codelet_unpack_args(arg, &z);
+	unsigned z;
+	starpu_codelet_unpack_args(arg, &z);
 	struct block_description *block = get_block_description(z);
+	(void) block;
 
 	int workerid = starpu_worker_get_id_check();
 	bottom_per_worker[workerid]++;

+ 1 - 1
examples/stencil/life_opencl.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011, 2013-2014  Université de Bordeaux
- * 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

+ 5 - 1
examples/stencil/stencil-kernels.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2015  Université de Bordeaux
- * Copyright (C) 2012, 2013, 2016  CNRS
+ * Copyright (C) 2012, 2013, 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
@@ -520,6 +520,7 @@ void dummy_func_top_cpu(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 void dummy_func_bottom_cpu(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 	struct block_description *block = (struct block_description *) arg;
+	(void) block;
 	int workerid = starpu_worker_get_id_check();
 	bottom_per_worker[workerid]++;
 
@@ -550,6 +551,7 @@ static void dummy_func_top_cuda(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg
 static void dummy_func_bottom_cuda(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 	struct block_description *block = (struct block_description *) arg;
+	(void) block;
 	int workerid = starpu_worker_get_id_check();
 	bottom_per_worker[workerid]++;
 
@@ -565,6 +567,7 @@ static void dummy_func_bottom_cuda(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *
 static void dummy_func_top_opencl(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 	struct block_description *block = (struct block_description *) arg;
+	(void) block;
 	int workerid = starpu_worker_get_id_check();
 	top_per_worker[workerid]++;
 
@@ -581,6 +584,7 @@ static void dummy_func_top_opencl(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *a
 static void dummy_func_bottom_opencl(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 	struct block_description *block = (struct block_description *) arg;
+	(void) block;
 	int workerid = starpu_worker_get_id_check();
 	bottom_per_worker[workerid]++;
 

+ 5 - 1
examples/stencil/stencil-tasks.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2013-2015  Université de Bordeaux
- * Copyright (C) 2012, 2013, 2015  CNRS
+ * Copyright (C) 2012, 2013, 2015, 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
@@ -78,6 +78,7 @@ static void create_task_save_local(unsigned iter, unsigned z, int dir, int local
 static void send_done(void *arg)
 {
 	uintptr_t z = (uintptr_t) arg;
+	(void) z;
 	DEBUG("DO SEND %d\n", (int)z);
 }
 
@@ -106,6 +107,7 @@ static void create_task_save_mpi_send(unsigned iter, unsigned z, int dir, int lo
 static void recv_done(void *arg)
 {
 	uintptr_t z = (uintptr_t) arg;
+	(void) z;
 	DEBUG("DO RECV %d\n", (int)z);
 }
 
@@ -195,9 +197,11 @@ void create_task_update(unsigned iter, unsigned z, int local_rank)
 	task->handles[1] = descr->layers_handle[old_layer];
 
 	task->handles[2] = descr->boundaries_handle[T][new_layer];
+	// cppcheck-suppress negativeIndex
 	task->handles[3] = descr->boundaries_handle[T][old_layer];
 
 	task->handles[4] = descr->boundaries_handle[B][new_layer];
+	// cppcheck-suppress negativeIndex
 	task->handles[5] = descr->boundaries_handle[B][old_layer];
 
 	task->cl = &cl_update;

+ 3 - 3
include/starpu_rand.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2012, 2013  CNRS
+ * Copyright (C) 2012, 2013, 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
@@ -48,7 +48,7 @@ typedef int starpu_drand48_data;
 #    define starpu_srand48_r(seed, buffer)		srand48(starpu_seed(seed))
 #    define starpu_drand48_r(buffer, result)		do {*(result) = drand48(); } while (0)
 #    define starpu_lrand48_r(buffer, result)		do {*(result) = lrand48(); } while (0)
-#    define starpu_erand48_r(xsubi, buffer, result)	do {*(result) = erand48(xsubi); } while (0)
+#    define starpu_erand48_r(xsubi, buffer, result)	do {(void) buffer; *(result) = erand48(xsubi); } while (0)
 #  endif
 #else
 typedef int starpu_drand48_data;
@@ -57,7 +57,7 @@ typedef int starpu_drand48_data;
 #  define starpu_lrand48() 				rand()
 #  define starpu_erand48(xsubi)				starpu_drand48()
 #  define starpu_srand48_r(seed, buffer) 		srand(starpu_seed(seed))
-#  define starpu_erand48_r(xsubi, buffer, result)	do {*(result) = ((double)(rand()) / RAND_MAX);} while (0)
+#  define starpu_erand48_r(xsubi, buffer, result)	do {(void) xsubi; (void) buffer; *(result) = ((double)(rand()) / RAND_MAX);} while (0)
 #endif
 
 #ifdef __cplusplus