Start to enable int-warnings
diff --git a/build/premake5.lua b/build/premake5.lua index 340807c..8749d62 100644 --- a/build/premake5.lua +++ b/build/premake5.lua
@@ -66,7 +66,12 @@ files {"../src/**.cpp"} - buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti", "-Werror=format"} + buildoptions { + "-Wall", "-fno-exceptions", + "-fno-rtti", + "-Werror=format", + "-Wimplicit-int-conversion", + } filter {"system:macosx" } buildoptions {"-flto=full"}
diff --git a/src/shapes/mesh.cpp b/src/shapes/mesh.cpp index fa8234f..e98d853 100644 --- a/src/shapes/mesh.cpp +++ b/src/shapes/mesh.cpp
@@ -58,9 +58,7 @@ BinaryReader reader(value); while (!reader.reachedEnd()) { - uint64_t index = reader.readVarUint64(); - assert(index < std::numeric_limits<uint16_t>::max()); - buffer->push_back(index); + buffer->push_back(reader.readVarUintAs<uint16_t>()); } m_IndexBuffer = buffer; }
diff --git a/src/shapes/metrics_path.cpp b/src/shapes/metrics_path.cpp index 3574eef..dd9fff3 100644 --- a/src/shapes/metrics_path.cpp +++ b/src/shapes/metrics_path.cpp
@@ -1,3 +1,4 @@ +#include "rive/core/type_conversions.hpp" #include "rive/shapes/metrics_path.hpp" #include "rive/renderer.hpp" #include <math.h> @@ -34,12 +35,15 @@ } void MetricsPath::lineTo(float x, float y) { - m_Parts.push_back(PathPart(0, m_Points.size())); + // TODO: resize PathPart to allow for larger offsets + auto offset = castTo<uint8_t>(m_Points.size()); + m_Parts.push_back(PathPart(0, offset)); m_Points.emplace_back(Vec2D(x, y)); } void MetricsPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) { - m_Parts.push_back(PathPart(1, m_Points.size())); + auto offset = castTo<uint8_t>(m_Points.size()); + m_Parts.push_back(PathPart(1, offset)); m_Points.emplace_back(Vec2D(ox, oy)); m_Points.emplace_back(Vec2D(ix, iy)); m_Points.emplace_back(Vec2D(x, y)); @@ -157,12 +161,12 @@ pen = &to; int index = (int)m_CubicSegments.size(); - part.type = index + 1; + part.type = castTo<uint8_t>(index + 1); float partLength = segmentCubic(from, fromOut, toIn, to, 0.0f, 0.0f, 1.0f, m_CubicSegments); m_Lengths.push_back(partLength); length += partLength; - part.numSegments = m_CubicSegments.size() - index; + part.numSegments = castTo<uint8_t>(m_CubicSegments.size() - index); break; } }