Merge pull request #474 from Dmitry-Me/reorderChecks

Reorder checks to avoid redundant actions
This commit is contained in:
amai2012 2014-11-30 20:20:08 +01:00
commit 02298bf4d9
1 changed files with 4 additions and 2 deletions

View File

@ -445,10 +445,12 @@ void CheckOther::invalidPointerCast()
nextTok = nextTok->next();
toTok = tok->tokAt(2);
}
if (!nextTok)
continue;
if (toTok && toTok->str() == "const")
toTok = toTok->next();
if (!nextTok || !toTok || !toTok->isStandardType())
if (!toTok || !toTok->isStandardType())
continue;
// Find casted variable
@ -649,7 +651,7 @@ void CheckOther::checkRedundantAssignment()
}
}
if (error) {
if (scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok) && warning)
if (warning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
redundantAssignmentInSwitchError(it->second, tok, tok->str());
else if (performance) {
const bool nonlocal = nonLocal(it->second->variable());