diff --git a/cfg/posix.cfg b/cfg/posix.cfg index db63a3e29..0a7a888ea 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -1,14 +1,5 @@ - - - - false - - - - - false diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index cdfb7b5ae..7aa34e56a 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1449,7 +1449,9 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok, uninitdataError(tok, tok->str()); else uninitvarError(tok, tok->str()); - } else + } + + else // assume that variable is assigned return true; } @@ -1664,12 +1666,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, bool all if (!alloc && vartok->previous()->str() == "return") return true; - // code like: return foo( variable - if (vartok->tokAt(-3) && vartok->strAt(-3) == "return" - && vartok->tokAt(-1) && vartok->strAt(-1) == "(") - return true; - - // Passing variable to typeof/__alignof__ + // Passing variable to typeof/__alignof__ if (Token::Match(vartok->tokAt(-3), "typeof|__alignof__ ( * %var%")) return false; diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b8616ad3e..49f4e2d63 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -73,7 +73,6 @@ private: TEST_CASE(syntax_error); // Ticket #5073 // Test that the functions from std.cfg are configured correctly - TEST_CASE(stdcfg_btowc); TEST_CASE(stdcfg_clearerr); TEST_CASE(stdcfg_fclose); TEST_CASE(stdcfg_fopen); @@ -3611,15 +3610,6 @@ private: ASSERT_EQUALS("[test.cpp:6]: (debug) assertion failed '} while ('\n", errout.str()); } - // Test that the btowc function, defined in std.cfg is configured correctly. - void stdcfg_btowc() { - checkUninitVar2("wchar_t f() { int i; return btowc(i); }"); - ASSERT_EQUALS("[test.cpp:1]: (error) Uninitialized variable: i\n", errout.str()); - - checkUninitVar2("wchar_t f(int i) { return btowc(i); }"); - ASSERT_EQUALS("", errout.str()); - } - // Test that the clearerr function, defined in std.cfg is configured correctly. void stdcfg_clearerr() { checkUninitVar("void f() {\n"