Browse Source

Address some compiler warnings

Sasha Szpakowski 1 year ago
parent
commit
6aaf0b22bf

+ 1 - 1
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);

+ 6 - 6
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)

+ 1 - 1
src/modules/font/freetype/HarfbuzzShaper.h

@@ -53,7 +53,7 @@ private:
 
 	struct BufferRange
 	{
-		int index;
+		size_t index;
 		int codepointStart;
 		Range range;
 	};

+ 0 - 1
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))
 	{

+ 1 - 1
src/modules/image/magpie/PVRHandler.cpp

@@ -511,7 +511,7 @@ StrongRef<ByteData> PVRHandler::parseCompressed(Data *filedata, std::vector<Stro
 	PixelFormat cformat = convertFormat(pixelformat, channeltype);
 
 	if (header3.colorSpace == 1)
-		cformat == getSRGBPixelFormat(cformat);
+		cformat = getSRGBPixelFormat(cformat);
 
 	if (cformat == PIXELFORMAT_UNKNOWN)
 		throw love::Exception("Could not parse PVR file: unsupported image format.");

+ 1 - 1
src/modules/sensor/sdl/Sensor.cpp

@@ -121,7 +121,7 @@ std::vector<void*> Sensor::getHandles()
 {
 	std::vector<void*> nativeSensor;
 
-	for (const std::pair<SensorType, SDL_Sensor*> &data: sensors)
+	for (std::pair<SensorType, SDL_Sensor*> data : sensors)
 	{
 		if (data.second)
 			nativeSensor.push_back(data.second);