Removed --std=posix. From now on, if you use --library=posix then the posix checks will be enabled.

This commit is contained in:
Daniel Marjamäki 2019-04-12 06:47:28 +02:00
parent dfe417c369
commit cb06aebdab
6 changed files with 10 additions and 13 deletions

View File

@ -593,7 +593,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
// --std // --std
else if (std::strcmp(argv[i], "--std=posix") == 0) { 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) { } else if (std::strcmp(argv[i], "--std=c89") == 0) {
mSettings->standards.c = Standards::C89; mSettings->standards.c = Standards::C89;
} else if (std::strcmp(argv[i], "--std=c99") == 0) { } else if (std::strcmp(argv[i], "--std=c99") == 0) {
@ -1084,8 +1084,6 @@ void CmdLineParser::printHelp()
#endif #endif
" --std=<id> Set standard.\n" " --std=<id> Set standard.\n"
" The available options are:\n" " The available options are:\n"
" * posix\n"
" POSIX compatible code\n"
" * c89\n" " * c89\n"
" C code is C89 compatible\n" " C code is C89 compatible\n"
" * c99\n" " * c99\n"
@ -1098,8 +1096,6 @@ void CmdLineParser::printHelp()
" C++ code is C++11 compatible\n" " C++ code is C++11 compatible\n"
" * c++14\n" " * c++14\n"
" C++ code is C++14 compatible (default)\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=<spec> Suppress warnings that match <spec>. The format of\n" " --suppress=<spec> Suppress warnings that match <spec>. The format of\n"
" <spec> is:\n" " <spec> is:\n"
" [error id]:[filename]:[line]\n" " [error id]:[filename]:[line]\n"

View File

@ -823,7 +823,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
} }
bool posix = true; bool posix = true;
if (settings.standards.posix) if (settings.posix())
posix = tryLoadLibrary(settings.library, argv[0], "posix.cfg"); posix = tryLoadLibrary(settings.library, argv[0], "posix.cfg");
bool windows = true; bool windows = true;
if (settings.isWindowsPlatform()) if (settings.isWindowsPlatform())

View File

@ -153,7 +153,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2,
return New; return New;
} }
if (mSettings_->standards.posix) { if (mSettings_->posix()) {
if (Token::Match(tok2, "open|openat|creat|mkstemp|mkostemp|socket (")) { if (Token::Match(tok2, "open|openat|creat|mkstemp|mkostemp|socket (")) {
// simple sanity check of function parameters.. // simple sanity check of function parameters..
// TODO: Make such check for all these functions // 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 )")) if (tok->str() == "realloc" && Token::simpleMatch(vartok->next(), ", 0 )"))
return Malloc; return Malloc;
if (mSettings_->standards.posix) { if (mSettings_->posix()) {
if (tok->str() == "close") if (tok->str() == "close")
return Fd; return Fd;
if (tok->str() == "pclose") if (tok->str() == "pclose")

View File

@ -377,7 +377,7 @@ void CheckOther::invalidPointerCastError(const Token* tok, const std::string& fr
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void CheckOther::checkPipeParameterSize() void CheckOther::checkPipeParameterSize()
{ {
if (!mSettings->standards.posix) if (!mSettings->posix())
return; return;
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();

View File

@ -176,6 +176,10 @@ public:
/** @brief Using -E for debugging purposes */ /** @brief Using -E for debugging purposes */
bool preprocessOnly; 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 /** @brief List of include paths, e.g. "my/includes/" which should be used
for finding include files inside source files. (-I) */ for finding include files inside source files. (-I) */
std::list<std::string> includePaths; std::list<std::string> includePaths;

View File

@ -38,11 +38,8 @@ struct Standards {
/** C++ code standard */ /** C++ code standard */
enum cppstd_t { CPP03, CPP11, CPP14, CPPLatest=CPP14 } cpp; enum cppstd_t { CPP03, CPP11, CPP14, CPPLatest=CPP14 } cpp;
/** Code is posix */
bool posix;
/** This constructor clear all the variables **/ /** This constructor clear all the variables **/
Standards() : c(C11), cpp(CPP14), posix(false) {} Standards() : c(C11), cpp(CPP14) {}
bool setC(const std::string& str) { bool setC(const std::string& str) {
if (str == "c89" || str == "C89") { if (str == "c89" || str == "C89") {