From d3d3d31613212a8f71e0223f481013524459cb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 23 May 2017 11:57:25 +0200 Subject: [PATCH] Clarify 'invalidFunctionArg' messages --- lib/checkfunctions.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index df5931dac..c08f4bb50 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -133,12 +133,20 @@ void CheckFunctions::invalidFunctionArgError(const Token *tok, const std::string errmsg << " The value is " << invalidValue->intvalue << " but the valid values are '" << validstr << "'."; else errmsg << " The value is 0 or 1 (boolean) but the valid values are '" << validstr << "'."; - reportError(tok, - (!invalidValue || !invalidValue->condition) ? Severity::error : Severity::warning, - "invalidFunctionArg", - errmsg.str(), - CWE628, - invalidValue && invalidValue->inconclusive); + if (invalidValue) + reportError(getErrorPath(tok, invalidValue, "Invalid argument"), + invalidValue->errorSeverity() ? Severity::error : Severity::warning, + "invalidFunctionArg", + errmsg.str(), + CWE628, + invalidValue->inconclusive); + else + reportError(tok, + Severity::error, + "invalidFunctionArg", + errmsg.str(), + CWE628, + false); } void CheckFunctions::invalidFunctionArgBoolError(const Token *tok, const std::string &functionName, int argnr)