astyle formatting

This commit is contained in:
Daniel Marjamäki 2015-08-07 20:27:32 +02:00
parent 48c6b30d1a
commit ec3d76be5e
3 changed files with 137 additions and 137 deletions

View File

@ -2614,6 +2614,6 @@ void CheckOther::checkInterlockedDecrement()
void CheckOther::raceAfterInterlockedDecrementError(const Token* tok) void CheckOther::raceAfterInterlockedDecrementError(const Token* tok)
{ {
reportError(tok, Severity::error, "raceAfterInterlockedDecrement", reportError(tok, Severity::error, "raceAfterInterlockedDecrement",
"Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead."); "Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.");
} }

View File

@ -230,7 +230,7 @@ public:
void checkInterlockedDecrement(); void checkInterlockedDecrement();
void checkNewAfterDelete(); void checkNewAfterDelete();
private: private:
// Error messages.. // Error messages..

View File

@ -6256,201 +6256,201 @@ private:
void raceAfterInterlockedDecrement() { void raceAfterInterlockedDecrement() {
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" whatever();\n" " whatever();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (counter)\n" " if (counter)\n"
" return;\n" " return;\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (!counter)\n" " if (!counter)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (counter > 0)\n" " if (counter > 0)\n"
" return;\n" " return;\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (0 < counter)\n" " if (0 < counter)\n"
" return;\n" " return;\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (counter == 0)\n" " if (counter == 0)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (0 == counter)\n" " if (0 == counter)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (0 != counter)\n" " if (0 != counter)\n"
" return;\n" " return;\n"
" destroy()\n" " destroy()\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (counter != 0)\n" " if (counter != 0)\n"
" return;\n" " return;\n"
" destroy()\n" " destroy()\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (counter <= 0)\n" " if (counter <= 0)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" InterlockedDecrement(&counter);\n" " InterlockedDecrement(&counter);\n"
" if (0 >= counter)\n" " if (0 >= counter)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:4]: (error) Race condition: non-interlocked access after InterlockedDecrement(). Use InterlockedDecrement() return value instead.\n", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (newCount)\n" " if (newCount)\n"
" return;\n" " return;\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (!newCount)\n" " if (!newCount)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (newCount > 0)\n" " if (newCount > 0)\n"
" return;\n" " return;\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (0 < newCount)\n" " if (0 < newCount)\n"
" return;\n" " return;\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (newCount == 0)\n" " if (newCount == 0)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (0 == newCount)\n" " if (0 == newCount)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (0 != newCount)\n" " if (0 != newCount)\n"
" return;\n" " return;\n"
" destroy()\n" " destroy()\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (newCount != 0)\n" " if (newCount != 0)\n"
" return;\n" " return;\n"
" destroy()\n" " destroy()\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (newCount <= 0)\n" " if (newCount <= 0)\n"
" destroy();\n" " destroy();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkInterlockedDecrement( checkInterlockedDecrement(
"void f() {\n" "void f() {\n"
" int counter = 0;\n" " int counter = 0;\n"
" int newCount = InterlockedDecrement(&counter);\n" " int newCount = InterlockedDecrement(&counter);\n"
" if (0 >= newCount)\n" " if (0 >= newCount)\n"
" destroy;\n" " destroy;\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
}; };