diff --git a/lib/checkvaarg.cpp b/lib/checkvaarg.cpp index 1fd3d5e9c..ed463120b 100644 --- a/lib/checkvaarg.cpp +++ b/lib/checkvaarg.cpp @@ -86,7 +86,7 @@ void CheckVaarg::va_list_usage() bool exitOnEndOfStatement = false; const Token* tok = var->nameToken()->next(); - for (const Token* tok = var->nameToken()->next(); tok != var->scope()->classEnd; tok = tok->next()) { + for (; tok != var->scope()->classEnd; tok = tok->next()) { if (Token::Match(tok, "va_start ( %varid% ,", var->declarationId())) { if (open) va_start_subsequentCallsError(tok, var->name()); diff --git a/test/testvaarg.cpp b/test/testvaarg.cpp index 635dbe3a6..3ba65fc43 100644 --- a/test/testvaarg.cpp +++ b/test/testvaarg.cpp @@ -104,7 +104,7 @@ private: " va_list arg_ptr;\n" " va_start(arg_ptr, szBuffer);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) va_list 'arg_ptr' was opened but not closed by va_end().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error) va_list 'arg_ptr' was opened but not closed by va_end().\n", errout.str()); check("void Format(char* szFormat, char (*szBuffer)[_Size], ...) {\n" " va_list arg_ptr;\n" @@ -112,7 +112,7 @@ private: " if(sth) return;\n" " va_end(arg_ptr);\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (error) va_list 'arg_ptr' was opened but not closed by va_end().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error) va_list 'arg_ptr' was opened but not closed by va_end().\n", errout.str()); } void va_list_usedBeforeStarted() {