Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope of variables (please Codacy).
[simgrid.git] / teshsuite / smpi / coll-alltoallv / coll-alltoallv.c
index c3e3798..30d5a88 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014. The SimGrid Team.
+/* Copyright (c) 2013-2014, 2016-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 
 static void print_buffer_int(void *buf, int len, char *msg, int rank)
 {
-  int tmp, *v;
   printf("[%d] %s (#%d): ", rank, msg, len);
-  for (tmp = 0; tmp < len; tmp++) {
-    v = buf;
+  for (int tmp = 0; tmp < len; tmp++) {
+    int *v = buf;
     printf("[%d]", v[tmp]);
   }
   printf("\n");
@@ -59,9 +58,9 @@ static void print_buffer_int(void *buf, int len, char *msg, int rank)
 int main(int argc, char **argv)
 {
   MPI_Comm comm;
-  int *sbuf, *rbuf;
-  int i,rank, size;
-  int *sendcounts, *recvcounts, *rdispls, *sdispls;
+  int i;
+  int rank;
+  int size;
 
   MPI_Init(&argc, &argv);
 
@@ -70,8 +69,8 @@ int main(int argc, char **argv)
   /* Create the buffer */
   MPI_Comm_size(comm, &size);
   MPI_Comm_rank(comm, &rank);
-  sbuf = (int *) xbt_malloc(size * size * sizeof(int));
-  rbuf = (int *) xbt_malloc(size * size * sizeof(int));
+  int* sbuf = (int *) xbt_malloc(size * size * sizeof(int));
+  int* rbuf = (int *) xbt_malloc(size * size * sizeof(int));
 
   /* Load up the buffers */
   for (i = 0; i < size * size; i++) {
@@ -80,10 +79,10 @@ int main(int argc, char **argv)
   }
 
   /* Create and load the arguments to alltoallv */
-  sendcounts = (int *) xbt_malloc(size * sizeof(int));
-  recvcounts = (int *) xbt_malloc(size * sizeof(int));
-  rdispls = (int *) xbt_malloc(size * sizeof(int));
-  sdispls = (int *) xbt_malloc(size * sizeof(int));
+  int* sendcounts = (int*)xbt_malloc(size * sizeof(int));
+  int* recvcounts = (int*)xbt_malloc(size * sizeof(int));
+  int* rdispls    = (int*)xbt_malloc(size * sizeof(int));
+  int* sdispls    = (int*)xbt_malloc(size * sizeof(int));
   for (i = 0; i < size; i++) {
     sendcounts[i] = i;
     recvcounts[i] = rank;
@@ -101,7 +100,7 @@ int main(int argc, char **argv)
 
   print_buffer_int( rbuf, size*size, strdup("rbuf:"),rank);
 
-  MPI_Barrier(MPI_COMM_WORLD);  
+  MPI_Barrier(MPI_COMM_WORLD);
   if (0 == rank) {
     printf("Alltoallv TEST COMPLETE.\n");
   }