From: bangerth Date: Wed, 1 Dec 2010 20:21:18 +0000 (+0000) Subject: Fix a couple places that cppcheck marked up. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36314989e4c9985acc4a2b749392f82d32ae3178;p=dealii-svn.git Fix a couple places that cppcheck marked up. git-svn-id: https://svn.dealii.org/trunk@22893 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/constraint_matrix.templates.h b/deal.II/include/deal.II/lac/constraint_matrix.templates.h index 637b20b214..6270f60bc9 100644 --- a/deal.II/include/deal.II/lac/constraint_matrix.templates.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.templates.h @@ -990,8 +990,8 @@ namespace internals ~DataCache() { - if (data != 0) - delete [] data; + delete [] data; + data = 0; } void reinit () diff --git a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h index b173f7dc2b..8cab8ef9cf 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h @@ -2790,7 +2790,6 @@ namespace TrilinosWrappers const unsigned int j, const TrilinosScalar value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); if (value == 0) diff --git a/deal.II/source/base/index_set.cc b/deal.II/source/base/index_set.cc index 2ecf4f2bc6..073715cb28 100644 --- a/deal.II/source/base/index_set.cc +++ b/deal.II/source/base/index_set.cc @@ -241,7 +241,7 @@ IndexSet::block_write(std::ostream & out) const size_t n_ranges = ranges.size(); out.write(reinterpret_cast(&n_ranges), sizeof(n_ranges)); - if (ranges.size()) + if (ranges.empty() == false) out.write (reinterpret_cast(&*ranges.begin()), reinterpret_cast(&*ranges.end()) - reinterpret_cast(&*ranges.begin())); @@ -257,7 +257,7 @@ IndexSet::block_read(std::istream & in) in.read(reinterpret_cast(&n_ranges), sizeof(n_ranges)); // we have to clear ranges first ranges.clear(); - set_size(size); + set_size(size); ranges.resize(n_ranges, Range(0,0)); if (n_ranges) in.read(reinterpret_cast(&*ranges.begin()), diff --git a/deal.II/source/base/parameter_handler.cc b/deal.II/source/base/parameter_handler.cc index 009a7260fe..0ed237c25f 100644 --- a/deal.II/source/base/parameter_handler.cc +++ b/deal.II/source/base/parameter_handler.cc @@ -74,48 +74,48 @@ namespace Patterns PatternBase* pattern_factory (const std::string& description) { PatternBase* p; - + p = Integer::create(description); if (p != 0) return p; - + p = Double::create(description); if (p !=0 ) return p; - + p = Selection::create(description); if (p !=0 ) return p; - + p = List::create(description); - if (p !=0 ) + if (p !=0 ) return p; - + p = MultipleSelection::create(description); - if (p !=0 ) + if (p !=0 ) return p; - + p = Bool::create(description); if (p!=0 ) return p; - + p = Anything::create(description); if (p !=0 ) return p; - + p = FileName::create(description); if (p !=0 ) return p; - + p = DirectoryName::create(description); if (p!=0 ) return p; - + Assert(false, ExcNotImplemented()); - + return 0; } - + PatternBase::~PatternBase () @@ -137,7 +137,7 @@ namespace Patterns return sizeof(*this) + 32; } - + const int Integer::min_int_value = #ifdef HAVE_STD_NUMERIC_LIMITS @@ -223,22 +223,22 @@ namespace Patterns if(description.compare(0, std::strlen(description_init), description_init) == 0) { std::istringstream is(description); - + if(is.str().size() > strlen(description_init) + 1) - { + { //TODO: verify that description matches the pattern "^\[Integer range \d+\.\.\.\d+\]$" int lower_bound, upper_bound; - + is.ignore(strlen(description_init) + strlen(" range ")); - + if(!(is >> lower_bound)) return new Integer(); - + is.ignore(strlen("...")); - + if(!(is >> upper_bound)) return new Integer(); - + return new Integer(lower_bound, upper_bound); } else @@ -247,7 +247,7 @@ namespace Patterns else return 0; } - + const double Double::min_double_value = @@ -336,21 +336,21 @@ namespace Patterns if(description.compare(0, std::strlen(description_init), description_init) == 0) { std::istringstream is(description); - + if(is.str().size() > strlen(description_init) + 1) - { + { double lower_bound, upper_bound; - + is.ignore(strlen(description_init) + strlen(" range ")); - + if(!(is >> lower_bound)) return new Double(); - + is.ignore(strlen("...")); - + if(!(is >> upper_bound)) return new Double(); - + return new Double(lower_bound, upper_bound); } else @@ -359,7 +359,7 @@ namespace Patterns else return 0; } - + const char* Selection::description_init = "[Selection"; @@ -434,16 +434,16 @@ namespace Patterns if(description.compare(0, std::strlen(description_init), description_init) == 0) { std::string sequence(description); - + sequence.erase(0, std::strlen(description_init) + 1); sequence.erase(sequence.length()-2, 2); - + return new Selection(sequence); } else return 0; } - + const unsigned int List::max_int_value = @@ -561,26 +561,26 @@ namespace Patterns if(description.compare(0, std::strlen(description_init), description_init) == 0) { int min_elements, max_elements; - + std::istringstream is(description); is.ignore(strlen(description_init) + strlen(" list of <")); - + std::auto_ptr new_description (new char[is.str().size() + 1]); is.getline(&(*new_description), is.str().size(), '>'); std::string str(&(*new_description)); - + std::auto_ptr base_pattern (pattern_factory(str)); - + is.ignore(strlen(" of length ")); if(!(is >> min_elements)) return new List(*base_pattern); - + is.ignore(strlen("...")); if(!(is >> max_elements)) return new List(*base_pattern); - + return new List(*base_pattern, min_elements, max_elements); - } + } else return 0; } @@ -702,21 +702,21 @@ namespace Patterns if(description.compare(0, std::strlen(description_init), description_init) == 0) { std::string sequence(description); - + sequence.erase(0, std::strlen(description_init) + 1); sequence.erase(sequence.length()-2, 2); - + return new MultipleSelection(sequence); } else return 0; } - + const char* Bool::description_init = "[Bool"; - + Bool::Bool () : Selection ("true|false") @@ -750,7 +750,7 @@ namespace Patterns return new Bool(); else return 0; - } + } @@ -795,7 +795,7 @@ namespace Patterns return new Anything(); else return 0; - } + } @@ -846,21 +846,21 @@ namespace Patterns std::istringstream is(description); std::string file_type; FileType type; - + is.ignore(strlen(description_init) + strlen(" (Type:")); - + is >> file_type; - + if (file_type == "input)]") type = input; - else + else type = output; - + return new FileName(type); - } + } else return 0; - } + } @@ -904,7 +904,7 @@ namespace Patterns return new DirectoryName(); else return 0; - } + } } // end namespace Patterns @@ -1646,7 +1646,7 @@ ParameterHandler::print_parameters_section (std::ostream &out, out << std::setw(indent_level*2+6) << "" << description_str[i] << std::endl; } - else if (description_str.size() > 0) + else if (description_str.empty() == false) out << " " << description_str[0] << std::endl; else out << std::endl; diff --git a/deal.II/source/grid/grid_reordering.cc b/deal.II/source/grid/grid_reordering.cc index 6b47bba43f..4550de69f2 100644 --- a/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/source/grid/grid_reordering.cc @@ -1362,7 +1362,7 @@ namespace internal // finished with. Cell &c = mesh.cell_list[cur_posn]; c.waiting_to_be_processed = false; - if (sheet_to_process.size() != 0) + if (sheet_to_process.empty() == false) { cur_posn = sheet_to_process.back(); sheet_to_process.pop_back(); diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index 5af96763c7..bfe89e2bf2 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -489,7 +489,7 @@ GridTools::delete_duplicated_vertices (std::vector > &vertice : angle(angle) {} - Point<2> operator() (const Point<2> p) const + Point<2> operator() (const Point<2> &p) const { return Point<2> (std::cos(angle)*p(0) - std::sin(angle) * p(1), std::sin(angle)*p(0) + std::cos(angle) * p(1));