From cb06aebdab894c2ca767869889df8e1175aeb379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 12 Apr 2019 06:47:28 +0200 Subject: [PATCH] Removed --std=posix. From now on, if you use --library=posix then the posix checks will be enabled. --- cli/cmdlineparser.cpp | 6 +----- cli/cppcheckexecutor.cpp | 2 +- lib/checkmemoryleak.cpp | 4 ++-- lib/checkother.cpp | 2 +- lib/settings.h | 4 ++++ lib/standards.h | 5 +---- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index dda75d80f..92496aeca 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -593,7 +593,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) // --std else if (std::strcmp(argv[i], "--std=posix") == 0) { - mSettings->standards.posix = true; + printMessage("cppcheck: Option --std=posix is deprecated and will be removed in 1.95."); } else if (std::strcmp(argv[i], "--std=c89") == 0) { mSettings->standards.c = Standards::C89; } else if (std::strcmp(argv[i], "--std=c99") == 0) { @@ -1084,8 +1084,6 @@ void CmdLineParser::printHelp() #endif " --std= Set standard.\n" " The available options are:\n" - " * posix\n" - " POSIX compatible code\n" " * c89\n" " C code is C89 compatible\n" " * c99\n" @@ -1098,8 +1096,6 @@ void CmdLineParser::printHelp() " C++ code is C++11 compatible\n" " * c++14\n" " C++ code is C++14 compatible (default)\n" - " More than one --std can be used:\n" - " 'cppcheck --std=c99 --std=posix file.c'\n" " --suppress= Suppress warnings that match . The format of\n" " is:\n" " [error id]:[filename]:[line]\n" diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index f72e3d09e..95ec505c4 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -823,7 +823,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha } bool posix = true; - if (settings.standards.posix) + if (settings.posix()) posix = tryLoadLibrary(settings.library, argv[0], "posix.cfg"); bool windows = true; if (settings.isWindowsPlatform()) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 7cafe41bb..5fe8aaa8a 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -153,7 +153,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2, return New; } - if (mSettings_->standards.posix) { + if (mSettings_->posix()) { if (Token::Match(tok2, "open|openat|creat|mkstemp|mkostemp|socket (")) { // simple sanity check of function parameters.. // TODO: Make such check for all these functions @@ -255,7 +255,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getDeallocationType(const Token *tok if (tok->str() == "realloc" && Token::simpleMatch(vartok->next(), ", 0 )")) return Malloc; - if (mSettings_->standards.posix) { + if (mSettings_->posix()) { if (tok->str() == "close") return Fd; if (tok->str() == "pclose") diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 53af4fc8d..293b4d1de 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -377,7 +377,7 @@ void CheckOther::invalidPointerCastError(const Token* tok, const std::string& fr //--------------------------------------------------------------------------- void CheckOther::checkPipeParameterSize() { - if (!mSettings->standards.posix) + if (!mSettings->posix()) return; const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); diff --git a/lib/settings.h b/lib/settings.h index d2ffb6031..a26637323 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -176,6 +176,10 @@ public: /** @brief Using -E for debugging purposes */ bool preprocessOnly; + bool posix() const { + return std::find(libraries.begin(), libraries.end(), "posix") != libraries.end(); + } + /** @brief List of include paths, e.g. "my/includes/" which should be used for finding include files inside source files. (-I) */ std::list includePaths; diff --git a/lib/standards.h b/lib/standards.h index b9697c6de..cff6b1ac8 100644 --- a/lib/standards.h +++ b/lib/standards.h @@ -38,11 +38,8 @@ struct Standards { /** C++ code standard */ enum cppstd_t { CPP03, CPP11, CPP14, CPPLatest=CPP14 } cpp; - /** Code is posix */ - bool posix; - /** This constructor clear all the variables **/ - Standards() : c(C11), cpp(CPP14), posix(false) {} + Standards() : c(C11), cpp(CPP14) {} bool setC(const std::string& str) { if (str == "c89" || str == "C89") {