]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix uninitialized reads 7789/head
authorTimo Heister <timo.heister@gmail.com>
Thu, 7 Mar 2019 20:25:00 +0000 (13:25 -0700)
committerTimo Heister <timo.heister@gmail.com>
Thu, 7 Mar 2019 20:25:00 +0000 (13:25 -0700)
valgrind warns about uninitialized reads in the following two MPI
functions. The totals are only available on rank 0. Note that the value
doesn't matter as the results will be thrown away for rank !=0.

source/distributed/grid_refinement.cc

index 6de9b6a6b8a5eb4169621ffb2d3b904af8d6e9a5..ccd69d2c55b36a9f342b68d9b523830483f53b40 100644 (file)
@@ -260,7 +260,8 @@ namespace
                             return c > test_threshold;
                           });
 
-          unsigned int total_count;
+          unsigned int total_count = 0;
+
           ierr = MPI_Reduce(&my_count,
                             &total_count,
                             1,
@@ -270,7 +271,7 @@ namespace
                             mpi_communicator);
           AssertThrowMPI(ierr);
 
-          // now adjust the range. if we have to many cells, we take the upper
+          // now adjust the range. if we have too many cells, we take the upper
           // half of the previous range, otherwise the lower half. if we have
           // hit the right number, then set the range to the exact value.
           // slave nodes also update their own interesting_range, however their
@@ -369,7 +370,8 @@ namespace
             if (criteria(i) > test_threshold)
               my_error += criteria(i);
 
-          double total_error;
+          double total_error = 0.;
+
           ierr = MPI_Reduce(&my_error,
                             &total_error,
                             1,
@@ -379,7 +381,7 @@ namespace
                             mpi_communicator);
           AssertThrowMPI(ierr);
 
-          // now adjust the range. if we have to many cells, we take the upper
+          // now adjust the range. if we have too many cells, we take the upper
           // half of the previous range, otherwise the lower half. if we have
           // hit the right number, then set the range to the exact value.
           // slave nodes also update their own interesting_range, however their

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.