]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Reduce the scope of some variables.
authorDavid Wells <wellsd2@rpi.edu>
Sat, 4 Mar 2017 21:51:36 +0000 (16:51 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Sat, 4 Mar 2017 23:38:58 +0000 (18:38 -0500)
This was caught by cppcheck.

source/base/data_out_base.cc
source/numerics/data_out_rotation.cc

index f375ccb43aa84eb12b18fd1b81f216a84d8b6937..812f066ae379fff4e1148cc40eb24ffbd55ae0b8 100644 (file)
@@ -121,7 +121,6 @@ namespace
       const char *const plaintextend = plaintext_in + length_in;
       char *codechar = code_out;
       char result;
-      char fragment;
 
       result = state_in->result;
 
@@ -130,40 +129,46 @@ namespace
           while (1)
             {
             case step_A:
+            {
               if (plainchar == plaintextend)
                 {
                   state_in->result = result;
                   state_in->step = step_A;
                   return codechar - code_out;
                 }
-              fragment = *plainchar++;
+              const char fragment = *plainchar++;
               result = (fragment & 0x0fc) >> 2;
               *codechar++ = base64_encode_value(result);
               result = (fragment & 0x003) << 4;
+            }
             case step_B:
+            {
               if (plainchar == plaintextend)
                 {
                   state_in->result = result;
                   state_in->step = step_B;
                   return codechar - code_out;
                 }
-              fragment = *plainchar++;
+              const char fragment = *plainchar++;
               result |= (fragment & 0x0f0) >> 4;
               *codechar++ = base64_encode_value(result);
               result = (fragment & 0x00f) << 2;
+            }
             case step_C:
+            {
               if (plainchar == plaintextend)
                 {
                   state_in->result = result;
                   state_in->step = step_C;
                   return codechar - code_out;
                 }
-              fragment = *plainchar++;
+              const char fragment = *plainchar++;
               result |= (fragment & 0x0c0) >> 6;
               *codechar++ = base64_encode_value(result);
               result  = (fragment & 0x03f) >> 0;
               *codechar++ = base64_encode_value(result);
             }
+          }
         }
       /* control should not reach here */
       return codechar - code_out;
index dfab4fb512876bd89fcbb8af57eb1eb1a7597287..0b2de31de6de675f5270a5111c50714b404c400b 100644 (file)
@@ -177,11 +177,11 @@ build_one_patch (const cell_iterator
           Assert (false, ExcNotImplemented());
         };
 
-      unsigned int offset=0;
-
       // then fill in data
       if (data.n_datasets > 0)
         {
+          unsigned int offset=0;
+
           data.reinit_all_fe_values(this->dof_data, *cell);
           // first fill dof_data
           for (unsigned int dataset=0; dataset<this->dof_data.size(); ++dataset)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.