From bf2d57f187f57b2913b21c811868415b6baf56f3 Mon Sep 17 00:00:00 2001 From: Graham Pentheny Date: Tue, 2 Sep 2025 17:48:08 -0400 Subject: [PATCH] Fix some static analysis warnings --- RecastDemo/Source/InputGeom.cpp | 13 +++++++++---- RecastDemo/Source/SampleInterfaces.cpp | 7 +++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/RecastDemo/Source/InputGeom.cpp b/RecastDemo/Source/InputGeom.cpp index 49395213..9f71b45e 100644 --- a/RecastDemo/Source/InputGeom.cpp +++ b/RecastDemo/Source/InputGeom.cpp @@ -88,7 +88,7 @@ bool intersectSegmentTriangle(const float* sp, const float* sq, const float* a, bool isectSegAABB(const float* sp, const float* sq, const float* amin, const float* amax, float& tmin, float& tmax) { - static const float EPS = 1e-6f; + static constexpr float EPS = 1e-6f; float d[3]; rcVsub(d, sq, sp); @@ -452,12 +452,18 @@ bool InputGeom::loadGeomSet(rcContext* ctx, char* buffer, size_t bufferLen) &bidir, &area, &flags); - addOffMeshConnection(startPos, endPos, rad, bidir, area, flags); + addOffMeshConnection( + startPos, + endPos, + rad, + static_cast(bidir), + static_cast(area), + static_cast(flags)); } else if (row[0] == 'v') { // Convex volumes - ConvexVolume vol; + ConvexVolume& vol = convexVolumes.emplace_back(); sscanf(row + 1, "%d %d %f %f", &vol.nverts, &vol.area, &vol.hmin, &vol.hmax); for (int i = 0; i < vol.nverts; ++i) { @@ -465,7 +471,6 @@ bool InputGeom::loadGeomSet(rcContext* ctx, char* buffer, size_t bufferLen) src = parseRow(src, srcEnd, row, sizeof(row) / sizeof(char)); sscanf(row, "%f %f %f", &vol.verts[i * 3 + 0], &vol.verts[i * 3 + 1], &vol.verts[i * 3 + 2]); } - convexVolumes.emplace_back(std::move(vol)); } else if (row[0] == 's') { diff --git a/RecastDemo/Source/SampleInterfaces.cpp b/RecastDemo/Source/SampleInterfaces.cpp index f7f5e1c9..b96d1a29 100644 --- a/RecastDemo/Source/SampleInterfaces.cpp +++ b/RecastDemo/Source/SampleInterfaces.cpp @@ -5,7 +5,6 @@ #include #ifdef WIN32 -# define snprintf _snprintf # include #else # include @@ -216,7 +215,7 @@ void DebugDrawGL::begin(duDebugDrawPrimitives prim, float size) case DU_DRAW_QUADS: glBegin(GL_QUADS); break; - }; + } } void DebugDrawGL::vertex(const float* pos, unsigned int color) @@ -344,10 +343,10 @@ size_t FileIO::getFileSize() const void FileIO::scanDirectory(const std::string& path, const std::string& ext, std::vector& fileList) { #ifdef WIN32 - std::string pathWithExt = path + "/*" + ext; + const std::string pathWithExt = path + "/*" + ext; _finddata_t dir; - intptr_t findHandle = _findfirst(pathWithExt.c_str(), &dir); + const intptr_t findHandle = _findfirst(pathWithExt.c_str(), &dir); if (findHandle == -1L) { return;