From 88a35d22534f91e9d0194871580d5f2ef9097504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 6 Nov 2020 19:50:05 +0100 Subject: [PATCH] Fix CodeQL warning, Multiplication result converted to larger type --- lib/checkfunctions.cpp | 8 ++++---- lib/suppressions.cpp | 4 ++-- lib/suppressions.h | 10 +++++----- lib/valueflow.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index bf0c6411d..a7db0baca 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -216,15 +216,15 @@ void CheckFunctions::checkIgnoredReturnValue() } 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); if (mSettings->isEnabled(Settings::WARNING) && ((retvalTy == Library::UseRetValType::DEFAULT) || - (tok->function() && tok->function()->isAttributeNodiscard()))) - ignoredReturnValueError(tok, tok->next()->astOperand1()->expressionString()); + (tok->function() && tok->function()->isAttributeNodiscard()))) + ignoredReturnValueError(tok, tok->next()->astOperand1()->expressionString()); else if (mSettings->isEnabled(Settings::STYLE) && retvalTy == Library::UseRetValType::ERROR_CODE) - ignoredReturnErrorCode(tok, tok->next()->astOperand1()->expressionString()); + ignoredReturnErrorCode(tok, tok->next()->astOperand1()->expressionString()); } } } diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index c2122da20..18165ab32 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -219,8 +219,8 @@ std::string Suppressions::addSuppressionLine(const std::string &line) std::string Suppressions::addSuppression(const Suppressions::Suppression &suppression) { // Check if suppression is already in list - auto foundSuppression = std::find_if(mSuppressions.begin(), mSuppressions.end(), - std::bind(&Suppression::isSameParameters, &suppression, std::placeholders::_1)); + auto foundSuppression = std::find_if(mSuppressions.begin(), mSuppressions.end(), + std::bind(&Suppression::isSameParameters, &suppression, std::placeholders::_1)); if (foundSuppression != mSuppressions.end()) { // Update matched state of existing global suppression if (!suppression.isLocal() && suppression.matched) diff --git a/lib/suppressions.h b/lib/suppressions.h index 71e473003..2f3b5681d 100644 --- a/lib/suppressions.h +++ b/lib/suppressions.h @@ -102,11 +102,11 @@ public: bool isSameParameters(const Suppression &other) const { return errorId == other.errorId && - fileName == other.fileName && - lineNumber == other.lineNumber && - symbolName == other.symbolName && - hash == other.hash && - thisAndNextLine == other.thisAndNextLine; + fileName == other.fileName && + lineNumber == other.lineNumber && + symbolName == other.symbolName && + hash == other.hash && + thisAndNextLine == other.thisAndNextLine; } std::string errorId; diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 0c5d69ae8..50a7c917c 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -596,8 +596,8 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti value2.isIntValue())) { ValueFlow::Value result(0); combineValueProperties(value1, value2, &result); - const float floatValue1 = value1.isIntValue() ? value1.intvalue : value1.floatValue; - const float floatValue2 = value2.isIntValue() ? value2.intvalue : value2.floatValue; + const double floatValue1 = value1.isIntValue() ? value1.intvalue : value1.floatValue; + const double floatValue2 = value2.isIntValue() ? value2.intvalue : value2.floatValue; switch (parent->str()[0]) { case '+': if (value1.isTokValue() || value2.isTokValue())