From e5233d55b52668f9a523870b5cb02f27f5ccbda8 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 13 Dec 2018 00:29:00 +0100 Subject: [PATCH] Avoid C-style casts in some tests --- tests/quick_tests/affinity.cc | 2 +- tests/quick_tests/lapack.cc | 4 ++-- tests/tests.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/quick_tests/affinity.cc b/tests/quick_tests/affinity.cc index db80e93c98..edde64a356 100644 --- a/tests/quick_tests/affinity.cc +++ b/tests/quick_tests/affinity.cc @@ -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(&my_set); #else // sadly we don't have an implementation // for mac/windows diff --git a/tests/quick_tests/lapack.cc b/tests/quick_tests/lapack.cc index 2be5515cc5..fbfcc15f91 100644 --- a/tests/quick_tests/lapack.cc +++ b/tests/quick_tests/lapack.cc @@ -112,7 +112,7 @@ main() for (unsigned int i = 0; i < A.m(); ++i) { std::complex lambda = LA.eigenvalue(i); - deallog << "Eigenvalues " << (int)(lambda.real() + .0001) << '\t' - << (int)(lambda.imag() + .0001) << std::endl; + deallog << "Eigenvalues " << static_cast(lambda.real() + .0001) + << '\t' << static_cast(lambda.imag() + .0001) << std::endl; } } diff --git a/tests/tests.h b/tests/tests.h index 2337c0bea5..f585da1fc7 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -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(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(*it)) % 65521; b = (a + b) % 65521; ++it; } -- 2.39.5