From a4dbb5c58270959884c17d720185da06464fa256 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Wed, 2 May 2018 08:50:36 +0100 Subject: Prefer static_cast to reinterpret_cast (#4223) * Change reinterpret_cast -> static_cast wherever possible * Remove more unnecessary `const_cast`s. reinterpret_casts should be avoided for the same reason as c-style casts - they don't do any type-checking. reinterpret_cast was mainly being used for down-casting in inheritance hierarchies but static_cast works just as well while also making sure that there is actually an inheritance relationship there. --- src/mbedTLS++/CryptoKey.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mbedTLS++/CryptoKey.cpp') diff --git a/src/mbedTLS++/CryptoKey.cpp b/src/mbedTLS++/CryptoKey.cpp index 6615991d6..b0c0da167 100644 --- a/src/mbedTLS++/CryptoKey.cpp +++ b/src/mbedTLS++/CryptoKey.cpp @@ -109,7 +109,7 @@ int cCryptoKey::ParsePublic(const void * a_Data, size_t a_NumBytes) { ASSERT(!IsValid()); // Cannot parse a second key - return mbedtls_pk_parse_public_key(&m_Pk, reinterpret_cast(a_Data), a_NumBytes); + return mbedtls_pk_parse_public_key(&m_Pk, static_cast(a_Data), a_NumBytes); } @@ -122,7 +122,7 @@ int cCryptoKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AStri ASSERT(!IsValid()); // Cannot parse a second key // mbedTLS requires that PEM-encoded data is passed including the terminating NUL byte, // and DER-encoded data is decoded properly even with an extra trailing NUL byte, so we simply add one to everything: - AString keyData(reinterpret_cast(a_Data), a_NumBytes); + AString keyData(static_cast(a_Data), a_NumBytes); if (a_Password.empty()) { -- cgit v1.2.3