From 662745b504302a9901da9b74a6a79ec790f1ea9c Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 20 May 2020 18:03:03 +0200 Subject: [PATCH] Fixed several coverity messages --- lib/preprocessor.cpp | 2 +- lib/token.cpp | 2 +- lib/tokenize.cpp | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 6cbf84cef..20097f8bc 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -130,7 +130,7 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std: static void inlineSuppressions(const simplecpp::TokenList &tokens, Settings &mSettings, std::list *bad) { - for (const simplecpp::Token *tok = tokens.cfront(); tok; tok = tok ? tok->next : nullptr) { + for (const simplecpp::Token *tok = tokens.cfront(); tok; tok = tok->next) { if (!tok->comment) continue; diff --git a/lib/token.cpp b/lib/token.cpp index 6d051e49e..16f860a83 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -1031,7 +1031,7 @@ void Token::insertToken(const std::string &tokenStr, const std::string &original Token *tok1 = newToken; while (Token::Match(tok1->previous(), "const|volatile|final|override|&|&&|noexcept")) tok1 = tok1->previous(); - if (tok1 && tok1->previous() && tok1->strAt(-1) == ")") { + if (tok1->previous() && tok1->strAt(-1) == ")") { tok1 = tok1->linkAt(-1); if (Token::Match(tok1->previous(), "throw|noexcept")) { tok1 = tok1->previous(); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 613b0ef34..2eac17be7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1707,7 +1707,7 @@ namespace { Token *tok1 = tok; while (Token::Match(tok1->previous(), "const|volatile|final|override|&|&&|noexcept")) tok1 = tok1->previous(); - if (tok1 && tok1->previous() && tok1->strAt(-1) == ")") { + if (tok1->previous() && tok1->strAt(-1) == ")") { tok1 = tok1->linkAt(-1); if (Token::Match(tok1->previous(), "throw|noexcept")) { tok1 = tok1->previous(); @@ -2906,7 +2906,7 @@ void Tokenizer::calculateScopes() Token *tok1 = tok; while (Token::Match(tok1->previous(), "const|volatile|final|override|&|&&|noexcept")) tok1 = tok1->previous(); - if (tok1 && tok1->previous() && tok1->strAt(-1) == ")") { + if (tok1->previous() && tok1->strAt(-1) == ")") { bool member = true; tok1 = tok1->linkAt(-1); if (Token::Match(tok1->previous(), "throw|noexcept")) { @@ -7224,12 +7224,7 @@ bool Tokenizer::simplifyKnownVariables() std::unordered_map constantValues; std::map constantVars; std::unordered_map> constantValueUsages; - bool goback = false; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (goback) { - tok = tok->previous(); - goback = false; - } // Reference to variable if (Token::Match(tok, "%type%|* & %name% = %name% ;")) { Token *start = tok->previous();