From eeaf2e5ff0672f3222c169ec1681a6e0e69ddac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 28 Oct 2021 08:55:08 +0200 Subject: [PATCH] klocwork fixes; check that astSibling for comparison op does not return nullptr. remove check that pointer is non-null, the check should be redundant. --- lib/checkstl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index e1b86f394..914f766fe 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1352,7 +1352,7 @@ static bool if_findCompare(const Token * const tokBack, bool stdStringLike) if (tok->isComparisonOp()) { if (stdStringLike) { const Token * const tokOther = tokBack->astSibling(); - return !tokOther->hasKnownIntValue() || tokOther->getKnownIntValue() != 0; + return !tokOther || !tokOther->hasKnownIntValue() || tokOther->getKnownIntValue() != 0; } return (!tok->astOperand1()->isNumber() && !tok->astOperand2()->isNumber()); } @@ -1379,7 +1379,7 @@ void CheckStl::if_find() continue; const Token *conditionStart = scope.classDef->next(); - if (conditionStart && Token::simpleMatch(conditionStart->astOperand2(), ";")) + if (Token::simpleMatch(conditionStart->astOperand2(), ";")) conditionStart = conditionStart->astOperand2(); for (const Token *tok = conditionStart; tok->str() != "{"; tok = tok->next()) {