Browse Source

Fix some llvm warnings, nothing serious

Samuel Thibault 10 years ago
parent
commit
a41c4b9ce3

+ 1 - 1
examples/lu/lu_example.c

@@ -341,7 +341,7 @@ int main(int argc, char **argv)
 		if (no_stride)
 		{
 			/* in case the LU decomposition uses non-strided blocks, we _copy_ the matrix into smaller blocks */
-			A_blocks = malloc(nblocks*nblocks*sizeof(TYPE **));
+			A_blocks = malloc(nblocks*nblocks*sizeof(TYPE *));
 			copy_matrix_into_blocks();
 
 			ret = STARPU_LU(lu_decomposition_pivot_no_stride)(A_blocks, ipiv, size, size, nblocks);

+ 2 - 2
mpi/examples/matrix_decomposition/mpi_decomposition_matrix.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012  Université de Bordeaux
+ * Copyright (C) 2009-2012, 2015  Université de Bordeaux
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
  * Copyright (C) 2010, 2011, 2012, 2013, 2015  Centre National de la Recherche Scientifique
  *
@@ -63,7 +63,7 @@ void matrix_init(float ****bmat, int rank, int nodes, int alloc_everywhere)
 {
 	unsigned i,j,x,y;
 
-	*bmat = malloc(nblocks * sizeof(float *));
+	*bmat = malloc(nblocks * sizeof(float **));
 	for(x=0 ; x<nblocks ; x++)
 	{
 		(*bmat)[x] = malloc(nblocks * sizeof(float *));

+ 1 - 1
mpi/src/starpu_mpi.c

@@ -919,7 +919,7 @@ static void _starpu_mpi_handle_request_termination(struct _starpu_mpi_req *req)
 					STARPU_MPI_ASSERT_MSG(ret == MPI_SUCCESS, "MPI_Wait returning %s", _starpu_mpi_get_mpi_code(ret));
 					free(req->ptr);
 				}
-				if (req->request_type == RECV_REQ)
+				else if (req->request_type == RECV_REQ)
 				{
 					// req->ptr is freed by starpu_data_unpack
 					starpu_data_unpack(req->data_handle, req->ptr, req->count);

+ 3 - 0
src/core/disk_ops/disk_leveldb.cpp

@@ -292,7 +292,10 @@ get_leveldb_bandwidth_between_disk_and_main_ram(unsigned node)
 	void * mem = _starpu_disk_alloc(node, SIZE_DISK_MIN);
 	/* fail to alloc */
 	if (mem == NULL)
+	{
+		free(buf);
 		return 0;
+	}
 
 	/* Measure upload slowness */
 	start = starpu_timing_now();

+ 1 - 4
src/core/perfmodel/perfmodel_bus.c

@@ -768,11 +768,8 @@ static void get_bus_path(const char *type, char *path, size_t maxlen)
 {
 	char hostname[65];
 
-	snprintf(path, maxlen, "%s", _starpu_get_perf_model_dir_bus());
 	_starpu_gethostname(hostname, sizeof(hostname));
-	strncat(path, hostname, maxlen);
-	strncat(path, ".", maxlen);
-	strncat(path, type, maxlen);
+	snprintf(path, maxlen, "%s%s.%s", _starpu_get_perf_model_dir_bus(), hostname, type);
 }
 
 /*

+ 6 - 16
src/core/perfmodel/perfmodel_history.c

@@ -712,29 +712,19 @@ static void get_model_debug_path(struct starpu_perfmodel *model, const char *arc
 {
 	STARPU_ASSERT(path);
 
-	snprintf(path, maxlen, "%s/%s", _starpu_get_perf_model_dir_debug(), model->symbol);
-
 	char hostname[65];
 	_starpu_gethostname(hostname, sizeof(hostname));
-	strncat(path, ".", maxlen);
-	strncat(path, hostname, maxlen);
-	strncat(path, ".", maxlen);
-	strncat(path, arch, maxlen);
-	strncat(path, ".debug", maxlen);
+
+	snprintf(path, maxlen, "%s/%s.%s.%s.debug", _starpu_get_perf_model_dir_debug(), model->symbol, hostname, arch);
 }
 
 static void get_model_path(struct starpu_perfmodel *model, char *path, size_t maxlen)
 {
-	snprintf(path, maxlen, "%s/%s", _starpu_get_perf_model_dir_codelet(), model->symbol);
-
+	char hostname[65];
+	_starpu_gethostname(hostname, sizeof(hostname));
 	const char *dot = strrchr(model->symbol, '.');
-	if (dot == NULL)
-	{
-		char hostname[65];
-		_starpu_gethostname(hostname, sizeof(hostname));
-		strncat(path, ".", maxlen);
-		strncat(path, hostname, maxlen);
-	}
+
+	snprintf(path, maxlen, "%s/%s%s%s", _starpu_get_perf_model_dir_codelet(), model->symbol, dot?"":".", dot?"":hostname);
 }
 
 #ifndef STARPU_SIMGRID

+ 0 - 3
src/datawizard/malloc.c

@@ -503,9 +503,6 @@ _starpu_malloc_on_node(unsigned dst_node, size_t size)
 	if (addr == 0)
 	{
 		// Allocation failed, gives the memory back to the memory manager
-		const char* file;					
-		file = strrchr(__FILE__,'/');							
-		file += sizeof(char);										
 		_STARPU_TRACE_MEMORY_FULL(size);
 		starpu_memory_deallocate(dst_node, size);
 	}

+ 19 - 1
src/profiling/bound.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
- * Copyright (C) 2010-2014  Université de Bordeaux
+ * Copyright (C) 2010-2015  Université de Bordeaux
  * Copyright (C) 2011  Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -492,6 +492,9 @@ void starpu_bound_print_lp(FILE *output)
 
 	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 	nw = starpu_worker_get_count();
+	if (!nw)
+		/* Make llvm happy about the VLA below */
+		return;
 
 	if (recorddeps)
 	{
@@ -527,6 +530,8 @@ void starpu_bound_print_lp(FILE *output)
 			}
 			nt++;
 		}
+		if (!nt)
+			return;
 		fprintf(output, "/* StarPU upper bound linear programming problem, to be run in lp_solve. */\n\n");
 		fprintf(output, "/* !! This is a big system, it will be long to solve !! */\n\n");
 
@@ -772,6 +777,8 @@ void starpu_bound_print_lp(FILE *output)
 		nt = 0;
 		for (tp = task_pools; tp; tp = tp->next)
 			nt++;
+		if (!nt)
+			return;
 
 		{
 			double times[nw*nt];
@@ -860,9 +867,15 @@ void starpu_bound_print_mps(FILE *output)
 	STARPU_PTHREAD_MUTEX_LOCK(&mutex);
 
 	nw = starpu_worker_get_count();
+	if (!nw)
+		/* Make llvm happy about the VLA below */
+		return;
 	nt = 0;
 	for (tp = task_pools; tp; tp = tp->next)
 		nt++;
+	if (!nt)
+		return;
+
 	{
 		double times[nw*nt];
 
@@ -935,9 +948,14 @@ static glp_prob *_starpu_bound_glp_resolve(int integer)
 	int ret;
 
 	nw = starpu_worker_get_count();
+	if (!nw)
+		/* Make llvm happy about the VLA below */
+		return NULL;
 	nt = 0;
 	for (tp = task_pools; tp; tp = tp->next)
 		nt++;
+	if (!nt)
+		return NULL;
 
 	lp = glp_create_prob();
 	glp_set_prob_name(lp, "StarPU theoretical bound");

+ 3 - 0
src/top/starpu_top_message_queue.c

@@ -34,6 +34,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 	if( NULL == p )
 	{
 		fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
+		free(msg);
 		STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 	}
@@ -44,6 +45,8 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
 	if( NULL == s )
 	{
 		printf("Queue not initialized\n");
+		free(msg);
+		free(p);
 		STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
 		return s;
 	}

+ 4 - 4
tests/main/driver_api/run_driver.c

@@ -89,7 +89,7 @@ test_cpu(void)
 	if (ret != 0)
 	{
 		ret = 1;
-		goto out;
+		goto out2;
 	}
 
 	struct starpu_task *task;
@@ -107,14 +107,14 @@ test_cpu(void)
 		goto out;
 	}
 
+	FPRINTF(stderr, "[CPU] Var = %d (expected value: 1)\n", var);
+	ret = !!(var != 1);
 out:
 	starpu_drivers_request_termination();
 	if (starpu_pthread_join(driver_thread, NULL) != 0)
 		return 1;
+out2:
 	starpu_shutdown();
-
-	FPRINTF(stderr, "[CPU] Var = %d (expected value: 1)\n", var);
-	ret = !!(var != 1);
 	return ret;
 }
 #endif /* STARPU_USE_CPU */