diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 3038e88f7..e2ab8083e 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -460,13 +460,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) } } - // Posix compliant code checks - else if (strcmp(argv[i], "--posix") == 0) - { - _settings->_posix = true; - } - - // deprecated: auto deallocated classes.. else if (strcmp(argv[i], "--auto-dealloc") == 0) { @@ -662,6 +655,9 @@ void CmdLineParser::PrintHelp() " * missingInclude\n" " Warn if there are missing includes.\n" " For detailed information use --check-config\n" + " * posix\n" + " Enable checks specific for POSIX-compiliant\n" + " code.\n" " Several ids can be given if you separate them with\n" " commas.\n" " --error-exitcode= If errors are found, integer [n] is returned instead\n" @@ -689,7 +685,6 @@ void CmdLineParser::PrintHelp() " more comments, like: // cppcheck-suppress warningId\n" " on the lines before the warning to suppress.\n" " -j Start [jobs] threads to do the checking simultaneously.\n" - " --posix Enable checks applicable only to Posix compliant code.\n" " -q, --quiet Only print error messages.\n" " --report-progress Report progress messages while checking a file.\n" #ifdef HAVE_RULES diff --git a/lib/checknonreentrantfunctions.cpp b/lib/checknonreentrantfunctions.cpp index 7acd88c75..0b83e5395 100644 --- a/lib/checknonreentrantfunctions.cpp +++ b/lib/checknonreentrantfunctions.cpp @@ -33,7 +33,7 @@ CheckNonReentrantFunctions instance; void CheckNonReentrantFunctions::nonReentrantFunctions() { - if (!_settings->_posix || !_settings->_checkCodingStyle) + if (!_settings->isEnabled("posix") || !_settings->_checkCodingStyle) return; // Don't check C# and Java code diff --git a/lib/settings.cpp b/lib/settings.cpp index d14a24eba..93c1fcc6f 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -36,7 +36,6 @@ Settings::Settings() _inlineSuppressions = false; _verbose = false; _force = false; - _posix = false; _xml = false; _xml_version = 1; _jobs = 1; @@ -399,6 +398,7 @@ std::string Settings::addEnabled(const std::string &str) id.insert("missingInclude"); id.insert("unusedFunction"); id.insert("information"); + id.insert("posix"); if (str == "all") { diff --git a/lib/settings.h b/lib/settings.h index cf137895f..0ad9426cc 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -96,9 +96,6 @@ public: /** @brief write XML results (--xml) */ bool _xml; - /** @brief check posix functions (--posix) */ - bool _posix; - /** @brief XML version (--xmlver=..) */ int _xml_version; diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 25eef78ae..f3f5174c1 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -62,6 +62,7 @@ private: TEST_CASE(enabledStyle); TEST_CASE(enabledUnusedFunction); TEST_CASE(enabledMissingInclude); + TEST_CASE(enablePosix); TEST_CASE(errorExitcode); TEST_CASE(errorExitcodeMissing); TEST_CASE(errorExitcodeStr); @@ -100,7 +101,6 @@ private: TEST_CASE(ignorefilepaths1); TEST_CASE(ignorefilepaths2); TEST_CASE(checkconfig); - TEST_CASE(posix); TEST_CASE(unknownParam); } @@ -421,6 +421,16 @@ private: ASSERT(settings.isEnabled("missingInclude")); } + void enablePosix() + { + REDIRECT; + const char *argv[] = {"cppcheck", "--enable=posix", "file.cpp"}; + Settings settings; + CmdLineParser parser(&settings); + ASSERT(parser.ParseFromArgs(3, argv)); + ASSERT(settings.isEnabled("posix")); + } + void errorExitcode() { REDIRECT; @@ -813,16 +823,6 @@ private: ASSERT_EQUALS(true, settings.checkConfiguration); } - void posix() - { - REDIRECT; - const char *argv[] = {"cppcheck", "--posix", "file.cpp"}; - Settings settings; - CmdLineParser parser(&settings); - ASSERT(parser.ParseFromArgs(3, argv)); - ASSERT_EQUALS(true, settings._posix); - } - void unknownParam() { REDIRECT; diff --git a/test/testnonreentrantfunctions.cpp b/test/testnonreentrantfunctions.cpp index 70b508cb0..67ba2d6fa 100644 --- a/test/testnonreentrantfunctions.cpp +++ b/test/testnonreentrantfunctions.cpp @@ -45,7 +45,7 @@ private: errout.str(""); Settings settings; - settings._posix = true; + settings.addEnabled("posix"); settings.inconclusive = true; settings._checkCodingStyle = true;