klocwork fixes; remove redundant nullpointer checks

This commit is contained in:
Daniel Marjamäki 2021-10-28 08:58:16 +02:00
parent eeaf2e5ff0
commit d90ee9bfb9
1 changed files with 2 additions and 2 deletions

View File

@ -1644,7 +1644,7 @@ void CheckStl::size()
const Token* const end = varTok->tokAt(5); const Token* const end = varTok->tokAt(5);
// check for comparison to zero // check for comparison to zero
if ((tok->previous() && !tok->previous()->isArithmeticalOp() && Token::Match(end, "==|<=|!=|> 0")) || if ((!tok->previous()->isArithmeticalOp() && Token::Match(end, "==|<=|!=|> 0")) ||
(end->next() && !end->next()->isArithmeticalOp() && Token::Match(tok->tokAt(-2), "0 ==|>=|!=|<"))) { (end->next() && !end->next()->isArithmeticalOp() && Token::Match(tok->tokAt(-2), "0 ==|>=|!=|<"))) {
if (isCpp03ContainerSizeSlow(varTok)) { if (isCpp03ContainerSizeSlow(varTok)) {
sizeError(varTok); sizeError(varTok);
@ -1653,7 +1653,7 @@ void CheckStl::size()
} }
// check for comparison to one // check for comparison to one
if ((tok->previous() && !tok->previous()->isArithmeticalOp() && Token::Match(end, ">=|< 1") && !end->tokAt(2)->isArithmeticalOp()) || if ((!tok->previous()->isArithmeticalOp() && Token::Match(end, ">=|< 1") && !end->tokAt(2)->isArithmeticalOp()) ||
(end->next() && !end->next()->isArithmeticalOp() && Token::Match(tok->tokAt(-2), "1 <=|>") && !tok->tokAt(-3)->isArithmeticalOp())) { (end->next() && !end->next()->isArithmeticalOp() && Token::Match(tok->tokAt(-2), "1 <=|>") && !tok->tokAt(-3)->isArithmeticalOp())) {
if (isCpp03ContainerSizeSlow(varTok)) if (isCpp03ContainerSizeSlow(varTok))
sizeError(varTok); sizeError(varTok);