Ticket #4510 - Reduced the scope of the safeFunctions variable to avoid a cppcheck style issue

This commit is contained in:
Zachary Blair 2013-04-26 20:06:17 -07:00
parent 548dd42aaf
commit 1f97e0e5df
1 changed files with 3 additions and 3 deletions

View File

@ -1200,11 +1200,11 @@ void CheckNullPointer::nullConstantDereference()
*/ */
void CheckNullPointer::removeAssignedVarFromSet(const Token* tok, std::set<unsigned int>& pointerArgs) void CheckNullPointer::removeAssignedVarFromSet(const Token* tok, std::set<unsigned int>& pointerArgs)
{ {
// Common functions that are known NOT to modify their pointer argument
const char safeFunctions[] = "printf|sprintf|fprintf|vprintf";
// If a pointer's address is passed into a function, stop considering it // If a pointer's address is passed into a function, stop considering it
if (Token::Match(tok->previous(), "[;{}] %var% (")) { if (Token::Match(tok->previous(), "[;{}] %var% (")) {
// Common functions that are known NOT to modify their pointer argument
const char safeFunctions[] = "printf|sprintf|fprintf|vprintf";
const Token* endParen = tok->next()->link(); const Token* endParen = tok->next()->link();
for (const Token* tok2 = tok->next(); tok2 != endParen; tok2 = tok2->next()) { for (const Token* tok2 = tok->next(); tok2 != endParen; tok2 = tok2->next()) {
if (tok2->isName() && tok2->varId() > 0 && !Token::Match(tok, safeFunctions)) { if (tok2->isName() && tok2->varId() > 0 && !Token::Match(tok, safeFunctions)) {