avoid some fixes for noisy signedness warnings

This commit is contained in:
Daniel Marjamäki 2015-10-11 12:36:23 +02:00
parent 0aad8af9ae
commit 40fffddb83
3 changed files with 12 additions and 12 deletions

View File

@ -552,7 +552,7 @@ bool Token::simpleMatch(const Token *tok, const char pattern[])
next = pattern + std::strlen(pattern);
while (*current) {
std::size_t length = static_cast<std::size_t>(next - current);
std::size_t length = next - current;
if (!tok || length != tok->_str.length() || std::strncmp(current, tok->_str.c_str(), length))
return false;
@ -1043,16 +1043,16 @@ std::string Token::stringifyList(bool varid, bool attributes, bool linenumbers,
std::ostringstream ret;
unsigned int lineNumber = _linenr;
int fileInd = files ? -1 : static_cast<int>(_fileIndex);
unsigned int fileInd = files ? ~0U : _fileIndex;
std::map<int, unsigned int> lineNumbers;
for (const Token *tok = this; tok != end; tok = tok->next()) {
bool fileChange = false;
if (static_cast<int>(tok->_fileIndex) != fileInd) {
if (fileInd != -1) {
if (tok->_fileIndex != fileInd) {
if (fileInd != ~0U) {
lineNumbers[fileInd] = tok->_fileIndex;
}
fileInd = static_cast<int>(tok->_fileIndex);
fileInd = tok->_fileIndex;
if (files) {
ret << "\n\n##file ";
if (fileNames && fileNames->size() > tok->_fileIndex)
@ -1066,7 +1066,7 @@ std::string Token::stringifyList(bool varid, bool attributes, bool linenumbers,
}
if (linebreaks && (lineNumber != tok->linenr() || fileChange)) {
if (lineNumber+4 < tok->linenr() && fileInd == static_cast<int>(tok->_fileIndex)) {
if (lineNumber+4 < tok->linenr() && fileInd == tok->_fileIndex) {
ret << '\n' << lineNumber+1 << ":\n|\n";
ret << tok->linenr()-1 << ":\n";
ret << tok->linenr() << ": ";

View File

@ -135,7 +135,7 @@ unsigned int Tokenizer::sizeOfType(const Token *type) const
return 0;
if (type->tokType() == Token::eString)
return static_cast<unsigned int>(Token::getStrLength(type) + 1);
return Token::getStrLength(type) + 1U;
std::map<std::string, unsigned int>::const_iterator it = _typeSize.find(type->str());
if (it == _typeSize.end())
@ -3052,7 +3052,7 @@ bool Tokenizer::simplifySizeof()
Token* tok2 = tok->next();
do {
size *= static_cast<unsigned int>(MathLib::toLongNumber(tok2->strAt(1)));
size *= MathLib::toULongNumber(tok2->strAt(1));
tok2 = tok2->tokAt(3);
} while (Token::Match(tok2, "[ %num% ]"));
if (Token::Match(tok2, "[;=]")) {
@ -3183,7 +3183,7 @@ bool Tokenizer::simplifySizeof()
for (unsigned int i = 0; i < derefs; i++)
tok2 = tok2->linkAt(1); // Skip all dimensions that are derefenced before the sizeof call
while (Token::Match(tok2, "] [ %num% ]")) {
sz *= static_cast<size_t>(MathLib::toULongNumber(tok2->strAt(2)));
sz *= MathLib::toULongNumber(tok2->strAt(2));
tok2 = tok2->linkAt(1);
}
if (Token::simpleMatch(tok2, "] ["))
@ -3195,7 +3195,7 @@ bool Tokenizer::simplifySizeof()
continue;
const Token *tok2 = nametok->next();
while (Token::Match(tok2, "[ %num% ]")) {
sz *= static_cast<size_t>(MathLib::toLongNumber(tok2->strAt(1)));
sz *= MathLib::toULongNumber(tok2->strAt(1));
tok2 = tok2->link()->next();
}
if (!tok2 || tok2->str() != ")")

View File

@ -92,7 +92,7 @@ unsigned int TokenList::appendFileIfNew(const std::string &fileName)
_isCPP = _settings->enforcedLang == Settings::CPP || (_settings->enforcedLang == Settings::None && Path::isCPP(getSourceFilePath()));
}
}
return static_cast<unsigned int>(_files.size() - 1);
return _files.size() - 1U;
}
void TokenList::deleteTokens(Token *tok)
@ -400,7 +400,7 @@ unsigned long long TokenList::calculateChecksum() const
{
unsigned long long checksum = 0;
for (const Token* tok = front(); tok; tok = tok->next()) {
const unsigned int subchecksum1 = tok->flags() + tok->varId() + static_cast<unsigned int>(tok->tokType());
const unsigned int subchecksum1 = tok->flags() + tok->varId() + tok->tokType();
unsigned int subchecksum2 = 0;
for (std::size_t i = 0; i < tok->str().size(); i++)
subchecksum2 += (unsigned int)tok->str()[i];