Verification: Use separate id for floating point division by zero

This commit is contained in:
Daniel Marjamäki 2019-12-30 19:50:22 +01:00
parent 4b5585e75b
commit 3ff31b799c
2 changed files with 3 additions and 2 deletions

View File

@ -1734,7 +1734,8 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
if (tok->astParent()->astOperand2() == tok && value.isEqual(dataBase, 0)) {
dataBase->addError(tok->linenr());
std::list<const Token*> callstack{tok->astParent()};
ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, "verificationDivByZero", "There is division, cannot determine that there can't be a division by zero.", CWE(369), false);
const char * const id = (tok->valueType() && tok->valueType()->isFloat()) ? "verificationDivByZeroFloat" : "verificationDivByZero";
ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, id, "There is division, cannot determine that there can't be a division by zero.", CWE(369), false);
errorLogger->reportErr(errmsg);
}
};

View File

@ -31,7 +31,7 @@ void float1(float f) {
}
void float2(float f) {
// cppcheck-suppress verificationDivByZero
// cppcheck-suppress verificationDivByZeroFloat
return 100000 / f;
}