From 4945d83eff8eae3183a1d1037f91a24b68ce2c05 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 17 Jun 2024 13:01:00 -0600 Subject: [PATCH] Enable clang-tidy `bugprone-misplaced-widening-cast` check --- .clang-tidy | 1 - src/SFML/Graphics/Image.cpp | 2 +- src/SFML/Graphics/Texture.cpp | 4 ++-- src/SFML/Window/DRM/InputImpl.cpp | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index a559652ba..b6e32c755 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -15,7 +15,6 @@ Checks: > -bugprone-exception-escape, -bugprone-implicit-widening-of-multiplication-result, -bugprone-integer-division, - -bugprone-misplaced-widening-cast, -bugprone-narrowing-conversions, -bugprone-signed-char-misuse, -bugprone-string-integer-assignment, diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 80f2b23a1..c00c89438 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -586,7 +586,7 @@ void Image::flipVertically() { if (!m_pixels.empty()) { - const auto rowSize = static_cast::iterator::difference_type>(m_size.x * 4); + const auto rowSize = static_cast::iterator::difference_type>(m_size.x) * 4; auto top = m_pixels.begin(); auto bottom = m_pixels.end() - rowSize; diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 572f32380..fe31ac662 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -483,10 +483,10 @@ Image Texture::copyToImage() const if (m_pixelsFlipped) { // Flip the texture vertically - const auto stride = static_cast(m_size.x * 4); + const auto stride = static_cast(m_size.x) * 4; auto currentRowIterator = pixels.begin(); auto nextRowIterator = pixels.begin() + stride; - auto reverseRowIterator = pixels.begin() + (stride * static_cast(m_size.y - 1)); + auto reverseRowIterator = pixels.begin() + (stride * (static_cast(m_size.y) - 1)); for (unsigned int i = 0; i < m_size.y / 2; ++i) { std::swap_ranges(currentRowIterator, nextRowIterator, reverseRowIterator); diff --git a/src/SFML/Window/DRM/InputImpl.cpp b/src/SFML/Window/DRM/InputImpl.cpp index 4114066e6..a3e2822af 100644 --- a/src/SFML/Window/DRM/InputImpl.cpp +++ b/src/SFML/Window/DRM/InputImpl.cpp @@ -318,7 +318,7 @@ void pushEvent(const sf::Event& event) TouchSlot& atSlot(int idx) { if (idx >= static_cast(touchSlots.size())) - touchSlots.resize(static_cast(idx + 1)); + touchSlots.resize(static_cast(idx) + 1); return touchSlots.at(static_cast(idx)); }