From 6aaf0b22bf0ff91fd48c8254de2b9689f8e33e7c Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 21 Oct 2023 13:55:43 -0300 Subject: [PATCH] Address some compiler warnings --- src/modules/data/wrap_ByteData.cpp | 2 +- src/modules/font/freetype/HarfbuzzShaper.cpp | 12 ++++++------ src/modules/font/freetype/HarfbuzzShaper.h | 2 +- src/modules/font/wrap_Font.cpp | 1 - src/modules/image/magpie/PVRHandler.cpp | 2 +- src/modules/sensor/sdl/Sensor.cpp | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/modules/data/wrap_ByteData.cpp b/src/modules/data/wrap_ByteData.cpp index e299cbae3..57ff5f975 100644 --- a/src/modules/data/wrap_ByteData.cpp +++ b/src/modules/data/wrap_ByteData.cpp @@ -56,7 +56,7 @@ int w_ByteData_setString(lua_State *L) if (size == 0) return 0; - if (offset < 0 || offset + size > (int64) t->getSize()) + if (offset < 0 || offset + (int64) size > (int64) t->getSize()) return luaL_error(L, "The given string offset and size don't fit within the Data's size."); memcpy((char *) t->getData() + (size_t) offset, str, size); diff --git a/src/modules/font/freetype/HarfbuzzShaper.cpp b/src/modules/font/freetype/HarfbuzzShaper.cpp index 70767dada..f7828cecf 100644 --- a/src/modules/font/freetype/HarfbuzzShaper.cpp +++ b/src/modules/font/freetype/HarfbuzzShaper.cpp @@ -153,18 +153,18 @@ void HarfbuzzShaper::computeBufferRanges(const ColoredCodepoints &codepoints, Ra hb_shape(hbFonts[rasti], hbb, nullptr, 0); - int glyphcount = (int)hb_buffer_get_length(hbb); + size_t glyphcount = (size_t)hb_buffer_get_length(hbb); const hb_glyph_info_t *glyphinfos = hb_buffer_get_glyph_infos(hbb, nullptr); hb_direction_t direction = hb_buffer_get_direction(hbb); fallbackranges.clear(); - for (int i = 0; i < glyphcount; i++) + for (size_t i = 0; i < glyphcount; i++) { if (isValidGlyph(glyphinfos[i].codepoint, codepoints.cps, glyphinfos[i].cluster)) { if (bufferranges.empty() || bufferranges.back().index != rasti || bufferranges.back().range.getMax() + 1 != i) - bufferranges.push_back({(int)rasti, (int)glyphinfos[i].cluster, Range(i, 1)}); + bufferranges.push_back({rasti, (int)glyphinfos[i].cluster, Range(i, 1)}); else bufferranges.back().range.last++; } @@ -247,7 +247,7 @@ void HarfbuzzShaper::computeGlyphPositions(const ColoredCodepoints &codepoints, // TODO: this doesn't handle situations where the user inserted a color // change in the middle of some characters that get combined into a single // cluster. - if (colors && colorindex < ncolors && codepoints.colors[colorindex].index == info.cluster) + if (colors && colorindex < ncolors && codepoints.colors[colorindex].index == (int)info.cluster) { colorToAdd.set(codepoints.colors[colorindex].color); colorindex++; @@ -273,7 +273,7 @@ void HarfbuzzShaper::computeGlyphPositions(const ColoredCodepoints &codepoints, continue; // This is a glyph index at this point, despite the name. - GlyphIndex gindex = { (int) info.codepoint, bufferrange.index }; + GlyphIndex gindex = { (int) info.codepoint, (int)bufferrange.index }; if (clustercodepoint == '\t' && isUsingSpacesForTab()) { @@ -390,7 +390,7 @@ int HarfbuzzShaper::computeWordWrapIndex(const ColoredCodepoints &codepoints, Ra if (newwidth > wraplimit) { // If this is the first character, wrap from the next one instead of this one. - int wrapindex = info.cluster > (int) range.first ? info.cluster : (int) range.first + 1; + int wrapindex = (int)info.cluster > (int)range.first ? (int)info.cluster : (int)range.first + 1; // Rewind to after the last seen space when wrapping. if (firstindexafterspace != -1) diff --git a/src/modules/font/freetype/HarfbuzzShaper.h b/src/modules/font/freetype/HarfbuzzShaper.h index 3a71a5b8b..8324b0a7c 100644 --- a/src/modules/font/freetype/HarfbuzzShaper.h +++ b/src/modules/font/freetype/HarfbuzzShaper.h @@ -53,7 +53,7 @@ class HarfbuzzShaper : public love::font::TextShaper struct BufferRange { - int index; + size_t index; int codepointStart; Range range; }; diff --git a/src/modules/font/wrap_Font.cpp b/src/modules/font/wrap_Font.cpp index e2ec84f08..8a843c413 100644 --- a/src/modules/font/wrap_Font.cpp +++ b/src/modules/font/wrap_Font.cpp @@ -103,7 +103,6 @@ static TrueTypeRasterizer::Settings luax_checktruetypesettings(lua_State* L, int int w_newTrueTypeRasterizer(lua_State *L) { Rasterizer *t = nullptr; - TrueTypeRasterizer::Hinting hinting = TrueTypeRasterizer::HINTING_NORMAL; if (lua_type(L, 1) == LUA_TNUMBER || lua_isnone(L, 1)) { diff --git a/src/modules/image/magpie/PVRHandler.cpp b/src/modules/image/magpie/PVRHandler.cpp index f30f01b8b..ef074f0f8 100644 --- a/src/modules/image/magpie/PVRHandler.cpp +++ b/src/modules/image/magpie/PVRHandler.cpp @@ -511,7 +511,7 @@ StrongRef PVRHandler::parseCompressed(Data *filedata, std::vector Sensor::getHandles() { std::vector nativeSensor; - for (const std::pair &data: sensors) + for (std::pair data : sensors) { if (data.second) nativeSensor.push_back(data.second);