diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 56d2cfbca..9ef4d5a6a 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1833,7 +1833,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, } }; -#ifdef VERIFY_INTEGEROVERFLOW +#ifdef BUG_HUNTING_INTEGEROVERFLOW std::function integerOverflow = [&](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { if (!tok->isArithmeticalOp() || !tok->valueType() || !tok->valueType()->isIntegral() || tok->valueType()->pointer > 0) return; @@ -1882,6 +1882,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, }; #endif +#ifdef BUG_HUNTING_UNINIT std::function uninit = [=](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { if (!tok->astParent()) return; @@ -1945,6 +1946,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, "verificationUninit", "Cannot determine that '" + tok->expressionString() + "' is initialized", CWE_USE_OF_UNINITIALIZED_VARIABLE, false); errorLogger->reportErr(errmsg); }; +#endif std::function checkFunctionCall = [=](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { if (!Token::Match(tok->astParent(), "[(,]")) @@ -2044,6 +2046,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, } } +#ifdef BUG_HUNTING_UNINIT // Uninitialized function argument.. if (settings->library.isuninitargbad(parent->astOperand1(), num) && settings->library.isnullargbad(parent->astOperand1(), num) && value.type == ExprEngine::ValueType::ArrayValue) { const ExprEngine::ArrayValue &arrayValue = static_cast(value); @@ -2058,15 +2061,18 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, } } } +#endif }; std::vector callbacks; callbacks.push_back(divByZero); callbacks.push_back(checkFunctionCall); -#ifdef VERIFY_INTEGEROVERFLOW +#ifdef BUG_HUNTING_INTEGEROVERFLOW callbacks.push_back(integerOverflow); #endif +#ifdef BUG_HUNTING_UNINIT callbacks.push_back(uninit); +#endif std::ostringstream report; ExprEngine::executeAllFunctions(tokenizer, settings, callbacks, report); diff --git a/test/verify/itc.py b/test/verify/itc.py index a93b59426..1afb898da 100644 --- a/test/verify/itc.py +++ b/test/verify/itc.py @@ -33,7 +33,7 @@ def get_error_lines(filename): def check(filename): cmd = [CPPCHECK_PATH, - '--verify', + '--bug-hunting', '--platform=unix64', filename] print(' '.join(cmd)) diff --git a/test/verify/juliet.py b/test/verify/juliet.py index fbca4a42b..a7eeb9173 100644 --- a/test/verify/juliet.py +++ b/test/verify/juliet.py @@ -40,7 +40,7 @@ def check(tc:str, warning_id:str): '-DAF_INET=1', '-DINADDR_ANY=1', '--library=posix', - '--verify', + '--bug-hunting', '--platform=unix64'] cmd += glob.glob(f) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -61,8 +61,8 @@ def check(tc:str, warning_id:str): final_report = '' -#final_report += check('C/testcases/CWE369_Divide_by_Zero/s*/*.c', 'verificationDivByZero') -final_report += check('C/testcases/CWE457_Use_of_Uninitialized_Variable/s*/*.c', 'verificationUninit') +final_report += check('C/testcases/CWE369_Divide_by_Zero/s*/*.c', 'verificationDivByZero') +#final_report += check('C/testcases/CWE457_Use_of_Uninitialized_Variable/s*/*.c', 'verificationUninit') print(final_report)