]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid C-style casts in some tests
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 12 Dec 2018 23:29:00 +0000 (00:29 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 12 Dec 2018 23:42:03 +0000 (00:42 +0100)
tests/quick_tests/affinity.cc
tests/quick_tests/lapack.cc
tests/tests.h

index db80e93c98adc03211a285f3325cdd0398cdf5de..edde64a356d4d1fe23a5309a8b4969d9b4f624a0 100644 (file)
@@ -50,7 +50,7 @@ getaffinity(unsigned int &bits_set, unsigned int &mask)
   for (int i = 0; i < CPU_SETSIZE; ++i)
     bits_set += CPU_ISSET(i, &my_set);
 
-  mask = *(int *)(&my_set);
+  mask = *reinterpret_cast<int *>(&my_set);
 #else
   // sadly we don't have an implementation
   // for mac/windows
index 2be5515cc551e37a3e82f31d71fbaa6243ee9526..fbfcc15f919901a9c50043087752847e715a2161 100644 (file)
@@ -112,7 +112,7 @@ main()
   for (unsigned int i = 0; i < A.m(); ++i)
     {
       std::complex<double> lambda = LA.eigenvalue(i);
-      deallog << "Eigenvalues " << (int)(lambda.real() + .0001) << '\t'
-              << (int)(lambda.imag() + .0001) << std::endl;
+      deallog << "Eigenvalues " << static_cast<int>(lambda.real() + .0001)
+              << '\t' << static_cast<int>(lambda.imag() + .0001) << std::endl;
     }
 }
index 2337c0bea5cf23c74066bccaaf1b32473a5edf97..f585da1fc761eb7b4ae74142c3cb26a99a92ed03 100644 (file)
@@ -222,7 +222,7 @@ namespace Testing
     r[k % 32] = nonoverflow_add(r[(k + 32 - 31) % 32], r[(k + 32 - 3) % 32]);
     int ret   = r[k % 32];
     k         = (k + 1) % 32;
-    return (unsigned int)ret >> 1;
+    return static_cast<unsigned int>(ret) >> 1;
   }
 
   // reseed our random number generator
@@ -315,7 +315,7 @@ checksum(const IT &begin, const IT &end)
 
   while (it != end)
     {
-      a = (a + (unsigned char)*it) % 65521;
+      a = (a + static_cast<unsigned char>(*it)) % 65521;
       b = (a + b) % 65521;
       ++it;
     }

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.