Skip to content

Commit 7142edf

Browse files
committed
Improved fix for Cppcheck warning. Remove useless conditions instead of adding a new one.
1 parent 605fb90 commit 7142edf

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/executionpath.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,13 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
366366
}
367367

368368
// ; { ... }
369-
if (tok && Token::Match(tok->previous(), "[;{}:] {")) {
369+
if (Token::Match(tok->previous(), "[;{}:] {")) {
370370
ExecutionPath::checkScope(tok->next(), checks);
371371
tok = tok->link();
372372
continue;
373373
}
374374

375-
if (tok && tok->str() == "if" && tok->next() && tok->next()->str() == "(") {
375+
if (tok->str() == "if" && tok->next() && tok->next()->str() == "(") {
376376
// what variable ids should the numberOfIf be counted for?
377377
std::set<unsigned int> countif;
378378

@@ -449,15 +449,9 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
449449
}
450450
}
451451

452-
453-
if (tok) {
454-
tok = check->parse(*tok, checks);
455-
if (checks.empty())
456-
return;
457-
}
458-
459-
if (!tok)
460-
break;
452+
tok = check->parse(*tok, checks);
453+
if (!tok || checks.empty())
454+
return;
461455

462456
// return/throw ends all execution paths
463457
if (tok->str() == "return" ||

0 commit comments

Comments
 (0)