MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / wrongPrintfScanfArgumentsError

Method wrongPrintfScanfArgumentsError

lib/checkio.cpp:1734–1754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1732}
1733
1734void CheckIOImpl::wrongPrintfScanfArgumentsError(const Token* tok,
1735 const std::string &functionName,
1736 nonneg int numFormat,
1737 nonneg int numFunction)
1738{
1739 const Severity severity = numFormat > numFunction ? Severity::error : Severity::warning;
1740 if (severity != Severity::error && !mSettings.severity.isEnabled(Severity::warning) && !mSettings.isPremiumEnabled("wrongPrintfScanfArgNum"))
1741 return;
1742
1743 std::ostringstream errmsg;
1744 errmsg << functionName
1745 << " format string requires "
1746 << numFormat
1747 << " parameter" << (numFormat != 1 ? "s" : "") << " but "
1748 << (numFormat > numFunction ? "only " : "")
1749 << numFunction
1750 << (numFunction != 1 ? " are" : " is")
1751 << " given.";
1752
1753 reportError(tok, severity, "wrongPrintfScanfArgNum", errmsg.str(), CWE685, Certainty::normal);
1754}
1755
1756void CheckIOImpl::wrongPrintfScanfPosixParameterPositionError(const Token* tok, const std::string& functionName,
1757 nonneg int index, nonneg int numFunction)

Callers 1

getErrorMessagesMethod · 0.80

Calls 4

isPremiumEnabledMethod · 0.80
reportErrorFunction · 0.70
isEnabledMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected