From 2861a358406edeaa7e976d92d3d0e5d68802ce0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 9 Jul 2019 15:50:14 +0200 Subject: [PATCH] Clean some warnings --- apps/shared/cartesian_function.cpp | 2 +- apps/shared/function.cpp | 2 +- apps/shared/text_helpers.cpp | 2 +- escher/src/text_area.cpp | 2 +- ion/src/shared/unicode/utf8_decoder.cpp | 2 +- ion/src/shared/unicode/utf8_helper.cpp | 4 +++- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/shared/cartesian_function.cpp b/apps/shared/cartesian_function.cpp index 5775fdd58..bb349abe6 100644 --- a/apps/shared/cartesian_function.cpp +++ b/apps/shared/cartesian_function.cpp @@ -69,7 +69,7 @@ int CartesianFunction::derivativeNameWithArgument(char * buffer, size_t bufferSi // Fill buffer with f(x). Keep size for derivative sign. int derivativeSize = UTF8Decoder::CharSizeOfCodePoint('\''); int numberOfChars = nameWithArgument(buffer, bufferSize - derivativeSize, arg); - assert(numberOfChars + derivativeSize < bufferSize); + assert(numberOfChars + derivativeSize < (int)bufferSize); char * firstParenthesis = const_cast(UTF8Helper::CodePointSearch(buffer, '(')); if (!UTF8Helper::CodePointIs(firstParenthesis, '(')) { return numberOfChars; diff --git a/apps/shared/function.cpp b/apps/shared/function.cpp index f76da5fc5..8ded6d47e 100644 --- a/apps/shared/function.cpp +++ b/apps/shared/function.cpp @@ -68,7 +68,7 @@ int Function::nameWithArgument(char * buffer, size_t bufferSize, CodePoint arg) assert(UTF8Decoder::CharSizeOfCodePoint(arg) == 1); const char * functionName = fullName(); size_t baseNameLength = SymbolAbstract::TruncateExtension(buffer, functionName, bufferSize - k_parenthesedArgumentLength); - int result = baseNameLength + strlcpy(&buffer[baseNameLength], k_parenthesedArgument, bufferSize-baseNameLength); + size_t result = baseNameLength + strlcpy(&buffer[baseNameLength], k_parenthesedArgument, bufferSize-baseNameLength); int bufferRemainingSize = bufferSize - (baseNameLength+1); if (bufferRemainingSize > 0) { UTF8Decoder::CodePointToChars(arg, buffer+baseNameLength+1, bufferRemainingSize); diff --git a/apps/shared/text_helpers.cpp b/apps/shared/text_helpers.cpp index 199f9f29d..3da53e965 100644 --- a/apps/shared/text_helpers.cpp +++ b/apps/shared/text_helpers.cpp @@ -11,7 +11,7 @@ void PadWithSpaces(char * buffer, int bufferSize, int * currentNumberOfChar, int size_t currentGlyphLength = UTF8Helper::StringGlyphLength(buffer, *currentNumberOfChar); bool addedPadding = false; assert(UTF8Decoder::CharSizeOfCodePoint(' ') == 1); - while (currentGlyphLength < maxGlyphLengthWithPadding && *currentNumberOfChar < bufferSize) { + while ((int)currentGlyphLength < maxGlyphLengthWithPadding && *currentNumberOfChar < bufferSize) { *currentNumberOfChar = *currentNumberOfChar + UTF8Decoder::CodePointToChars(' ', buffer + *currentNumberOfChar, bufferSize - *currentNumberOfChar); addedPadding = true; currentGlyphLength++; diff --git a/escher/src/text_area.cpp b/escher/src/text_area.cpp index 89b4abde2..0b61fa3cf 100644 --- a/escher/src/text_area.cpp +++ b/escher/src/text_area.cpp @@ -21,7 +21,7 @@ TextArea::TextArea(Responder * parentResponder, View * contentView, const KDFont static inline void InsertSpacesAtLocation(int spacesCount, char * buffer, int bufferSize) { assert(buffer != nullptr); - assert(strlen(buffer) + spacesCount < bufferSize); + assert((int)(strlen(buffer) + spacesCount) < bufferSize); size_t sizeToMove = strlen(buffer) + 1; size_t spaceCharSize = UTF8Decoder::CharSizeOfCodePoint(' '); diff --git a/ion/src/shared/unicode/utf8_decoder.cpp b/ion/src/shared/unicode/utf8_decoder.cpp index ea02ba7b3..8e12b8f8f 100644 --- a/ion/src/shared/unicode/utf8_decoder.cpp +++ b/ion/src/shared/unicode/utf8_decoder.cpp @@ -105,7 +105,7 @@ size_t UTF8Decoder::CodePointToChars(CodePoint c, char * buffer, size_t bufferSi return 0; } size_t i = 0; - int charCount = CharSizeOfCodePoint(c); + size_t charCount = CharSizeOfCodePoint(c); if (charCount == 1) { buffer[i++] = c; } else if (charCount == 2) { diff --git a/ion/src/shared/unicode/utf8_helper.cpp b/ion/src/shared/unicode/utf8_helper.cpp index 9f9537bb1..3fd39e7f3 100644 --- a/ion/src/shared/unicode/utf8_helper.cpp +++ b/ion/src/shared/unicode/utf8_helper.cpp @@ -100,6 +100,7 @@ void CopyAndRemoveCodePoint(char * dst, size_t dstSize, const char * src, CodePo const char * nextPointer = decoder.stringPosition(); size_t bufferIndex = 0; size_t codePointCharSize = UTF8Decoder::CharSizeOfCodePoint(c); + (void)codePointCharSize; // Silence compilation warning about unused variable. // Remove CodePoint c while (codePoint != UCodePointNull && bufferIndex < dstSize) { @@ -122,7 +123,8 @@ void RemoveCodePoint(char * buffer, CodePoint c, const char * * pointerToUpdate, const char * initialPointerToUpdate = *pointerToUpdate; const char * nextPointer = decoder.stringPosition(); size_t bufferIndex = 0; - size_t codePointCharSize = UTF8Decoder::CharSizeOfCodePoint(c); + int codePointCharSize = UTF8Decoder::CharSizeOfCodePoint(c); + (void)codePointCharSize; // Silence compilation warning about unused variable. while (codePoint != UCodePointNull && (stoppingPosition == nullptr || currentPointer < stoppingPosition)) { if (codePoint != c) {