Merge pull request #155 from simartin/ticket_4900_errorlist
Register error added for ticket #4900 in cppcheck --errorlist
This commit is contained in:
commit
57d8a8719b
|
@ -737,7 +737,7 @@ void CheckIO::checkWrongPrintfScanfArguments()
|
||||||
|
|
||||||
// Check that all parameter positions reference an actual parameter
|
// Check that all parameter positions reference an actual parameter
|
||||||
for (std::set<unsigned int>::const_iterator it = parameterPositionsUsed.begin() ; it != parameterPositionsUsed.end() ; ++it) {
|
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);
|
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,
|
void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, const std::string& functionName,
|
||||||
unsigned int index, unsigned int numFunction)
|
unsigned int index, unsigned int numFunction)
|
||||||
{
|
{
|
||||||
if (!_settings->isEnabled("warning"))
|
|
||||||
return;
|
|
||||||
std::ostringstream errmsg;
|
std::ostringstream errmsg;
|
||||||
errmsg << functionName << ": ";
|
errmsg << functionName << ": ";
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
|
@ -781,7 +779,7 @@ void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, cons
|
||||||
} else {
|
} else {
|
||||||
errmsg << "referencing parameter " << index << " while " << numFunction << " arguments given";
|
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)
|
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_sint(0, 1, "i");
|
||||||
c.invalidPrintfArgTypeError_float(0, 1, "f");
|
c.invalidPrintfArgTypeError_float(0, 1, "f");
|
||||||
c.invalidScanfFormatWidthError(0, 10, 5, NULL);
|
c.invalidScanfFormatWidthError(0, 10, 5, NULL);
|
||||||
|
c.wrongPrintfScanfPosixParameterPositionError(0, "printf", 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
Loading…
Reference in New Issue