From 3c73183a04302be98ef52d2422c9b888edc0c7d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 7 May 2018 15:05:59 +0200 Subject: [PATCH] Cleanups - fix warnings --- libretro-common/formats/json/jsonsax_full.c | 16 +++++++--------- libretro-db/rmsgpack.c | 4 ++-- menu/menu_displaylist.c | 3 ++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libretro-common/formats/json/jsonsax_full.c b/libretro-common/formats/json/jsonsax_full.c index 3704620f84..3a413d8d05 100644 --- a/libretro-common/formats/json/jsonsax_full.c +++ b/libretro-common/formats/json/jsonsax_full.c @@ -1217,7 +1217,7 @@ static void JSON_Parser_NullTerminateToken(JSON_Parser parser) can write the null terminator to the buffer with impunity. */ static const byte nullTerminatorBytes[LONGEST_ENCODING_SEQUENCE] = { 0 }; Encoding encoding = (Encoding)((parser->token == T_NUMBER) ? parser->numberEncoding : parser->stringEncoding); - memcpy(parser->pTokenBytes + parser->tokenBytesUsed, nullTerminatorBytes, SHORTEST_ENCODING_SEQUENCE(encoding)); + memcpy(parser->pTokenBytes + parser->tokenBytesUsed, nullTerminatorBytes, (size_t)SHORTEST_ENCODING_SEQUENCE(encoding)); } static JSON_Status JSON_Parser_FlushParser(JSON_Parser parser) @@ -1514,10 +1514,10 @@ static JSON_Status JSON_Parser_HandleInvalidNumber(JSON_Parser parser, "1.2e-!" => "1.2" */ parser->codepointLocationByte -= (size_t)codepointsSinceValidNumber - * SHORTEST_ENCODING_SEQUENCE(parser->inputEncoding); + * (size_t)SHORTEST_ENCODING_SEQUENCE(parser->inputEncoding); parser->codepointLocationColumn -= (size_t)codepointsSinceValidNumber; parser->tokenBytesUsed -= (size_t)codepointsSinceValidNumber - * SHORTEST_ENCODING_SEQUENCE(parser->numberEncoding); + * (size_t)SHORTEST_ENCODING_SEQUENCE(parser->numberEncoding); return JSON_Parser_ProcessToken(parser); /* always fails */ } /* Allow JSON_Parser_FlushLexer() to fail. */ @@ -3232,7 +3232,7 @@ static JSON_Status JSON_Writer_OutputString(JSON_Writer writer, const byte* pByt static const byte* const quoteEncodings[5] = { quoteUTF + 3, quoteUTF + 3, quoteUTF + 2, quoteUTF + 3, quoteUTF }; const byte* pQuoteEncoded = quoteEncodings[writer->outputEncoding - 1]; - size_t minSequenceLength = SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); + size_t minSequenceLength = (size_t)SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); DecoderData decoderData; WriteBufferData bufferData; size_t i = 0; @@ -3510,7 +3510,7 @@ static JSON_Status JSON_Writer_OutputSpaces(JSON_Writer writer, size_t numberOfS static const byte spacesUTF32[SPACES_PER_CHUNK * 4 + 3] = { 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0, ' ', 0, 0, 0 }; static const byte* const spacesEncodings[5] = { spacesUTF8, spacesUTF16 + 1, spacesUTF16, spacesUTF32 + 3, spacesUTF32 }; - size_t encodedLength = SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); + size_t encodedLength = (size_t)SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); const byte* encoded = spacesEncodings[writer->outputEncoding - 1]; while (numberOfSpaces > SPACES_PER_CHUNK) { @@ -3529,7 +3529,7 @@ static JSON_Status JSON_Writer_WriteSimpleToken(JSON_Writer writer, Symbol token JSON_Status status = JSON_Failure; if (writer && !GET_FLAGS(writer->state, WRITER_IN_PROTECTED_API) && writer->error == JSON_Error_None) { - size_t encodedLength = length * SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); + size_t encodedLength = length * (size_t)SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); SET_FLAGS_ON(WriterState, writer->state, WRITER_STARTED | WRITER_IN_PROTECTED_API); if (JSON_Writer_ProcessToken(writer, token) && JSON_Writer_OutputBytes(writer, encodings[writer->outputEncoding - 1], encodedLength)) @@ -3870,11 +3870,9 @@ JSON_Status JSON_CALL JSON_Writer_WriteNewLine(JSON_Writer writer) encodings = lfEncodings; length = 1; } - encodedLength = length * SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); + encodedLength = length * (size_t)SHORTEST_ENCODING_SEQUENCE(writer->outputEncoding); if (JSON_Writer_OutputBytes(writer, encodings[writer->outputEncoding - 1], encodedLength)) - { status = JSON_Success; - } SET_FLAGS_OFF(WriterState, writer->state, WRITER_IN_PROTECTED_API); } return status; diff --git a/libretro-db/rmsgpack.c b/libretro-db/rmsgpack.c index 816fb4aee5..98240b8570 100644 --- a/libretro-db/rmsgpack.c +++ b/libretro-db/rmsgpack.c @@ -599,7 +599,7 @@ int rmsgpack_read(RFILE *fd, case _MPF_BIN8: case _MPF_BIN16: case _MPF_BIN32: - if ((rv = read_buff(fd, 1<<(type - _MPF_BIN8), + if ((rv = read_buff(fd, (size_t)(1 << (type - _MPF_BIN8)), &buff, &tmp_len)) < 0) return rv; @@ -633,7 +633,7 @@ int rmsgpack_read(RFILE *fd, case _MPF_STR8: case _MPF_STR16: case _MPF_STR32: - if ((rv = read_buff(fd, 1<<(type - _MPF_STR8), &buff, &tmp_len)) < 0) + if ((rv = read_buff(fd, (size_t)(1 << (type - _MPF_STR8)), &buff, &tmp_len)) < 0) return rv; if (callbacks->read_string) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 588da4c483..eeef413add 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4482,8 +4482,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) break; case DISPLAYLIST_HISTORY: { - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); settings_t *settings = config_get_ptr(); + + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); if (settings->bools.history_list_enable) menu_displaylist_parse_playlist_generic( menu, info,