diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index f1dd97aa5..1ec7dbc17 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -110,7 +110,7 @@ int ThreadExecutor::handleRead(unsigned int &result) unsigned int fileResult = 0; iss >> fileResult; result += fileResult; - _errorLogger.reportStatus(_fileCount, _filenames.size()); + _errorLogger.reportStatus(_fileCount, (unsigned int)_filenames.size()); delete [] buf; return -1; } @@ -216,7 +216,7 @@ unsigned int ThreadExecutor::check() void ThreadExecutor::writeToPipe(char type, const std::string &data) { - unsigned int len = data.length() + 1; + std::size_t len = data.length() + 1; char *out = new char[ len + 1 + sizeof(len)]; out[0] = type; std::memcpy(&(out[1]), &len, sizeof(len)); diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index de4ce3bb0..8bb441f97 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -813,7 +813,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vectortokAt(varc + 4)); - if (total_size > 0 && len >= total_size) + if (total_size > 0 && len >= (unsigned int)total_size) { bufferOverrun(tok, varid > 0 ? "" : varnames.c_str()); continue; @@ -1071,7 +1071,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo if (Token::Match(tok, "strcpy|strcat ( %varid% , %str% )", arrayInfo.varid)) { const std::size_t len = Token::getStrLength(tok->tokAt(4)); - if (total_size > 0 && len >= total_size) + if (total_size > 0 && len >= (unsigned int)total_size) { bufferOverrun(tok, arrayInfo.varname); continue; @@ -1087,7 +1087,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo while (tok2 && Token::Match(tok2, "strcat ( %varid% , %str% ) ;", arrayInfo.varid)) { charactersAppend += Token::getStrLength(tok2->tokAt(4)); - if (charactersAppend >= total_size) + if (charactersAppend >= (unsigned int)total_size) { bufferOverrun(tok2, arrayInfo.varname); break; @@ -1542,7 +1542,7 @@ MathLib::bigint CheckBufferOverrun::countSprintfLength(const std::string &input_ } } - return input_string_size; + return (MathLib::bigint)input_string_size; } void CheckBufferOverrun::checkSprintfCall(const Token *tok, const MathLib::bigint size) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 58f43decb..734300a4e 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -625,7 +625,7 @@ private: { if (Token::Match(tok.tokAt(6), "%num% )")) { - const unsigned int len = Token::getStrLength(tok.tokAt(4)); + const std::size_t len = Token::getStrLength(tok.tokAt(4)); const MathLib::bigint sz = MathLib::toLongNumber(tok.strAt(6)); if (sz >= 0 && len >= static_cast(sz)) { diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c60219743..925f1d26a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2324,7 +2324,7 @@ void Tokenizer::arraySize() else if (Token::Match(tok, "%var% [ ] = %str% ;")) { std::size_t sz = tok->strAt(4).length() - 1; - tok->next()->insertToken(MathLib::toString(sz)); + tok->next()->insertToken(MathLib::toString((unsigned int)sz)); } } } @@ -8125,7 +8125,7 @@ std::string Tokenizer::simplifyString(const std::string &source) // We will replace all other character as 'a' // If that causes problems in the future, this can // be improved. But for now, this should be OK. - unsigned char n = 1; + unsigned int n = 1; while (n < 2 && std::isxdigit(str[i+1+n])) ++n; --i;