From: Daniel Arndt Date: Sat, 3 Feb 2018 21:08:13 +0000 (+0100) Subject: Fix issues discovered by Coverity X-Git-Tag: v9.0.0-rc1~469^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5854%2Fhead;p=dealii.git Fix issues discovered by Coverity --- diff --git a/examples/step-32/step-32.cc b/examples/step-32/step-32.cc index a8d6c7019b..bc88b31738 100644 --- a/examples/step-32/step-32.cc +++ b/examples/step-32/step-32.cc @@ -3726,14 +3726,14 @@ start_time_iteration: // by changing the constant dimension below to 3. int main (int argc, char *argv[]) { - using namespace Step32; - using namespace dealii; - - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, - numbers::invalid_unsigned_int); - try { + using namespace Step32; + using namespace dealii; + + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, + numbers::invalid_unsigned_int); + std::string parameter_filename; if (argc>=2) parameter_filename = argv[1]; diff --git a/examples/step-50/step-50.cc b/examples/step-50/step-50.cc index 6bff73413c..22258225fc 100644 --- a/examples/step-50/step-50.cc +++ b/examples/step-50/step-50.cc @@ -968,13 +968,13 @@ namespace Step50 // in step-6: int main (int argc, char *argv[]) { - dealii::Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); - try { using namespace dealii; using namespace Step50; + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + LaplaceProblem<2> laplace_problem(1/*degree*/); laplace_problem.run (); } diff --git a/include/deal.II/lac/la_parallel_vector.templates.h b/include/deal.II/lac/la_parallel_vector.templates.h index 0ab50f602c..6cb5794d83 100644 --- a/include/deal.II/lac/la_parallel_vector.templates.h +++ b/include/deal.II/lac/la_parallel_vector.templates.h @@ -290,7 +290,12 @@ namespace LinearAlgebra inline Vector::~Vector () { - clear_mpi_requests(); + try + { + clear_mpi_requests(); + } + catch (...) + {} } diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc index 95bfc1a108..4195b3673b 100644 --- a/source/distributed/tria.cc +++ b/source/distributed/tria.cc @@ -1307,12 +1307,17 @@ namespace parallel // virtual functions called in constructors and destructors never use the // override in a derived class // for clarity be explicit on which function is called - Triangulation::clear (); + try + { + Triangulation::clear (); + } + catch (...) + {} - Assert (triangulation_has_content == false, - ExcInternalError()); - Assert (connectivity == nullptr, ExcInternalError()); - Assert (parallel_forest == nullptr, ExcInternalError()); + AssertNothrow (triangulation_has_content == false, + ExcInternalError()); + AssertNothrow (connectivity == nullptr, ExcInternalError()); + AssertNothrow (parallel_forest == nullptr, ExcInternalError()); } @@ -3741,7 +3746,7 @@ namespace parallel template Triangulation<1,spacedim>::~Triangulation () { - Assert (false, ExcNotImplemented()); + AssertNothrow (false, ExcNotImplemented()); } diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 03c9bae9e3..a56e9a12b4 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -3638,11 +3638,17 @@ namespace internal // different tags for phase 1 and 2, but the cost of a // barrier is negligible compared to everything else we do // here - const parallel::distributed::Triangulation< dim, spacedim > *triangulation - = (dynamic_cast*> - (&dof_handler.get_triangulation())); - const int ierr = MPI_Barrier(triangulation->get_communicator()); - AssertThrowMPI(ierr); + if (const auto *triangulation = + dynamic_cast*>(&dof_handler.get_triangulation())) + { + const int ierr = MPI_Barrier(triangulation->get_communicator()); + AssertThrowMPI(ierr); + } + else + { + Assert(false, ExcMessage("The function communicate_dof_indices_on_marked_cells() " + "only works with parallel distributed triangulations.")); + } #endif } diff --git a/source/sundials/arkode.cc b/source/sundials/arkode.cc index 68ebed5cb8..205c0d9b47 100644 --- a/source/sundials/arkode.cc +++ b/source/sundials/arkode.cc @@ -221,6 +221,8 @@ namespace SUNDIALS const MPI_Comm mpi_comm) : data(data), arkode_mem(nullptr), + yy(nullptr), + abs_tolls(nullptr), communicator(is_serial_vector::value ? MPI_COMM_SELF : Utilities::MPI::duplicate_communicator(mpi_comm)) @@ -237,7 +239,7 @@ namespace SUNDIALS if (is_serial_vector::value == false) { const int ierr = MPI_Comm_free(&communicator); - AssertThrowMPI(ierr); + AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr)); } #endif } diff --git a/source/sundials/ida.cc b/source/sundials/ida.cc index 160bb1e3a1..11afc8fc88 100644 --- a/source/sundials/ida.cc +++ b/source/sundials/ida.cc @@ -147,6 +147,10 @@ namespace SUNDIALS const MPI_Comm mpi_comm) : data(data), ida_mem(nullptr), + yy(nullptr), + yp(nullptr), + abs_tolls(nullptr), + diff_id(nullptr), communicator(is_serial_vector::value ? MPI_COMM_SELF : Utilities::MPI::duplicate_communicator(mpi_comm)) @@ -163,7 +167,7 @@ namespace SUNDIALS if (is_serial_vector::value == false) { const int ierr = MPI_Comm_free(&communicator); - AssertThrowMPI(ierr); + AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr)); } #endif } diff --git a/source/sundials/kinsol.cc b/source/sundials/kinsol.cc index fe00b17db2..ba07fb638f 100644 --- a/source/sundials/kinsol.cc +++ b/source/sundials/kinsol.cc @@ -148,6 +148,9 @@ namespace SUNDIALS KINSOL::KINSOL(const AdditionalData &data, const MPI_Comm mpi_comm) : data(data), kinsol_mem(nullptr), + solution(nullptr), + u_scale(nullptr), + f_scale(nullptr), communicator(is_serial_vector::value ? MPI_COMM_SELF : Utilities::MPI::duplicate_communicator(mpi_comm)) @@ -166,7 +169,7 @@ namespace SUNDIALS if (is_serial_vector::value == false) { const int ierr = MPI_Comm_free(&communicator); - AssertThrowMPI(ierr); + AssertNothrow(ierr == MPI_SUCCESS, ExcMPI(ierr)); } #endif }