From 6f3282623f6c484d24e120f839eb0f33e8f90772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Thu, 7 Dec 2017 14:46:19 +0100 Subject: [PATCH] Fixed various type conversion/comparison warnings. --- src/SFML/Audio/Music.cpp | 2 +- src/SFML/Audio/SoundFileReaderFlac.cpp | 6 +++--- src/SFML/Audio/SoundFileReaderWav.cpp | 2 +- src/SFML/Graphics/Font.cpp | 8 ++++---- src/SFML/Graphics/RenderTarget.cpp | 2 +- src/SFML/Graphics/Shader.cpp | 12 ++++++------ src/SFML/Network/Ftp.cpp | 4 ++-- src/SFML/System/FileInputStream.cpp | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index 62855f80..dc9a896d 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -188,7 +188,7 @@ bool Music::onGetData(SoundStream::Chunk& data) // This will trip an "onLoop()" call from the underlying SoundStream, // and we can then take action. if (getLoop() && (m_loopSpan.length != 0) && (currentOffset <= loopEnd) && (currentOffset + toFill > loopEnd)) - toFill = loopEnd - currentOffset; + toFill = static_cast(loopEnd - currentOffset); // Fill the chunk parameters data.samples = &m_samples[0]; diff --git a/src/SFML/Audio/SoundFileReaderFlac.cpp b/src/SFML/Audio/SoundFileReaderFlac.cpp index 00794b66..8828af23 100644 --- a/src/SFML/Audio/SoundFileReaderFlac.cpp +++ b/src/SFML/Audio/SoundFileReaderFlac.cpp @@ -284,14 +284,14 @@ Uint64 SoundFileReaderFlac::read(Int16* samples, Uint64 maxCount) assert(m_decoder); // If there are leftovers from previous call, use it first - Uint64 left = m_clientData.leftovers.size(); + std::size_t left = m_clientData.leftovers.size(); if (left > 0) { if (left > maxCount) { // There are more leftovers than needed - std::copy(m_clientData.leftovers.begin(), m_clientData.leftovers.begin() + maxCount, samples); - std::vector leftovers(m_clientData.leftovers.begin() + maxCount, m_clientData.leftovers.end()); + std::copy(m_clientData.leftovers.begin(), m_clientData.leftovers.begin() + static_cast(maxCount), samples); + std::vector leftovers(m_clientData.leftovers.begin() + static_cast(maxCount), m_clientData.leftovers.end()); m_clientData.leftovers.swap(leftovers); return maxCount; } diff --git a/src/SFML/Audio/SoundFileReaderWav.cpp b/src/SFML/Audio/SoundFileReaderWav.cpp index b49909e8..30f23e5b 100644 --- a/src/SFML/Audio/SoundFileReaderWav.cpp +++ b/src/SFML/Audio/SoundFileReaderWav.cpp @@ -155,7 +155,7 @@ Uint64 SoundFileReaderWav::read(Int16* samples, Uint64 maxCount) assert(m_stream); Uint64 count = 0; - while ((count < maxCount) && (m_stream->tell() < m_dataEnd)) + while ((count < maxCount) && (static_cast(m_stream->tell()) < m_dataEnd)) { switch (m_bytesPerSample) { diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 0ab41b9b..f148956e 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -631,9 +631,9 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f if (bitmap.pixel_mode == FT_PIXEL_MODE_MONO) { // Pixels are 1 bit monochrome values - for (int y = padding; y < height - padding; ++y) + for (unsigned int y = padding; y < height - padding; ++y) { - for (int x = padding; x < width - padding; ++x) + for (unsigned int x = padding; x < width - padding; ++x) { // The color channels remain white, just fill the alpha channel std::size_t index = x + y * width; @@ -645,9 +645,9 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f else { // Pixels are 8 bits gray levels - for (int y = padding; y < height - padding; ++y) + for (unsigned int y = padding; y < height - padding; ++y) { - for (int x = padding; x < width - padding; ++x) + for (unsigned int x = padding; x < width - padding; ++x) { // The color channels remain white, just fill the alpha channel std::size_t index = x + y * width; diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index 4faa7ddb..2dce1b40 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -298,7 +298,7 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount, GLenum mode = modes[type]; // Draw the primitives - glCheck(glDrawArrays(mode, 0, vertexCount)); + glCheck(glDrawArrays(mode, 0, static_cast(vertexCount))); // Unbind the shader, if any if (states.shader) diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index 92b92dbf..b423ca68 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -593,7 +593,7 @@ void Shader::setUniformArray(const std::string& name, const float* scalarArray, { UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform1fv(binder.location, length, scalarArray)); + glCheck(GLEXT_glUniform1fv(binder.location, static_cast(length), scalarArray)); } @@ -604,7 +604,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec2* vectorAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform2fv(binder.location, length, &contiguous[0])); + glCheck(GLEXT_glUniform2fv(binder.location, static_cast(length), &contiguous[0])); } @@ -615,7 +615,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec3* vectorAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform3fv(binder.location, length, &contiguous[0])); + glCheck(GLEXT_glUniform3fv(binder.location, static_cast(length), &contiguous[0])); } @@ -626,7 +626,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec4* vectorAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform4fv(binder.location, length, &contiguous[0])); + glCheck(GLEXT_glUniform4fv(binder.location, static_cast(length), &contiguous[0])); } @@ -641,7 +641,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat3* matrixAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniformMatrix3fv(binder.location, length, GL_FALSE, &contiguous[0])); + glCheck(GLEXT_glUniformMatrix3fv(binder.location, static_cast(length), GL_FALSE, &contiguous[0])); } @@ -656,7 +656,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, &contiguous[0])); + glCheck(GLEXT_glUniformMatrix4fv(binder.location, static_cast(length), GL_FALSE, &contiguous[0])); } diff --git a/src/SFML/Network/Ftp.cpp b/src/SFML/Network/Ftp.cpp index 1882da86..c77ccd2f 100644 --- a/src/SFML/Network/Ftp.cpp +++ b/src/SFML/Network/Ftp.cpp @@ -463,7 +463,7 @@ Ftp::Response Ftp::getResponse() } // Save the remaining data for the next time getResponse() is called - m_receiveBuffer.assign(buffer + in.tellg(), length - in.tellg()); + m_receiveBuffer.assign(buffer + static_cast(in.tellg()), length - static_cast(in.tellg())); // Return the response code and message return Response(static_cast(code), message); @@ -631,7 +631,7 @@ void Ftp::DataChannel::send(std::istream& stream) break; } - count = stream.gcount(); + count = static_cast(stream.gcount()); if (count > 0) { diff --git a/src/SFML/System/FileInputStream.cpp b/src/SFML/System/FileInputStream.cpp index e6f1c838..1684e812 100644 --- a/src/SFML/System/FileInputStream.cpp +++ b/src/SFML/System/FileInputStream.cpp @@ -95,7 +95,7 @@ Int64 FileInputStream::seek(Int64 position) #else if (m_file) { - if (std::fseek(m_file, static_cast(position), SEEK_SET)) + if (std::fseek(m_file, static_cast(position), SEEK_SET)) return -1; return tell();