From 236073c78d12a89d03259e016a2199eeb3d1493b Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 19 Mar 2024 10:24:36 +0100 Subject: [PATCH] made all suppressions in `cfg` tests inline / added TODOs [skip ci] --- test/CMakeLists.txt | 4 ---- test/cfg/boost.cpp | 2 ++ test/cfg/bsd.c | 2 ++ test/cfg/cppunit.cpp | 2 ++ test/cfg/gnu.c | 2 ++ test/cfg/googletest.cpp | 2 ++ test/cfg/libcurl.c | 2 ++ test/cfg/opencv2.cpp | 2 ++ test/cfg/posix.c | 2 ++ test/cfg/qt.cpp | 4 +++- test/cfg/runtests.sh | 2 +- test/cfg/std.c | 2 ++ test/cfg/std.cpp | 16 +++++++++------- test/cfg/windows.cpp | 8 +++++--- test/cfg/wxwidgets.cpp | 2 ++ 15 files changed, 38 insertions(+), 16 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 723aa98ea0c5..a92ef8ed166d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -115,7 +115,6 @@ if (BUILD_TESTS) else() # TODO: remove missingInclude disabling when it no longer is implied by --enable=information # TODO: add syntax check - # need to suppress unmatchedSuppression in case valueFlowBailout is not reported add_test(NAME cfg-${TEST_NAME} COMMAND $ --library=${LIBRARY} @@ -129,9 +128,6 @@ if (BUILD_TESTS) --disable=missingInclude --inline-suppr --debug-warnings - --suppress=valueFlowBailout - --suppress=purgedConfiguration - --suppress=unmatchedSuppression --suppress=checkersReport ${CMAKE_CURRENT_SOURCE_DIR}/cfg/${CFG_TEST} ) diff --git a/test/cfg/boost.cpp b/test/cfg/boost.cpp index d2e19fbd2b1c..d68d5a7f262f 100644 --- a/test/cfg/boost.cpp +++ b/test/cfg/boost.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include diff --git a/test/cfg/bsd.c b/test/cfg/bsd.c index 734a97fe4aa5..6652129c553f 100644 --- a/test/cfg/bsd.c +++ b/test/cfg/bsd.c @@ -6,6 +6,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include diff --git a/test/cfg/cppunit.cpp b/test/cfg/cppunit.cpp index 28b7fa7a8580..1eaf0b666283 100644 --- a/test/cfg/cppunit.cpp +++ b/test/cfg/cppunit.cpp @@ -6,6 +6,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include void cppunit_assert_equal(int x, double y) diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c index 6b51a2bb3fb2..296a3cc04428 100644 --- a/test/cfg/gnu.c +++ b/test/cfg/gnu.c @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include diff --git a/test/cfg/googletest.cpp b/test/cfg/googletest.cpp index 7dfc0946006c..c13db34967a1 100644 --- a/test/cfg/googletest.cpp +++ b/test/cfg/googletest.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include diff --git a/test/cfg/libcurl.c b/test/cfg/libcurl.c index 8c494494a032..9e91eefcc5c7 100644 --- a/test/cfg/libcurl.c +++ b/test/cfg/libcurl.c @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include diff --git a/test/cfg/opencv2.cpp b/test/cfg/opencv2.cpp index 5ab29ef80fff..847ab1b42f42 100644 --- a/test/cfg/opencv2.cpp +++ b/test/cfg/opencv2.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 95c7b81cda1e..b4b8c9e49859 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file [valueFlowBailout,purgedConfiguration] + #define _BSD_SOURCE #include diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index 513c8bb1bef0..d4350cea8279 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include @@ -576,7 +578,7 @@ void validCode(int * pIntPtr, QString & qstrArg, double d) printf(QT_TR_NOOP("Hi")); - // cppcheck-suppress [checkLibraryFunction,valueFlowBailoutIncompleteVar] + // cppcheck-suppress valueFlowBailoutIncompleteVar Q_DECLARE_LOGGING_CATEGORY(logging_category_test); QT_FORWARD_DECLARE_CLASS(forwardDeclaredClass); QT_FORWARD_DECLARE_STRUCT(forwardDeclaredStruct); diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 70eb2ffb4788..5b4fa1dd6fd6 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -27,7 +27,7 @@ CFG="$DIR"../../cfg/ # TODO: remove missingInclude disabling when it no longer is implied by --enable=information # Cppcheck options # need to suppress unmatchedSuppression in case valueFlowBailout is not reported -CPPCHECK_OPT='--check-library --platform=unix64 --enable=style,information --inconclusive --force --check-level=exhaustive --error-exitcode=-1 --disable=missingInclude --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}" --debug-warnings --suppress=valueFlowBailout --suppress=purgedConfiguration --suppress=unmatchedSuppression --suppress=checkersReport' +CPPCHECK_OPT='--check-library --platform=unix64 --enable=style,information --inconclusive --force --check-level=exhaustive --error-exitcode=-1 --disable=missingInclude --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}" --debug-warnings --suppress=checkersReport' # Compiler settings CXX=g++ diff --git a/test/cfg/std.c b/test/cfg/std.c index 98952c6de3b3..f795cdc5bdaf 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index a5490796dc81..8f4344514991 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include @@ -2472,21 +2474,21 @@ void uninitvar_ldexp(void) void invalidFunctionArg_lgamma(float f, double d, long double ld) { (void)lgamma(d); - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg (void)lgamma(-0.1); // cppcheck-suppress invalidFunctionArg (void)lgamma(0.0); (void)lgamma(0.1); (void)lgammaf(f); - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg (void)lgammaf(-0.1f); // cppcheck-suppress invalidFunctionArg (void)lgammaf(0.0f); (void)lgammaf(0.1f); (void)lgammal(ld); - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg (void)lgammal(-0.1L); // cppcheck-suppress invalidFunctionArg (void)lgammal(0.0L); @@ -2496,21 +2498,21 @@ void invalidFunctionArg_lgamma(float f, double d, long double ld) void invalidFunctionArg_tgamma(float f, double d, long double ld) { (void)tgamma(d); - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg (void)tgamma(-0.1); // cppcheck-suppress invalidFunctionArg (void)tgamma(0.0); (void)tgamma(0.1); (void)tgammaf(f); - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg (void)tgammaf(-0.1f); // cppcheck-suppress invalidFunctionArg (void)tgammaf(0.0f); (void)tgammaf(0.1f); (void)tgammal(ld); - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg (void)tgammal(-0.1L); // cppcheck-suppress invalidFunctionArg (void)tgammal(0.0L); @@ -4969,7 +4971,7 @@ void memleak_std_realloc(void* block, size_t newsize) void unusedAllocatedMemory_std_free() { - //cppcheck-suppress unusedAllocatedMemory + // TODO cppcheck-suppress unusedAllocatedMemory void* p = std::malloc(1); std::free(p); } diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index 470aeb332c19..5f2e6555ead8 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file [valueFlowBailout,purgedConfiguration] + #include #include #include @@ -355,7 +357,7 @@ void validCode() WSACleanup(); wordInit = MAKEWORD(1, 2); - // cppcheck-suppress redundantAssignment + // TODO cppcheck-suppress redundantAssignment dwordInit = MAKELONG(1, 2); // cppcheck-suppress redundantAssignment wordInit = LOWORD(dwordInit); @@ -789,7 +791,7 @@ void invalidFunctionArg() CloseHandle(hMutex); //Incorrect: 2. parameter to LoadLibraryEx() must be NULL - // cppcheck-suppress invalidFunctionArg + // TODO cppcheck-suppress invalidFunctionArg HINSTANCE hInstLib = LoadLibraryEx(L"My.dll", HANDLE(1), 0); FreeLibrary(hInstLib); @@ -814,7 +816,7 @@ void uninitvar() // cppcheck-suppress uninitvar lstrcat(buf, _T("test")); buf[0] = _T('\0'); - // cppcheck-suppress constVariable + // TODO cppcheck-suppress constVariable TCHAR buf2[2]; // cppcheck-suppress lstrcatCalled // cppcheck-suppress uninitvar diff --git a/test/cfg/wxwidgets.cpp b/test/cfg/wxwidgets.cpp index 0852aaba9965..9292a7f71b35 100644 --- a/test/cfg/wxwidgets.cpp +++ b/test/cfg/wxwidgets.cpp @@ -7,6 +7,8 @@ // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // +// cppcheck-suppress-file valueFlowBailout + #include #include #include