diff --git a/lib/astutils.cpp b/lib/astutils.cpp index a705c438b..bebb1227b 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -404,7 +404,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, const Settings *settings, return false; // address of variable - const bool addressOf = tok && Token::simpleMatch(tok->previous(), "&"); + const bool addressOf = Token::simpleMatch(tok->previous(), "&"); // passing variable to subfunction? if (Token::Match(tok->tokAt(-2), ") & %name% [,)]") && Token::Match(tok->linkAt(-2)->previous(), "[,(] (")) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index e55a2f176..481bdf5b6 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -706,7 +706,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector 0 && Token::Match(tok, "%name% ( !!)")) { + if (declarationId == 0 && Token::Match(tok, "%name% ( !!)")) { std::list callstack; callstack.push_back(tok); const Token* tok2 = tok->tokAt(2); diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index e4555622b..1e02633e9 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -1010,14 +1010,14 @@ void CheckCondition::checkIncorrectLogicOperator() incorrectLogicOperatorError(tok, text, alwaysTrue, inconclusive); } else if (printStyle && secondTrue) { const std::string text = "If '" + cond1str + "', the comparison '" + cond2str + - "' is always " + (secondTrue ? "true" : "false") + "."; + "' is always true."; redundantConditionError(tok, text, inconclusive); } else if (printStyle && firstTrue) { //const std::string text = "The comparison " + cond1str + " is always " + // (firstTrue ? "true" : "false") + " when " + // cond2str + "."; const std::string text = "If '" + cond2str + "', the comparison '" + cond1str + - "' is always " + (firstTrue ? "true" : "false") + "."; + "' is always true."; redundantConditionError(tok, text, inconclusive); } } diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 10c1154e8..52a57d3b2 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1033,7 +1033,7 @@ void CheckIO::checkFormatString(const Token * const tok, break; } } - } else if (!scan && printWarning) { + } else if (printWarning) { std::string specifier; bool done = false; while (!done) { diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index fa541d0b6..8b91a7d4d 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -392,7 +392,7 @@ void CheckNullPointer::nullConstantDereference() const Token *tok = scope->classStart; - if (scope->function && scope->function->isConstructor()) + if (scope->function->isConstructor()) tok = scope->function->token; // Check initialization list for (; tok != scope->classEnd; tok = tok->next()) { diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 10a2990bf..b6b6cb2d5 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -265,7 +265,7 @@ void CheckStl::iterators() // bailout handling. Assume that the iterator becomes valid if we see else. // TODO: better handling - else if (tok2 && tok2->str() == "else") { + else if (tok2->str() == "else") { validIterator = true; } } diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 0e2016df5..6d117e964 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3973,7 +3973,6 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const // check each function against the arguments in the function call for a match for (std::size_t i = 0; i < matches.size();) { - bool erased = false; bool constFallback = false; const Function * func = matches[i]; size_t same = 0; @@ -3987,8 +3986,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const // check if isConst mismatches if (scope->function->isConst() != func->isConst()) { if (scope->function->isConst()) { - if (!erased) - ++i; + ++i; continue; } constFallback = true; @@ -3998,6 +3996,7 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const size_t fallback1 = 0; size_t fallback2 = 0; + bool erased = false; for (std::size_t j = 0; j < args; ++j) { // don't check variadic arguments diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 564a72725..bde722b91 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9437,7 +9437,7 @@ void Tokenizer::simplifyOperatorName() bool done = false; while (!done && par) { done = true; - if (par && par->isName()) { + if (par->isName()) { op += par->str(); par = par->next(); // merge namespaces eg. 'operator std :: string () const {'