Browse Source

tests: fixes for minor warnings detected by cppcheck

Nathalie Furmento 8 years ago
parent
commit
a20018f8dc
2 changed files with 12 additions and 13 deletions
  1. 2 3
      tests/loader.c
  2. 10 10
      tests/main/combined_workers/bfs/bfs.cpp

+ 2 - 3
tests/loader.c

@@ -237,13 +237,12 @@ int main(int argc, char *argv[])
 		test_args = (char *) calloc(150, sizeof(char));
 		sprintf(test_args, "%s/examples/spmv/matrix_market/examples/fidapm05.mtx", STARPU_SRC_DIR);
 	}
-
-	if (strstr(test_name, "starpu_perfmodel_display"))
+	else if (strstr(test_name, "starpu_perfmodel_display"))
 	{
 		test_args = (char *) calloc(5, sizeof(char));
 		sprintf(test_args, "-l");
 	}
-	if (strstr(test_name, "starpu_perfmodel_plot"))
+	else if (strstr(test_name, "starpu_perfmodel_plot"))
 	{
 		test_args = (char *) calloc(5, sizeof(char));
 		sprintf(test_args, "-l");

+ 10 - 10
tests/main/combined_workers/bfs/bfs.cpp

@@ -54,10 +54,10 @@ void read_file(char *input_f, unsigned int *nb_nodes, unsigned int *nb_edges,
 	fscanf(fp, "%u", nb_nodes);
 
 	// allocate host memory
-	*origin_graph_nodes = (Node *) malloc(sizeof(Node) * (*nb_nodes));
-	*origin_graph_mask = (bool *) malloc(sizeof(bool) * (*nb_nodes));
-	*origin_updating_graph_mask = (bool *) malloc(sizeof(bool) * (*nb_nodes));
-	*origin_graph_visited = (bool *) malloc(sizeof(bool) * (*nb_nodes));
+	*origin_graph_nodes = malloc(sizeof(Node) * (*nb_nodes));
+	*origin_graph_mask = malloc(sizeof(bool) * (*nb_nodes));
+	*origin_updating_graph_mask = malloc(sizeof(bool) * (*nb_nodes));
+	*origin_graph_visited = malloc(sizeof(bool) * (*nb_nodes));
 
 	int start, edgeno;
 	// initalize the memory
@@ -156,12 +156,12 @@ int main( int argc, char** argv)
 		  &origin_graph_mask, &origin_updating_graph_mask,
 		  &origin_graph_visited, &origin_graph_edges, &origin_cost);
 
-	graph_nodes = (Node *) calloc(nb_nodes, sizeof(Node));
-	graph_mask = (bool *) calloc(nb_nodes, sizeof(bool));
-	updating_graph_mask = (bool *) calloc(nb_nodes, sizeof(bool));
-	graph_visited = (bool *) calloc(nb_nodes, sizeof(bool));
-	graph_edges = (int*) calloc(nb_edges, sizeof(int));
-	cost = (int*) calloc(nb_nodes, sizeof(int));
+	graph_nodes = calloc(nb_nodes, sizeof(Node));
+	graph_mask = calloc(nb_nodes, sizeof(bool));
+	updating_graph_mask = calloc(nb_nodes, sizeof(bool));
+	graph_visited = calloc(nb_nodes, sizeof(bool));
+	graph_edges = calloc(nb_edges, sizeof(int));
+	cost = calloc(nb_nodes, sizeof(int));
 
 	memcpy(graph_nodes, origin_graph_nodes, nb_nodes*sizeof(Node));
 	memcpy(graph_edges, origin_graph_edges, nb_edges*sizeof(int));