From b720979bfbb197b0940445ce38f9118bd03a209c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <foss@grueninger.de> Date: Thu, 6 Jun 2024 16:34:46 +0200 Subject: [PATCH] Mark references as const wherever possible Found by Cppcheck (constVariableReference(. --- .../test_functionfromstringexpression.cc | 2 +- test/common/spline/test_spline.cc | 4 ++-- test/geometry/test_1d2d_intersection.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/functionfromstringexpression/test_functionfromstringexpression.cc b/test/common/functionfromstringexpression/test_functionfromstringexpression.cc index e97865af37..9c75c93add 100644 --- a/test/common/functionfromstringexpression/test_functionfromstringexpression.cc +++ b/test/common/functionfromstringexpression/test_functionfromstringexpression.cc @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) const std::string funcStr = "foo*sin(bar)*bla"; bool error = false; try { FunctionFromStringExpression<2> func(funcStr, std::array<std::string, 2>{{"foo" "bar"}}); } - catch (Dune::IOError& e) { error = true; } + catch (const Dune::IOError& e) { error = true; } if (!error) DUNE_THROW(Dune::Exception, "Faulty expression did not throw: " << funcStr); } diff --git a/test/common/spline/test_spline.cc b/test/common/spline/test_spline.cc index 30249beeb2..10f8a086f1 100644 --- a/test/common/spline/test_spline.cc +++ b/test/common/spline/test_spline.cc @@ -240,8 +240,8 @@ void plot() double y_[] = { 10, 0, 10, 0, 10 }; double m1 = 10; double m2 = -10; - FV &xs = *reinterpret_cast<FV*>(x_); - FV &ys = *reinterpret_cast<FV*>(y_); + const FV &xs = *reinterpret_cast<FV*>(x_); + const FV &ys = *reinterpret_cast<FV*>(y_); Dumux::Spline<double, numSamples> spFull(xs, ys, m1, m2); Dumux::Spline<double, numSamples> spNatural(xs, ys); diff --git a/test/geometry/test_1d2d_intersection.cc b/test/geometry/test_1d2d_intersection.cc index d4cf483f19..0deac74958 100644 --- a/test/geometry/test_1d2d_intersection.cc +++ b/test/geometry/test_1d2d_intersection.cc @@ -26,7 +26,7 @@ Dune::MultiLinearGeometry<double, 1, 3> makeLine(std::initializer_list<Dune::FieldVector<double, 2>>&& c, std::integral_constant<int, 3>) { std::vector<Dune::FieldVector<double, 3>> corners; - for (auto& corner : c) + for (const auto& corner : c) { Dune::FieldVector<double, 3> coord; coord[0] = corner[0]; -- GitLab