gcc: fixed -Wconversion errors

This commit is contained in:
Daniel Marjamäki 2010-12-31 09:51:27 +01:00
parent 68b9c6ec94
commit d8f241e033
4 changed files with 9 additions and 9 deletions

View File

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

View File

@ -813,7 +813,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
(varid == 0 && Token::Match(tok, ("strcpy|strcat ( " + varnames + " , %str% )").c_str())))
{
const std::size_t len = Token::getStrLength(tok->tokAt(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)

View File

@ -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<unsigned long>(sz))
{

View File

@ -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<unsigned int>(sz));
tok->next()->insertToken(MathLib::toString<unsigned int>((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;