Use knownConditionTrueFalse when is duplicate expression is true or false (#1410)
This commit is contained in:
parent
e170a45230
commit
26a8435d76
|
@ -2058,7 +2058,9 @@ void CheckOther::duplicateExpressionError(const Token *tok1, const Token *tok2,
|
|||
|
||||
const std::string& op = opTok ? opTok->str() : "&&";
|
||||
std::string msg = "Same expression on both sides of \'" + op + "\'";
|
||||
std::string id = "duplicateExpression";
|
||||
if (expr1 != expr2) {
|
||||
id = "knownConditionTrueFalse";
|
||||
std::string exprMsg = "The expression \'" + expr1 + " " + op + " " + expr2 + "\' is always ";
|
||||
if (Token::Match(opTok, "==|>=|<="))
|
||||
msg = exprMsg + "true";
|
||||
|
@ -2068,7 +2070,7 @@ void CheckOther::duplicateExpressionError(const Token *tok1, const Token *tok2,
|
|||
msg += " because '" + expr1 + "' and '" + expr2 + "' represent the same value";
|
||||
}
|
||||
|
||||
reportError(errors, Severity::style, "duplicateExpression", msg + ".\n"
|
||||
reportError(errors, Severity::style, id.c_str(), msg + ".\n"
|
||||
"Finding the same expression on both sides of an operator is suspicious and might "
|
||||
"indicate a cut and paste or logic error. Please examine this code carefully to "
|
||||
"determine if it is correct.", CWE398, false);
|
||||
|
|
Loading…
Reference in New Issue