From b1cf626e9892134b82013b7f7b993752792145bd Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 17 Jan 2018 14:00:09 +0100 Subject: [PATCH] Fix issues reported by Coverity --- .../lac/block_sparse_matrix.templates.h | 7 +++++- .../deal.II/lac/swappable_vector.templates.h | 9 +++++++- source/grid/tria.cc | 22 +++++++------------ source/numerics/time_dependent.cc | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/deal.II/lac/block_sparse_matrix.templates.h b/include/deal.II/lac/block_sparse_matrix.templates.h index 01bae4345f..0b6a0f6b23 100644 --- a/include/deal.II/lac/block_sparse_matrix.templates.h +++ b/include/deal.II/lac/block_sparse_matrix.templates.h @@ -37,7 +37,12 @@ BlockSparseMatrix::~BlockSparseMatrix () { // delete previous content of // the subobjects array - clear (); + try + { + clear (); + } + catch (...) + {} sparsity_pattern = nullptr; } diff --git a/include/deal.II/lac/swappable_vector.templates.h b/include/deal.II/lac/swappable_vector.templates.h index 08d64e7e8f..84dd2fa51a 100644 --- a/include/deal.II/lac/swappable_vector.templates.h +++ b/include/deal.II/lac/swappable_vector.templates.h @@ -54,7 +54,14 @@ SwappableVector::~SwappableVector () // itself if (filename != "") - kill_file (); + { + try + { + kill_file (); + } + catch (...) + {} + } } diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 8ff8460535..e0ee6ecfbd 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -4022,12 +4022,6 @@ namespace internal // user flag is set or not cell->clear_user_flag(); - // An assert to make sure that the static_cast in the - // next line has the chance to give reasonable - // results. - Assert(cell->material_id()<= std::numeric_limits::max(), - ExcIndexRange(cell->material_id(),0,std::numeric_limits::max())); - // new vertex is placed on the surface according to // the information stored in the boundary class triangulation.vertices[next_unused_vertex] = @@ -8896,17 +8890,17 @@ Triangulation::~Triangulation () // 1d. double check this here, as destruction is a good place to // ensure that what we've done over the course of the lifetime of // this object makes sense - Assert ((dim == 1) - || - (vertex_to_boundary_id_map_1d == nullptr), - ExcInternalError()); + AssertNothrow ((dim == 1) + || + (vertex_to_boundary_id_map_1d == nullptr), + ExcInternalError()); // the vertex_to_manifold_id_map_1d field should be also unused // except in 1d. check this as well - Assert ((dim == 1) - || - (vertex_to_manifold_id_map_1d == nullptr), - ExcInternalError()); + AssertNothrow ((dim == 1) + || + (vertex_to_manifold_id_map_1d == nullptr), + ExcInternalError()); } diff --git a/source/numerics/time_dependent.cc b/source/numerics/time_dependent.cc index 517c8b3059..f4a8ecddc2 100644 --- a/source/numerics/time_dependent.cc +++ b/source/numerics/time_dependent.cc @@ -444,7 +444,7 @@ TimeStepBase_Tria::~TimeStepBase_Tria () delete t; } else - Assert (tria==nullptr, ExcInternalError()); + AssertNothrow (tria==nullptr, ExcInternalError()); coarse_grid = nullptr; } -- 2.39.5