Skip to content

Commit c0d2933

Browse files
committed
Reorder checks to avoid redundant actions
1 parent 6482fef commit c0d2933

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/checkother.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,12 @@ void CheckOther::invalidPointerCast()
445445
nextTok = nextTok->next();
446446
toTok = tok->tokAt(2);
447447
}
448+
if (!nextTok)
449+
continue;
448450
if (toTok && toTok->str() == "const")
449451
toTok = toTok->next();
450452

451-
if (!nextTok || !toTok || !toTok->isStandardType())
453+
if (!toTok || !toTok->isStandardType())
452454
continue;
453455

454456
// Find casted variable
@@ -649,7 +651,7 @@ void CheckOther::checkRedundantAssignment()
649651
}
650652
}
651653
if (error) {
652-
if (scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok) && warning)
654+
if (warning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok))
653655
redundantAssignmentInSwitchError(it->second, tok, tok->str());
654656
else if (performance) {
655657
const bool nonlocal = nonLocal(it->second->variable());

0 commit comments

Comments
 (0)