From: David Wells <wellsd2@rpi.edu>
Date: Sat, 27 Jan 2018 18:24:47 +0000 (-0500)
Subject: Reduce the scope of some variables.
X-Git-Tag: v9.0.0-rc1~505^2~2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7790df55ea42056509ec297b4b6e2f8a59258ab;p=dealii.git

Reduce the scope of some variables.

This was found by cppcheck.
---

diff --git a/include/deal.II/lac/utilities.h b/include/deal.II/lac/utilities.h
index f7689437ea..1b0496e652 100644
--- a/include/deal.II/lac/utilities.h
+++ b/include/deal.II/lac/utilities.h
@@ -328,12 +328,9 @@ namespace Utilities
       std::vector<double> diagonal;
       std::vector<double> subdiagonal;
 
-      // scalars to store norms and inner products
-      double a = 0, b = 0;
-
       // 1. Normalize input vector
       (*v) = v0_;
-      a = v->l2_norm();
+      double a = v->l2_norm();
       Assert (a!=0, ExcDivideByZero());
       (*v) *= 1./a;
 
@@ -347,7 +344,7 @@ namespace Utilities
       for (unsigned int i = 1; i < k; ++i)
         {
           // 4. L2 norm of f
-          b = f->l2_norm();
+          const double b = f->l2_norm();
           Assert (b!=0, ExcDivideByZero());
           // 5. v0 <- v; v <- f/b
           *v0 = *v;
diff --git a/source/base/quadrature_lib.cc b/source/base/quadrature_lib.cc
index 37eaf86d26..48be55bfff 100644
--- a/source/base/quadrature_lib.cc
+++ b/source/base/quadrature_lib.cc
@@ -268,7 +268,6 @@ compute_quadrature_weights(const std::vector<long double> &x,
 {
   const unsigned int q = x.size();
   std::vector<long double> w(q);
-  long double s = 0.L;
 
   const long double factor = std::pow(2., alpha+beta+1) *
                              gamma(alpha+q) *
@@ -276,7 +275,7 @@ compute_quadrature_weights(const std::vector<long double> &x,
                              ((q-1)*gamma(q)*gamma(alpha+beta+q+1));
   for (unsigned int i=0; i<q; ++i)
     {
-      s = JacobiP(x[i], alpha, beta, q-1);
+      const long double s = JacobiP(x[i], alpha, beta, q-1);
       w[i] = factor/(s*s);
     }
   w[0]   *= (beta + 1);