Fix CodeQL warning, Multiplication result converted to larger type
This commit is contained in:
parent
52b88bcee3
commit
88a35d2253
|
@ -216,15 +216,15 @@ void CheckFunctions::checkIgnoredReturnValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!tok->function() || !Token::Match(tok->function()->retDef, "void %name%")) &&
|
if ((!tok->function() || !Token::Match(tok->function()->retDef, "void %name%")) &&
|
||||||
!WRONG_DATA(!tok->next()->astOperand1(), tok)) {
|
!WRONG_DATA(!tok->next()->astOperand1(), tok)) {
|
||||||
const Library::UseRetValType retvalTy = mSettings->library.getUseRetValType(tok);
|
const Library::UseRetValType retvalTy = mSettings->library.getUseRetValType(tok);
|
||||||
if (mSettings->isEnabled(Settings::WARNING) &&
|
if (mSettings->isEnabled(Settings::WARNING) &&
|
||||||
((retvalTy == Library::UseRetValType::DEFAULT) ||
|
((retvalTy == Library::UseRetValType::DEFAULT) ||
|
||||||
(tok->function() && tok->function()->isAttributeNodiscard())))
|
(tok->function() && tok->function()->isAttributeNodiscard())))
|
||||||
ignoredReturnValueError(tok, tok->next()->astOperand1()->expressionString());
|
ignoredReturnValueError(tok, tok->next()->astOperand1()->expressionString());
|
||||||
else if (mSettings->isEnabled(Settings::STYLE) &&
|
else if (mSettings->isEnabled(Settings::STYLE) &&
|
||||||
retvalTy == Library::UseRetValType::ERROR_CODE)
|
retvalTy == Library::UseRetValType::ERROR_CODE)
|
||||||
ignoredReturnErrorCode(tok, tok->next()->astOperand1()->expressionString());
|
ignoredReturnErrorCode(tok, tok->next()->astOperand1()->expressionString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,8 +219,8 @@ std::string Suppressions::addSuppressionLine(const std::string &line)
|
||||||
std::string Suppressions::addSuppression(const Suppressions::Suppression &suppression)
|
std::string Suppressions::addSuppression(const Suppressions::Suppression &suppression)
|
||||||
{
|
{
|
||||||
// Check if suppression is already in list
|
// Check if suppression is already in list
|
||||||
auto foundSuppression = std::find_if(mSuppressions.begin(), mSuppressions.end(),
|
auto foundSuppression = std::find_if(mSuppressions.begin(), mSuppressions.end(),
|
||||||
std::bind(&Suppression::isSameParameters, &suppression, std::placeholders::_1));
|
std::bind(&Suppression::isSameParameters, &suppression, std::placeholders::_1));
|
||||||
if (foundSuppression != mSuppressions.end()) {
|
if (foundSuppression != mSuppressions.end()) {
|
||||||
// Update matched state of existing global suppression
|
// Update matched state of existing global suppression
|
||||||
if (!suppression.isLocal() && suppression.matched)
|
if (!suppression.isLocal() && suppression.matched)
|
||||||
|
|
|
@ -102,11 +102,11 @@ public:
|
||||||
|
|
||||||
bool isSameParameters(const Suppression &other) const {
|
bool isSameParameters(const Suppression &other) const {
|
||||||
return errorId == other.errorId &&
|
return errorId == other.errorId &&
|
||||||
fileName == other.fileName &&
|
fileName == other.fileName &&
|
||||||
lineNumber == other.lineNumber &&
|
lineNumber == other.lineNumber &&
|
||||||
symbolName == other.symbolName &&
|
symbolName == other.symbolName &&
|
||||||
hash == other.hash &&
|
hash == other.hash &&
|
||||||
thisAndNextLine == other.thisAndNextLine;
|
thisAndNextLine == other.thisAndNextLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string errorId;
|
std::string errorId;
|
||||||
|
|
|
@ -596,8 +596,8 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
||||||
value2.isIntValue())) {
|
value2.isIntValue())) {
|
||||||
ValueFlow::Value result(0);
|
ValueFlow::Value result(0);
|
||||||
combineValueProperties(value1, value2, &result);
|
combineValueProperties(value1, value2, &result);
|
||||||
const float floatValue1 = value1.isIntValue() ? value1.intvalue : value1.floatValue;
|
const double floatValue1 = value1.isIntValue() ? value1.intvalue : value1.floatValue;
|
||||||
const float floatValue2 = value2.isIntValue() ? value2.intvalue : value2.floatValue;
|
const double floatValue2 = value2.isIntValue() ? value2.intvalue : value2.floatValue;
|
||||||
switch (parent->str()[0]) {
|
switch (parent->str()[0]) {
|
||||||
case '+':
|
case '+':
|
||||||
if (value1.isTokValue() || value2.isTokValue())
|
if (value1.isTokValue() || value2.isTokValue())
|
||||||
|
|
Loading…
Reference in New Issue