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/ByteBuffer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ByteBuffer.cpp') diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 5b4cdb745..2fecc7817 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -126,7 +126,7 @@ bool cByteBuffer::Write(const void * a_Bytes, size_t a_Count) } ASSERT(m_BufferSize >= m_WritePos); size_t TillEnd = m_BufferSize - m_WritePos; - const char * Bytes = reinterpret_cast(a_Bytes); + const char * Bytes = static_cast(a_Bytes); if (TillEnd <= a_Count) { // Need to wrap around the ringbuffer end @@ -739,7 +739,7 @@ bool cByteBuffer::ReadBuf(void * a_Buffer, size_t a_Count) CHECK_THREAD CheckValid(); NEEDBYTES(a_Count); - char * Dst = reinterpret_cast(a_Buffer); // So that we can do byte math + char * Dst = static_cast(a_Buffer); // So that we can do byte math ASSERT(m_BufferSize >= m_ReadPos); size_t BytesToEndOfBuffer = m_BufferSize - m_ReadPos; if (BytesToEndOfBuffer <= a_Count) @@ -772,7 +772,7 @@ bool cByteBuffer::WriteBuf(const void * a_Buffer, size_t a_Count) CHECK_THREAD CheckValid(); PUTBYTES(a_Count); - char * Src = reinterpret_cast(const_cast(a_Buffer)); // So that we can do byte math + const char * Src = static_cast(a_Buffer); // So that we can do byte math ASSERT(m_BufferSize >= m_ReadPos); size_t BytesToEndOfBuffer = m_BufferSize - m_WritePos; if (BytesToEndOfBuffer <= a_Count) -- cgit v1.2.3