@@ -1068,18 +1068,6 @@ void CheckUninitVar::checkScope(const Scope* scope)
10681068 continue ;
10691069 if (i->nameToken ()->strAt (1 ) == " (" )
10701070 continue ;
1071-
1072- bool forHead = false ; // Don't check variables declared in header of a for loop
1073- for (const Token* tok = i->typeStartToken (); tok; tok = tok->previous ()) {
1074- if (tok->str () == " (" ) {
1075- forHead = true ;
1076- break ;
1077- } else if (Token::Match (tok, " [{};]" ))
1078- break ;
1079- }
1080- if (forHead)
1081- continue ;
1082-
10831071 bool stdtype = _tokenizer->isC ();
10841072 const Token* tok = i->typeStartToken ();
10851073 for (; tok && tok->str () != " ;" && tok->str () != " <" ; tok = tok->next ()) {
@@ -1090,8 +1078,10 @@ void CheckUninitVar::checkScope(const Scope* scope)
10901078 tok = tok->next ();
10911079 if (!tok)
10921080 continue ;
1093- if (Token::findsimplematch (i->typeStartToken (), " =" , tok))
1081+ if (Token::Match (i->nameToken (), " %var% =" )) {
1082+ checkRhs (i->nameToken (), *i, false , " " );
10941083 continue ;
1084+ }
10951085 if (stdtype || i->isPointer ()) {
10961086 bool alloc = false ;
10971087 checkScopeForVariable (scope, tok, *i, NULL , NULL , &alloc, " " );
@@ -1780,7 +1770,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool all
17801770 }
17811771
17821772 bool unknown = false ;
1783- if (pointer && CheckNullPointer::isPointerDeRef (vartok, unknown)) {
1773+ if (pointer && ( CheckNullPointer::isPointerDeRef (vartok, unknown) || Token::Match (vartok, " %var% . " ) )) {
17841774 // pointer is allocated - dereferencing it is ok.
17851775 if (alloc)
17861776 return false ;
0 commit comments