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.
This commit is contained in:
@@ -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<const char *>(a_Bytes);
|
||||
const char * Bytes = static_cast<const char *>(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<char *>(a_Buffer); // So that we can do byte math
|
||||
char * Dst = static_cast<char *>(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<char *>(const_cast<void*>(a_Buffer)); // So that we can do byte math
|
||||
const char * Src = static_cast<const char *>(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)
|
||||
|
||||
Reference in New Issue
Block a user