From 076f7a75420328e39203296b5191d005c39ac56f Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 14 Apr 2014 22:46:51 +0200 Subject: [PATCH] Fixed some coverity findings about dead code, fixed a misleading comment --- lib/checkclass.cpp | 2 +- lib/checkother.cpp | 2 +- lib/checkstl.cpp | 2 +- lib/tokenize.cpp | 4 ---- lib/valueflow.cpp | 3 +-- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 9e73f6a81..26f0abcff 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -792,7 +792,7 @@ void CheckClass::initializationListUsage() tok2->strAt(-1)!=".") { // Is there a dependency between two member variables? allowed = false; break; - } else if (var2 && (var2->isArray() && var2->isLocal())) { // Can't initialize an array + } else if (var2 && (var2->isArray() && var2->isLocal())) { // Can't initialize with a local array allowed = false; break; } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6c553e6e8..ca578ceae 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2058,7 +2058,7 @@ static bool astIsSignedChar(const Token *tok) const Variable *var = tok->astOperand1()->variable(); if (!var || !var->isPointer()) return false; - const Token *type = var ? var->typeStartToken() : nullptr; + const Token *type = var->typeStartToken(); while (type && type->str() == "const") type = type->next(); return (type && type->str() == "char" && !type->isUnsigned()); diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 4acd99060..3f7914b2f 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -1601,7 +1601,7 @@ void CheckStl::readingEmptyStlContainer() if (tok->strAt(-1) == "=") readingEmptyStlContainerError(tok); empty_map.erase(tok->varId()); - } else if ((map && empty_map.find(tok->varId()) != empty_map.end()) || (!map && empty_nonmap.find(tok->varId()) != empty_nonmap.end())) + } else readingEmptyStlContainerError(tok); } else if (Token::Match(tok, "%var% . %type% (")) { // Member function call diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1a543e6f7..7d7590558 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2928,10 +2928,6 @@ bool Tokenizer::simplifySizeof() // We have variable++ or variable--, there should be // nothing after this tempToken = tempToken->tokAt(2); - } else if (parlevel > 0 && Token::simpleMatch(tempToken->next(), ") .")) { - --parlevel; - tempToken = tempToken->tokAt(2); - continue; } // Ok, we should be clean. Add ) after tempToken diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 9942d1281..4de5e6460 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -787,7 +787,7 @@ static bool valueFlowForLoop1(const Token *tok, unsigned int * const varid, Math } if (!num2tok) return false; - *num2 = MathLib::toLongNumber(num2tok ? num2tok->str() : "0") - ((tok->str()=="<=") ? 0 : 1); + *num2 = MathLib::toLongNumber(num2tok->str()) - ((tok->str()=="<=") ? 0 : 1); if (!num1tok) *num1 = *num2; while (tok && tok->str() != ";") @@ -804,7 +804,6 @@ static bool valueFlowForLoop2(const Token *tok, const Token *firstExpression = tok->next()->astOperand2()->astOperand1(); const Token *secondExpression = tok->next()->astOperand2()->astOperand2()->astOperand1(); const Token *thirdExpression = tok->next()->astOperand2()->astOperand2()->astOperand2(); - tok = tok->linkAt(1); std::map programMemory; MathLib::bigint result(0);