From 4a89b2b84d610ce7a26e7cd9a7dbc7ce177a91e2 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Thu, 3 Nov 2022 16:52:22 +0100 Subject: [PATCH] [cpp] Fix more warnings on latest Clang. --- spine-cpp/spine-cpp/include/spine/RegionAttachment.h | 2 +- spine-cpp/spine-cpp/src/spine/Bone.cpp | 8 ++++++-- spine-cpp/spine-cpp/src/spine/IkConstraint.cpp | 6 +++--- spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp | 6 +++--- spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h index bd8cc1827..9420d6dfd 100644 --- a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h @@ -61,7 +61,7 @@ namespace spine { void updateRegion(); /// Transforms the attachment's four vertices to world coordinates. - /// @param bone The parent bone. + /// @param slot The parent slot. /// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8. /// @param offset The worldVertices index to begin writing values. /// @param stride The number of worldVertices entries between the value pairs written. diff --git a/spine-cpp/spine-cpp/src/spine/Bone.cpp b/spine-cpp/spine-cpp/src/spine/Bone.cpp index d0238abbe..c8a2548a7 100644 --- a/spine-cpp/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/spine-cpp/src/spine/Bone.cpp @@ -523,7 +523,7 @@ void Bone::updateAppliedTransform() { break; } case TransformMode_NoScale: - case TransformMode_NoScaleOrReflection: + case TransformMode_NoScaleOrReflection: { float cos = MathUtil::cosDeg(_rotation), sin = MathUtil::sinDeg(_rotation); pa = (pa * cos + pb * sin) / _skeleton.getScaleX(); pc = (pc * cos + pd * sin) / _skeleton.getScaleY(); @@ -540,7 +540,11 @@ void Bone::updateAppliedTransform() { ia = pd * pid; ib = pb * pid; ic = pc * pid; - id = pa * pid; + id = pa * pid; + break; + } + default: + break; } ra = ia * _a - ib * _c; rb = ia * _b - ib * _d; diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp index e36bdf18e..b6036c331 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp @@ -154,11 +154,11 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY } x = targetX - pp->_worldX; y = targetY - pp->_worldY; - tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; + tx = (x * d - y * b) * id - px; ty = (y * a - x * c) * id - py; dd = tx * tx + ty * ty; if (softness != 0) { softness *= psx * (csx + 1) * 0.5f; - td = MathUtil::sqrt(dd), sd = td - l1 - l2 * psx + softness; + td = MathUtil::sqrt(dd); sd = td - l1 - l2 * psx + softness; if (sd > 0) { p = MathUtil::min(1.0f, sd / (softness * 2)) - 1; p = (sd - softness * (1 - p * p)) / td; @@ -188,7 +188,7 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY b = l2 * MathUtil::sin(a2); a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b); } else { - a = psx * l2, b = psy * l2; + a = psx * l2; b = psy * l2; float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx); float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa; d = c1 * c1 - 4 * c2 * c0; diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp index a006284c1..dca81584f 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp @@ -109,9 +109,9 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons int lowHash = readInt(input); int hightHash = readInt(input); String hashString; - sprintf(buffer, "%x", hightHash); + snprintf(buffer, 16, "%x", hightHash); hashString.append(buffer); - sprintf(buffer, "%x", lowHash); + snprintf(buffer, 16, "%x", lowHash); hashString.append(buffer); skeletonData->_hash = hashString; @@ -120,7 +120,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) { char errorMsg[255]; - sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING); + snprintf(errorMsg, 255, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING); setError(errorMsg, ""); return NULL; } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp index 80a88c8d0..2c9228db1 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp @@ -152,7 +152,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { skeletonData->_version = Json::getString(skeleton, "spine", 0); if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) { char errorMsg[255]; - sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING); + snprintf(errorMsg, 255, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING); setError(NULL, errorMsg, ""); return NULL; }