From fe785ea788cc81fcdcb26c9096df86c129a211e3 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 3 Jul 2022 15:36:32 +0400 Subject: [PATCH] Don't cast away const when we can avoid it --- components/esm3/esmwriter.hpp | 2 +- components/misc/utf8stream.hpp | 5 ++++- components/myguiplatform/myguirendermanager.cpp | 6 +++--- components/nifosg/nifloader.cpp | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/esm3/esmwriter.hpp b/components/esm3/esmwriter.hpp index 473e948f98..ddb9844796 100644 --- a/components/esm3/esmwriter.hpp +++ b/components/esm3/esmwriter.hpp @@ -115,7 +115,7 @@ class ESMWriter void writeT(const T& data) { static_assert(!std::is_pointer_v); - write((char*)&data, sizeof(T)); + write(reinterpret_cast(&data), sizeof(T)); } template diff --git a/components/misc/utf8stream.hpp b/components/misc/utf8stream.hpp index 8435816c67..847d73ceb7 100644 --- a/components/misc/utf8stream.hpp +++ b/components/misc/utf8stream.hpp @@ -22,7 +22,10 @@ public: } Utf8Stream (const char * str) : - cur ((unsigned char*) str), nxt ((unsigned char*) str), end ((unsigned char*) str + strlen(str)), val(Utf8Stream::sBadChar()) + cur (reinterpret_cast(str)), + nxt (reinterpret_cast(str)), + end (reinterpret_cast(str) + strlen(str)), + val(Utf8Stream::sBadChar()) { } diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index 77b20ae5c7..9d48a0d35a 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -137,9 +137,9 @@ public: } else { - glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), (char*)vbo->getArray(0)->getDataPointer()); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), (char*)vbo->getArray(0)->getDataPointer() + 12); - glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), (char*)vbo->getArray(0)->getDataPointer() + 16); + glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), reinterpret_cast(vbo->getArray(0)->getDataPointer())); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), reinterpret_cast(vbo->getArray(0)->getDataPointer()) + 12); + glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), reinterpret_cast(vbo->getArray(0)->getDataPointer()) + 16); } glDrawArrays(GL_TRIANGLES, 0, batch.mVertexCount); diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 9b2e8db8d6..fd3fb40d9f 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1284,7 +1284,7 @@ namespace NifOsg if (strip.size() < 3) continue; geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, strip.size(), - (unsigned short*)strip.data())); + reinterpret_cast(strip.data()))); hasGeometry = true; } if (!hasGeometry) @@ -1299,7 +1299,7 @@ namespace NifOsg if (line.empty()) return; geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::LINES, line.size(), - (unsigned short*)line.data())); + reinterpret_cast(line.data()))); } handleNiGeometryData(geometry, niGeometryData, boundTextures, nifNode->name);