Ensure wrongPrintfScanfParameterPositionError is shown by 'cppcheck --errorlist'.
This commit is contained in:
parent
8e59ea9842
commit
1fe008ba4b
|
@ -737,7 +737,7 @@ void CheckIO::checkWrongPrintfScanfArguments()
|
|||
|
||||
// Check that all parameter positions reference an actual parameter
|
||||
for (std::set<unsigned int>::const_iterator it = parameterPositionsUsed.begin() ; it != parameterPositionsUsed.end() ; ++it) {
|
||||
if ((*it == 0) || (*it > numFormat))
|
||||
if (((*it == 0) || (*it > numFormat)) && _settings->isEnabled("warning"))
|
||||
wrongPrintfScanfPosixParameterPositionError(tok, tok->str(), *it, numFormat);
|
||||
}
|
||||
|
||||
|
@ -772,8 +772,6 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok,
|
|||
void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, const std::string& functionName,
|
||||
unsigned int index, unsigned int numFunction)
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << functionName << ": ";
|
||||
if (index == 0) {
|
||||
|
@ -781,7 +779,7 @@ void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, cons
|
|||
} else {
|
||||
errmsg << "referencing parameter " << index << " while " << numFunction << " arguments given";
|
||||
}
|
||||
reportError(tok, Severity::warning, "wrongPrintfScanfParameterError", errmsg.str());
|
||||
reportError(tok, Severity::warning, "wrongPrintfScanfParameterPositionError", errmsg.str());
|
||||
}
|
||||
|
||||
void CheckIO::invalidScanfArgTypeError(const Token* tok, const std::string &functionName, unsigned int numFormat)
|
||||
|
|
|
@ -115,6 +115,7 @@ private:
|
|||
c.invalidPrintfArgTypeError_sint(0, 1, "i");
|
||||
c.invalidPrintfArgTypeError_float(0, 1, "f");
|
||||
c.invalidScanfFormatWidthError(0, 10, 5, NULL);
|
||||
c.wrongPrintfScanfPosixParameterPositionError(0, "printf", 2, 1);
|
||||
}
|
||||
|
||||
static std::string myName() {
|
||||
|
|
Loading…
Reference in New Issue