null pointer: Fixed better error message for 'possible null pointer' + removed redundant check in our Tokenizer.

This commit is contained in:
Daniel Marjamäki 2010-02-28 07:26:50 +01:00
parent 4407aabe55
commit 6ca4b008d0
3 changed files with 3 additions and 3 deletions

View File

@ -1187,7 +1187,7 @@ void CheckOther::nullPointerLinkedList()
// Is this variable a pointer? // Is this variable a pointer?
const Token *tempTok = Token::findmatch(_tokenizer->tokens(), "%type% * %varid% [;)=]", varid); const Token *tempTok = Token::findmatch(_tokenizer->tokens(), "%type% * %varid% [;)=]", varid);
if (tempTok) if (tempTok)
nullPointerError(tok1, varname); nullPointerError(tok1, varname, tok3->linenr());
break; break;
} }

View File

@ -850,7 +850,7 @@ void Tokenizer::simplifyTypedef()
if (tok2->str() != "}") if (tok2->str() != "}")
{ {
int level = 0; int level = 0;
while (tok2 && tok2->next() && (tok2->next()->str() != "}" || level)) while (tok2->next() && (tok2->next()->str() != "}" || level))
{ {
if (tok2->next()->str() == "{") if (tok2->next()->str() == "{")
level++; level++;

View File

@ -670,7 +670,7 @@ private:
" tok = tok->next();\n" " tok = tok->next();\n"
" }\n" " }\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: tok\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 5\n", errout.str());
checkNullPointer("void foo(Token &tok)\n" checkNullPointer("void foo(Token &tok)\n"
"{\n" "{\n"