From 3cd2f2d0927425f076b0b34253711745fa58f467 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Thu, 1 Jun 2017 01:49:40 +0300 Subject: [PATCH] Don't cast bool to bool --- lib/checkautovariables.cpp | 2 +- lib/checkuninitvar.cpp | 2 +- lib/path.cpp | 8 ++++---- lib/symboldatabase.h | 4 ++-- lib/token.h | 2 +- lib/tokenize.cpp | 2 +- test/testclass.cpp | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index c98326824..2d9392d11 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -396,7 +396,7 @@ bool CheckAutoVariables::returnTemporary(const Token *tok) if (!func && tok->type()) return true; - return bool(!retref && retvalue); + return (!retref && retvalue); } //--------------------------------------------------------------------------- diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index f55513ec0..8fe6a8207 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -651,7 +651,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var tok = tok->next(); } - return bool(noreturn==nullptr); + return (noreturn == nullptr); } // variable is seen.. diff --git a/lib/path.cpp b/lib/path.cpp index db779b318..57aaf8ba2 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -146,13 +146,13 @@ std::string Path::getPathFromFilename(const std::string &filename) bool Path::sameFileName(const std::string &fname1, const std::string &fname2) { #if defined(__linux__) || defined(__sun) || defined(__hpux) - return bool(fname1 == fname2); + return (fname1 == fname2); #elif defined(_MSC_VER) || (defined(__GNUC__) && defined(_WIN32)) - return bool(_stricmp(fname1.c_str(), fname2.c_str()) == 0); + return (_stricmp(fname1.c_str(), fname2.c_str()) == 0); #elif defined(__GNUC__) - return bool(strcasecmp(fname1.c_str(), fname2.c_str()) == 0); + return (strcasecmp(fname1.c_str(), fname2.c_str()) == 0); #elif defined(__BORLANDC__) - return bool(stricmp(fname1.c_str(), fname2.c_str()) == 0); + return (stricmp(fname1.c_str(), fname2.c_str()) == 0); #else #error Platform filename compare function needed #endif diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index df4d928fb..37ae27f05 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -185,7 +185,7 @@ class CPPCHECKLIB Variable { * @return true if flag set or false in flag not set */ bool getFlag(unsigned int flag_) const { - return bool((_flags & flag_) != 0); + return ((_flags & flag_) != 0); } /** @@ -656,7 +656,7 @@ class CPPCHECKLIB Function { * @return true if flag set or false in flag not set */ bool getFlag(unsigned int flag) const { - return bool((flags & flag) != 0); + return ((flags & flag) != 0); } /** diff --git a/lib/token.h b/lib/token.h index a3491fe40..66c9161ca 100644 --- a/lib/token.h +++ b/lib/token.h @@ -893,7 +893,7 @@ private: * @return true if flag set or false in flag not set */ bool getFlag(unsigned int flag_) const { - return bool((_flags & flag_) != 0); + return ((_flags & flag_) != 0); } /** diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 14b48f2e9..953eaaa0e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2369,7 +2369,7 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map= 2 && tok2 && Token::Match(tok2->tokAt(-2), "!!:: %type%")); + return (typeCount >= 2 && tok2 && Token::Match(tok2->tokAt(-2), "!!:: %type%")); } diff --git a/test/testclass.cpp b/test/testclass.cpp index 9a6a2647f..8af201a47 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -4436,7 +4436,7 @@ private: " x = 0;\n" " }\n" " bool isValid() {\n" - " return bool(x == 0x11224488);\n" + " return (x == 0x11224488);\n" " }\n" "};"); ASSERT_EQUALS("[test.cpp:9]: (style, inconclusive) Technically the member function 'Fred::isValid' can be const.\n", errout.str());