From: Timo Heister Date: Thu, 7 Mar 2019 20:25:00 +0000 (-0700) Subject: fix uninitialized reads X-Git-Tag: v9.1.0-rc1~300^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa5b5beb0d66e21b114f3b4467115d4a4de0e757;p=dealii.git fix uninitialized reads 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. --- diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index 6de9b6a6b8..ccd69d2c55 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -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