Fix CheckInternal warnings (#1790)
This commit is contained in:
parent
295153df72
commit
d23e987941
|
@ -693,7 +693,7 @@ void CheckBufferOverrun::stringNotZeroTerminated()
|
|||
// Is the buffer zero terminated after the call?
|
||||
bool isZeroTerminated = false;
|
||||
for (const Token *tok2 = tok->next()->link(); tok2 != scope->bodyEnd; tok2 = tok2->next()) {
|
||||
if (!Token::Match(tok2, "] ="))
|
||||
if (!Token::simpleMatch(tok2, "] ="))
|
||||
continue;
|
||||
const Token *rhs = tok2->next()->astOperand2();
|
||||
if (!rhs || !rhs->hasKnownIntValue() || rhs->getKnownIntValue() != 0)
|
||||
|
|
|
@ -1060,12 +1060,12 @@ void CheckMemoryLeakNoVar::checkForUnsafeArgAlloc(const Scope *scope)
|
|||
const Function *func = tok2->function();
|
||||
const bool isNothrow = func && (func->isAttributeNothrow() || func->isThrow());
|
||||
|
||||
if (Token::Match(tok2, "shared_ptr|unique_ptr <") && tok2->next()->link() && Token::Match(tok2->next()->link(), "> ( new %name%")) {
|
||||
if (Token::Match(tok2, "shared_ptr|unique_ptr <") && Token::Match(tok2->next()->link(), "> ( new %name%")) {
|
||||
pointerType = tok2;
|
||||
} else if (!isNothrow) {
|
||||
if (Token::Match(tok2, "%name% ("))
|
||||
functionCalled = tok2;
|
||||
else if (tok2->isName() && tok2->next()->link() && Token::simpleMatch(tok2->next()->link(), "> ("))
|
||||
else if (tok2->isName() && Token::simpleMatch(tok2->next()->link(), "> ("))
|
||||
functionCalled = tok2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -873,7 +873,7 @@ void CheckOther::checkVariableScope()
|
|||
const Variable *otherVar = otherVarToken->variable();
|
||||
if (otherVar && Token::Match(otherVar->nameToken(), "%var% :") &&
|
||||
otherVar->nameToken()->next()->astParent() &&
|
||||
Token::Match(otherVar->nameToken()->next()->astParent()->previous(), "for ("))
|
||||
Token::simpleMatch(otherVar->nameToken()->next()->astParent()->previous(), "for ("))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -9022,7 +9022,7 @@ void Tokenizer::findGarbageCode() const
|
|||
// Assign/increment/decrement literal
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "!!) %num%|%str%|%char% %assign%|++|--"))
|
||||
syntaxError(tok, tok->next()->str() + " " + tok->tokAt(2)->str());
|
||||
syntaxError(tok, tok->next()->str() + " " + tok->strAt(2));
|
||||
}
|
||||
|
||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -884,7 +884,7 @@ static Token * valueFlowSetConstantValue(const Token *tok, const Settings *setti
|
|||
else
|
||||
tok2 = tok2->tokAt(2);
|
||||
}
|
||||
if (Token::Match(tok, "sizeof ( *")) {
|
||||
if (Token::simpleMatch(tok, "sizeof ( *")) {
|
||||
const ValueType *vt = tok->tokAt(2)->valueType();
|
||||
const size_t sz = vt ? getSizeOf(*vt, settings) : 0;
|
||||
if (sz > 0) {
|
||||
|
|
Loading…
Reference in New Issue