Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 19 Mar 2021 09:34:59 +0000 (10:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 19 Mar 2021 15:12:50 +0000 (16:12 +0100)
teshsuite/smpi/coll-allreduce-with-leaks/coll-allreduce-with-leaks.c

index b88d897..c9b9bcb 100644 (file)
@@ -14,8 +14,6 @@ int main(int argc, char *argv[])
 {
   int rank;
   int size;
-  int i;
-  int status;
 
   MPI_Init(&argc, &argv);
   int maxlen = argc >= 2 ? atoi(argv[1]) : 1;
@@ -29,12 +27,12 @@ int main(int argc, char *argv[])
   int* sb = xbt_new0(int, size * maxlen);
   int* rb = xbt_new0(int, size * maxlen);
 
-  for (i = 0; i < size *maxlen; ++i) {
+  for (int i = 0; i < size * maxlen; ++i) {
     sb[i] = rank*size + i;
     rb[i] = 0;
   }
 
-  status = MPI_Allreduce(sb, rb, size *maxlen, MPI_INT, MPI_SUM, dup);
+  int status = MPI_Allreduce(sb, rb, size * maxlen, MPI_INT, MPI_SUM, dup);
 
   if (rank == 0 && status != MPI_SUCCESS) {
     printf("all_to_all returned %d\n", status);