Replace reinterpret_cast with safer or no cast
When casting types to one another in C++, the weaker the cast,
the better.
This change replaces instances of reinterpret_cast with static_cast
or no cast where it safe and correct to do so.
BUG=angleproject:2683
Change-Id: I99c9033614a65282ae1d78cf0f4b80fabd75877a
Reviewed-on: https://chromium-review.googlesource.com/1109396
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp
index 417f9df..f42a405 100644
--- a/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -455,7 +455,7 @@
packBuffer && packState.rowLength != 0 &&
packState.rowLength < area.width;
- GLubyte *pixels = reinterpret_cast<GLubyte *>(ptrOrOffset);
+ GLubyte *pixels = static_cast<GLubyte *>(ptrOrOffset);
int leftClip = area.x - origArea.x;
int topClip = area.y - origArea.y;
if (leftClip || topClip)
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
index 2f617f2..9c4edac 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.cpp
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
@@ -357,7 +357,7 @@
// Attributes using client memory ignore the VERTEX_ATTRIB_BINDING state.
// https://www.opengl.org/registry/specs/ARB/vertex_attrib_binding.txt
- const uint8_t *inputPointer = reinterpret_cast<const uint8_t *>(attrib.pointer);
+ const uint8_t *inputPointer = static_cast<const uint8_t *>(attrib.pointer);
// Pack the data when copying it, user could have supplied a very large stride that
// would cause the buffer to be much larger than needed.
diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp
index 1464033..0e1226f 100644
--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp
+++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp
@@ -1306,8 +1306,7 @@
{
if (functions->mapBufferRange != nullptr)
{
- return reinterpret_cast<uint8_t *>(
- functions->mapBufferRange(target, offset, length, access));
+ return static_cast<uint8_t *>(functions->mapBufferRange(target, offset, length, access));
}
else if (functions->mapBuffer != nullptr &&
(functions->standard == STANDARD_GL_DESKTOP || access == GL_MAP_WRITE_BIT))
@@ -1334,7 +1333,7 @@
return nullptr;
}
- return reinterpret_cast<uint8_t *>(functions->mapBuffer(target, accessEnum)) + offset;
+ return static_cast<uint8_t *>(functions->mapBuffer(target, accessEnum)) + offset;
}
else
{