General code tweaking, nothing strange.
This commit is contained in:
parent
0b6e7d7dd2
commit
ba5909ef1d
|
@ -1246,7 +1246,7 @@ void CheckBufferOverrun::checkReadlinkBufferUsage(const Token* tok, const Token
|
|||
void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
||||
{
|
||||
// check all known fixed size arrays first by just looking them up
|
||||
for (size_t i = 1; i <= _tokenizer->varIdCount(); i++) {
|
||||
for (unsigned int i = 1; i <= _tokenizer->varIdCount(); i++) {
|
||||
const Variable *var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(i);
|
||||
if (var && var->isArray() && var->dimension(0) > 0) {
|
||||
ArrayInfo arrayInfo(var, _tokenizer);
|
||||
|
@ -2100,7 +2100,7 @@ void CheckBufferOverrun::executionPaths()
|
|||
{
|
||||
// Parse all variables and extract array info..
|
||||
std::map<unsigned int, ArrayInfo> arrayInfo;
|
||||
for (size_t i = 1; i <= _tokenizer->varIdCount(); i++) {
|
||||
for (unsigned int i = 1; i <= _tokenizer->varIdCount(); i++) {
|
||||
const Variable *var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(i);
|
||||
if (var && var->isArray() && var->dimension(0) > 0)
|
||||
arrayInfo[i] = ArrayInfo(var, _tokenizer);
|
||||
|
|
|
@ -290,7 +290,7 @@ void CheckOther::warningOldStylePointerCast()
|
|||
!Token::Match(tok, "( const| %type% * ) (| new"))
|
||||
continue;
|
||||
|
||||
int addToIndex = 0;
|
||||
unsigned char addToIndex = 0;
|
||||
if (tok->tokAt(1)->str() == "const")
|
||||
addToIndex = 1;
|
||||
|
||||
|
@ -363,7 +363,7 @@ void CheckOther::checkSizeofForArrayParameter()
|
|||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "sizeof ( %var% )") || Token::Match(tok, "sizeof %var%")) {
|
||||
int tokIdx = 1;
|
||||
unsigned short tokIdx = 1;
|
||||
if (tok->tokAt(tokIdx)->str() == "(") {
|
||||
++tokIdx;
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ void CheckOther::checkSizeofForStrncmpSize()
|
|||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, pattern1) || Token::Match(tok, pattern2)) {
|
||||
int tokIdx = 7;
|
||||
unsigned short tokIdx = 7;
|
||||
if (tok->tokAt(tokIdx)->str() == "(")
|
||||
++tokIdx;
|
||||
const Token *tokVar = tok->tokAt(tokIdx);
|
||||
|
@ -1082,7 +1082,7 @@ void CheckOther::invalidFunctionUsage()
|
|||
continue;
|
||||
|
||||
// Locate the third parameter of the function call..
|
||||
int param = 1;
|
||||
unsigned int param = 1;
|
||||
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "(")
|
||||
tok2 = tok2->link();
|
||||
|
@ -1125,14 +1125,14 @@ void CheckOther::invalidFunctionUsage()
|
|||
continue;
|
||||
|
||||
// is any source buffer overlapping the target buffer?
|
||||
int parlevel = 0;
|
||||
unsigned int parlevel = 0;
|
||||
while ((tok2 = tok2->next()) != NULL) {
|
||||
if (tok2->str() == "(")
|
||||
++parlevel;
|
||||
else if (tok2->str() == ")") {
|
||||
--parlevel;
|
||||
if (parlevel < 0)
|
||||
if (!parlevel)
|
||||
break;
|
||||
--parlevel;
|
||||
} else if (parlevel == 0 && Token::Match(tok2, ", %varid% [,)]", varid)) {
|
||||
sprintfOverlappingDataError(tok2->next(), tok2->next()->str());
|
||||
break;
|
||||
|
@ -1410,7 +1410,7 @@ void CheckOther::checkVariableScope()
|
|||
continue;
|
||||
|
||||
// Walk through all tokens..
|
||||
int indentlevel = 0;
|
||||
unsigned int indentlevel = 0;
|
||||
for (const Token *tok = scope->classStart; tok; tok = tok->next()) {
|
||||
// Skip function local class and struct declarations..
|
||||
if ((tok->str() == "class") || (tok->str() == "struct") || (tok->str() == "union")) {
|
||||
|
@ -1430,9 +1430,9 @@ void CheckOther::checkVariableScope()
|
|||
else if (tok->str() == "{") {
|
||||
++indentlevel;
|
||||
} else if (tok->str() == "}") {
|
||||
if (!indentlevel)
|
||||
break;
|
||||
--indentlevel;
|
||||
if (indentlevel == 0)
|
||||
break;;
|
||||
}
|
||||
|
||||
if (indentlevel > 0 && Token::Match(tok, "[{};]")) {
|
||||
|
@ -1477,7 +1477,7 @@ void CheckOther::lookupVar(const Token *tok1, const std::string &varname)
|
|||
// Check if the variable is used in this indentlevel..
|
||||
bool used1 = false; // used in one sub-scope -> reducable
|
||||
bool used2 = false; // used in more sub-scopes -> not reducable
|
||||
int indentlevel = 0;
|
||||
unsigned int indentlevel = 0;
|
||||
int parlevel = 0;
|
||||
bool for_or_while = false; // is sub-scope a "for/while/etc". anything that is not "if"
|
||||
while (tok) {
|
||||
|
@ -1673,15 +1673,15 @@ void CheckOther::checkCharVariable()
|
|||
tok = tok->next();
|
||||
|
||||
// Check usage of char variable..
|
||||
int indentlevel = 0;
|
||||
unsigned int indentlevel = 0;
|
||||
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "{")
|
||||
++indentlevel;
|
||||
|
||||
else if (tok2->str() == "}") {
|
||||
--indentlevel;
|
||||
if (indentlevel <= 0)
|
||||
if (!indentlevel)
|
||||
break;
|
||||
--indentlevel;
|
||||
}
|
||||
|
||||
if (!isPointer) {
|
||||
|
@ -1977,9 +1977,9 @@ void CheckOther::checkMisusedScopedObject()
|
|||
if (tok->str() == "{") {
|
||||
++depth;
|
||||
} else if (tok->str() == "}") {
|
||||
--depth;
|
||||
if (depth == 0)
|
||||
break;
|
||||
--depth;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "[;{}] %var% (")
|
||||
|
|
|
@ -1164,8 +1164,9 @@ void Tokenizer::simplifyTypedef()
|
|||
if (tok->strAt(offset + 1) == "(")
|
||||
++offset;
|
||||
else if (Token::simpleMatch(tok->tokAt(offset), "( * (")) {
|
||||
++offset;
|
||||
pointers.push_back("*");
|
||||
offset += 2;
|
||||
++offset;
|
||||
}
|
||||
|
||||
if (tok->tokAt(offset)->link()->strAt(-2) == "*")
|
||||
|
@ -4041,7 +4042,7 @@ void Tokenizer::simplifySizeof()
|
|||
sz = sizeOfType(tok->tokAt(2));
|
||||
if (sz == 0)
|
||||
continue;
|
||||
sz = sz * static_cast<unsigned long>(MathLib::toLongNumber(tok->strAt(4)));
|
||||
sz = sz * static_cast<unsigned int>(MathLib::toLongNumber(tok->strAt(4)));
|
||||
}
|
||||
|
||||
if (sz > 0) {
|
||||
|
@ -8353,13 +8354,11 @@ void Tokenizer::simplifyComma()
|
|||
if (Token::simpleMatch(tok, "for (") ||
|
||||
Token::Match(tok, "=|enum {")) {
|
||||
tok = tok->next()->link();
|
||||
if (!tok)
|
||||
break;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tok->str() == "(") {
|
||||
if (tok->str() == "(" || tok->str() == "[") {
|
||||
tok = tok->link();
|
||||
continue;
|
||||
}
|
||||
|
@ -8372,7 +8371,7 @@ void Tokenizer::simplifyComma()
|
|||
if (tok2->str() == "<")
|
||||
++comparelevel;
|
||||
else if (tok2->str() == ">") {
|
||||
if (comparelevel <= 1) {
|
||||
if (!comparelevel) {
|
||||
tok = tok2;
|
||||
break;
|
||||
}
|
||||
|
@ -9680,7 +9679,7 @@ void Tokenizer::printUnknownTypes()
|
|||
|
||||
std::set<std::string> unknowns;
|
||||
|
||||
for (size_t i = 1; i <= _varId; ++i) {
|
||||
for (unsigned int i = 1; i <= _varId; ++i) {
|
||||
const Variable *var = _symbolDatabase->getVariableFromVarId(i);
|
||||
|
||||
// is unknown record type?
|
||||
|
|
Loading…
Reference in New Issue