diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1264eec75..ce62be290 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1059,7 +1059,7 @@ void CheckClass::checkMemset() if (var && arg1->strAt(1) == ",") { if (var->isArrayOrPointer()) { const Token *endTok = var->typeEndToken(); - while (endTok && Token::simpleMatch(endTok, "*")) { + while (Token::simpleMatch(endTok, "*")) { ++numIndirToVariableType; endTok = endTok->previous(); } diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 5a517194f..1a4f7de49 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -239,7 +239,7 @@ static bool inBooleanFunction(const Token *tok) const Function *func = scope->function; if (func) { const Token *ret = func->retDef; - while (ret && Token::Match(ret, "static|const")) + while (Token::Match(ret, "static|const")) ret = ret->next(); return ret && (ret->str() == "bool"); } diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index d4274d9be..a6cde627a 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -980,7 +980,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al const Token *parent = vartok->next()->astParent(); while (Token::Match(parent, "[|.")) parent = parent->astParent(); - if (parent && Token::simpleMatch(parent, "&") && !parent->astOperand2()) + if (Token::simpleMatch(parent, "&") && !parent->astOperand2()) return false; if (parent && Token::Match(parent->previous(), "if|while|switch (")) return true; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 56f34447c..fdb20555a 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3079,7 +3079,7 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope * // skip over qualification if present if (nameTok && nameTok->str() == "::") nameTok = nameTok->next(); - while (nameTok && Token::Match(nameTok, "%type% ::")) + while (Token::Match(nameTok, "%type% ::")) nameTok = nameTok->tokAt(2); if (nameTok && ((type == Scope::eEnum && Token::Match(nameTok, ":|{")) || nameTok->str() != "{")) // anonymous and unnamed structs/unions don't have a name diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6827abae9..7cef883c5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1816,7 +1816,7 @@ void Tokenizer::combineOperators() else if (c1 == '-' && c2 == '>') { // If the preceding sequence is "( & %name% )", replace it by "%name%" Token *t = tok->tokAt(-4); - if (t && Token::Match(t, "( & %name% )")) { + if (Token::Match(t, "( & %name% )")) { t->deleteThis(); t->deleteThis(); t->deleteNext(); @@ -7000,7 +7000,7 @@ bool Tokenizer::simplifyRedundantParentheses() if (Token::Match(tok->previous(), "*|& ( %name% )")) { // We may have a variable declaration looking like "type_name *(var_name)" Token *tok2 = tok->tokAt(-2); - while (tok2 && Token::Match(tok2, "%type%|static|const|extern") && tok2->str() != "operator") { + while (Token::Match(tok2, "%type%|static|const|extern") && tok2->str() != "operator") { tok2 = tok2->previous(); } if (tok2 && !Token::Match(tok2, "[;,{]")) { @@ -8614,10 +8614,10 @@ void Tokenizer::simplifyKeyword() // 2) void f() final; <- function is final if (Token::Match(tok, ") const|override|final")) { Token* specifier = tok->tokAt(2); - while (specifier && Token::Match(specifier, "const|override|final")) { + while (Token::Match(specifier, "const|override|final")) { specifier=specifier->next(); } - if (specifier && Token::Match(specifier, "[{;]")) { + if (Token::Match(specifier, "[{;]")) { specifier = tok->next(); while (!Token::Match(specifier, "[{;]")) { if (specifier->str()=="final")