Clean some warnings

This commit is contained in:
Émilie Feral
2019-07-09 15:50:14 +02:00
parent 15322cac21
commit 2861a35840
6 changed files with 8 additions and 6 deletions

View File

@@ -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<char *>(UTF8Helper::CodePointSearch(buffer, '('));
if (!UTF8Helper::CodePointIs(firstParenthesis, '(')) {
return numberOfChars;

View File

@@ -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);

View File

@@ -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++;

View File

@@ -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(' ');

View File

@@ -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) {

View File

@@ -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) {