errmsg: Added message 'Overlapping data buffer'
This commit is contained in:
parent
ae861852e2
commit
17d4c2b980
|
@ -212,8 +212,6 @@ void CheckOther::WarningIf()
|
||||||
{
|
{
|
||||||
if (Token::Match(tok2, ") ; !!else"))
|
if (Token::Match(tok2, ") ; !!else"))
|
||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
|
||||||
ostr << _tokenizer->fileLine(tok) << ": Found \"if (condition);\"";
|
|
||||||
_errorLogger->reportErr(ErrorMessage::ifNoAction(_tokenizer, tok));
|
_errorLogger->reportErr(ErrorMessage::ifNoAction(_tokenizer, tok));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -357,9 +355,7 @@ void CheckOther::InvalidFunctionUsage()
|
||||||
}
|
}
|
||||||
else if (parlevel == 0 && tok2->varId() == varid)
|
else if (parlevel == 0 && tok2->varId() == varid)
|
||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
_errorLogger->reportErr(ErrorMessage::sprintfOverlappingData(_tokenizer, tok2, tok2->str()));
|
||||||
ostr << _tokenizer->fileLine(tok2) << ": Overlapping data buffer " << tok2->str();
|
|
||||||
_errorLogger->reportErr(ostr.str());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,8 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
checkOther.WarningRedundantCode();
|
checkOther.WarningRedundantCode();
|
||||||
|
|
||||||
// strtol and strtoul usage
|
// strtol and strtoul usage
|
||||||
if (ErrorMessage::dangerousUsageStrtol(_settings))
|
if (ErrorMessage::dangerousUsageStrtol(_settings) ||
|
||||||
|
ErrorMessage::sprintfOverlappingData(_settings))
|
||||||
checkOther.InvalidFunctionUsage();
|
checkOther.InvalidFunctionUsage();
|
||||||
|
|
||||||
// Check that all private functions are called.
|
// Check that all private functions are called.
|
||||||
|
|
|
@ -192,5 +192,14 @@ public:
|
||||||
return s._checkCodingStyle;
|
return s._checkCodingStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string sprintfOverlappingData(const Tokenizer *tokenizer, const Token *Location, const std::string &varname)
|
||||||
|
{
|
||||||
|
return msg1(tokenizer, Location) + "Overlapping data buffer " + varname + "";
|
||||||
|
}
|
||||||
|
static bool sprintfOverlappingData(const Settings &s)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,6 +80,7 @@ int main()
|
||||||
err.push_back(Message("redundantIfRemove", Message::STYLE, "Redundant condition. The remove function in the STL will not do anything if element doesn't exist"));
|
err.push_back(Message("redundantIfRemove", Message::STYLE, "Redundant condition. The remove function in the STL will not do anything if element doesn't exist"));
|
||||||
err.push_back(Message("dangerousUsageStrtol", 0, "Invalid radix in call to strtol or strtoul. Must be 0 or 2-36"));
|
err.push_back(Message("dangerousUsageStrtol", 0, "Invalid radix in call to strtol or strtoul. Must be 0 or 2-36"));
|
||||||
err.push_back(Message("ifNoAction", Message::STYLE, "Found redundant if condition - 'if (condition);'"));
|
err.push_back(Message("ifNoAction", Message::STYLE, "Found redundant if condition - 'if (condition);'"));
|
||||||
|
err.push_back(Message("sprintfOverlappingData", 0, "Overlapping data buffer %1", "varname"));
|
||||||
|
|
||||||
// Generate code..
|
// Generate code..
|
||||||
std::cout << "Generate code.." << std::endl;
|
std::cout << "Generate code.." << std::endl;
|
||||||
|
|
Loading…
Reference in New Issue