Skip to content

Commit

Permalink
Fix up extra whitespaces in match patterns
Browse files Browse the repository at this point in the history
Detected by new internal check.
thomasjfox committed Dec 30, 2014
1 parent 17b47f1 commit 69b31a0
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
@@ -925,7 +925,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
const Token *tok2 = tok->next()->link()->next();
for (; tok2; tok2 = tok2->next()) {
if (tok2->varId() == tok->tokAt(2)->varId()) {
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId())) {
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId())) {
terminateStrncpyError(tok, tok->strAt(2));
}

2 changes: 1 addition & 1 deletion lib/checkmemoryleak.cpp
Original file line number Diff line number Diff line change
@@ -2531,7 +2531,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable * const var

// Struct member is allocated => check if it is also properly deallocated..
else if (Token::Match(tok2->previous(), "[;{}] %varid% . %var% = malloc|strdup|kmalloc (", variable->declarationId())
|| Token::Match(tok2->previous(), "[;{}] %varid% . %var% = new ", variable->declarationId())
|| Token::Match(tok2->previous(), "[;{}] %varid% . %var% = new", variable->declarationId())
|| Token::Match(tok2->previous(), "[;{}] %varid% . %var% = fopen (", variable->declarationId())) {
const unsigned int structid(variable->declarationId());
const unsigned int structmemberid(tok2->tokAt(2)->varId());
4 changes: 2 additions & 2 deletions lib/checkstl.cpp
Original file line number Diff line number Diff line change
@@ -1327,8 +1327,8 @@ void CheckStl::checkAutoPointer()
autoPointerError(tok->tokAt(2));
}
}
} else if ((Token::Match(tok, "%var% = new %type% ") && hasArrayEnd(tok)) ||
(Token::Match(tok, "%var% . reset ( new %type% ") && hasArrayEndParen(tok))) {
} else if ((Token::Match(tok, "%var% = new %type%") && hasArrayEnd(tok)) ||
(Token::Match(tok, "%var% . reset ( new %type%") && hasArrayEndParen(tok))) {
std::set<unsigned int>::const_iterator iter = autoPtrVarId.find(tok->varId());
if (iter != autoPtrVarId.end()) {
autoPointerArrayError(tok);
2 changes: 1 addition & 1 deletion lib/checkstring.cpp
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ void CheckString::checkAlwaysTrueOrFalseStringCompare()
if (str1 == str2)
alwaysTrueStringVariableCompareError(tok, str1, str2);
tok = tok->tokAt(5);
} else if (Token::Match(tok->tokAt(2), "%var% . c_str ( ) , %var% . c_str ( )")) {
} else if (Token::Match(tok->tokAt(2), "%var% . c_str ( ) , %var% . c_str ( )")) {
const std::string &str1 = tok->strAt(2);
const std::string &str2 = tok->strAt(8);
if (str1 == str2)
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
@@ -1362,7 +1362,7 @@ void Variable::evaluate()
// type var = {x}
// type var = x; gets simplified to: type var ; var = x ;
Token const * declEnd = declEndToken();
if ((Token::Match(declEnd, "; %var% = ") && declEnd->strAt(1) == _name->str()) ||
if ((Token::Match(declEnd, "; %var% =") && declEnd->strAt(1) == _name->str()) ||
Token::Match(declEnd, "=|{"))
setFlag(fHasDefault, true);
}
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
@@ -2500,7 +2500,7 @@ static void setVarIdClassFunction(const std::string &classname,
continue;
if (Token::Match(tok2->tokAt(-4), "%var% :: %var% ::")) // Currently unsupported
continue;
if (Token::Match(tok2->tokAt(-2), "!!this . "))
if (Token::Match(tok2->tokAt(-2), "!!this ."))
continue;

const std::map<std::string,unsigned int>::const_iterator it = varlist.find(tok2->str());

0 comments on commit 69b31a0

Please sign in to comment.