From 1b63503116b7d573b2d3a12ccceb5135a1871545 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 | 31 ++++++++++++++++--------------- test/cfg/runtests.sh | 2 +- test/cfg/std.c | 2 ++ test/cfg/std.cpp | 16 +++++++++------- test/cfg/windows.cpp | 8 +++++--- test/cfg/wxwidgets.cpp | 38 ++++++++++++++++++++------------------ 15 files changed, 69 insertions(+), 48 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4ec673ba1522..571bf4b3db0e 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 ${CMAKE_CURRENT_SOURCE_DIR}/cfg/${CFG_TEST} ) endif() 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 a259215153b1..5ab23853717a 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 cc4c1415ae6e..5a5a3b9b1275 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 7af2d6b70552..b59541014dd9 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 c2a78fbdc1b6..bb2e49423d6b 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 5fcb803e3728..f548947b3bb5 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,unmatchedSuppression] - TODO: remove unmatchedSuppression + #include #include #include @@ -35,9 +37,9 @@ void unreadVariable_QRegion(const int x, const QRegion::RegionType type, const QPolygon &polygon, const QBitmap &bm, const QRegion ®ion, const Qt::FillRule fillRule) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QRegion a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QRegion b{}; // cppcheck-suppress unreadVariable QRegion c{x,x,x,x}; @@ -53,9 +55,9 @@ void unreadVariable_QRegion(const int x, const QRegion::RegionType type, const Q void unreadVariable_QPoint(const QPoint &s) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QPoint a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QPoint b{}; // cppcheck-suppress unreadVariable QPoint c{4, 2}; @@ -67,9 +69,9 @@ void unreadVariable_QPoint(const QPoint &s) void unreadVariable_QPointF(const QPointF &s) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QPointF a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QPointF b{}; // cppcheck-suppress unreadVariable QPointF c{4.2, 4.2}; @@ -81,9 +83,9 @@ void unreadVariable_QPointF(const QPointF &s) void unreadVariable_QSizeF(const QSize &s) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QSizeF a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QSizeF b{}; // cppcheck-suppress unreadVariable QSizeF c{4.2, 4.2}; @@ -95,9 +97,9 @@ void unreadVariable_QSizeF(const QSize &s) void unreadVariable_QSize(const QSize &s) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QSize a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QSize b{}; // cppcheck-suppress unreadVariable QSize c{4, 2}; @@ -108,9 +110,9 @@ void unreadVariable_QSize(const QSize &s) } void unreadVariable_QRect(const QPoint &topLeft, const QSize &size, const QPoint &bottomRight, const int x) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QRect a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QRect b{}; // cppcheck-suppress unreadVariable QRect c(0, 0, 100, 50); @@ -123,9 +125,9 @@ void unreadVariable_QRect(const QPoint &topLeft, const QSize &size, const QPoint } void unreadVariable_QRectF(const QPointF &topLeft, const QSizeF &size, const QPointF &bottomRight, const QRectF &rect, const qreal x) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QRectF a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable QRectF b{}; // cppcheck-suppress unreadVariable QRectF c(0.0, 0.0, 100.0, 50.0); @@ -576,7 +578,6 @@ void validCode(int * pIntPtr, QString & qstrArg, double d) printf(QT_TR_NOOP("Hi")); - // cppcheck-suppress checkLibraryFunction 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 744d9aa7284f..51de119ab1c4 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' +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' # Compiler settings CXX=g++ diff --git a/test/cfg/std.c b/test/cfg/std.c index 9f2a0d213cf3..f23c5955592e 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 d27a87d0b478..f203ce61f236 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 @@ -2469,21 +2471,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); @@ -2493,21 +2495,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); @@ -4963,7 +4965,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 179f44d4b3f4..afdb8124a52d 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 85e233cdf9a6..06d24bf2dd47 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 @@ -38,13 +40,13 @@ void unreadVariable_wxAcceleratorEntry() { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxAcceleratorEntry a; } void unreadVariable_wxDateSpan(const int x) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxDateSpan a; // cppcheck-suppress unreadVariable wxDateSpan b{x}; @@ -58,9 +60,9 @@ void unreadVariable_wxDateSpan(const int x) void unreadVariable_wxTimeSpan(const long x, const wxLongLong y) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxTimeSpan a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxTimeSpan b{}; // cppcheck-suppress unreadVariable wxTimeSpan c{x}; @@ -80,9 +82,9 @@ void unreadVariable_wxFileType(const wxFileTypeInfo &info) void unreadVariable_wxPosition(const int x) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxPosition a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxPosition b{}; // cppcheck-suppress unreadVariable wxPosition c{x,x}; @@ -90,7 +92,7 @@ void unreadVariable_wxPosition(const int x) void unreadVariable_wxRegEx(const wxString &expr, const int flags) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRegEx a; // cppcheck-suppress unreadVariable wxRegEx b{expr}; @@ -100,9 +102,9 @@ void unreadVariable_wxRegEx(const wxString &expr, const int flags) void unreadVariable_wxRegion(const wxCoord x, const wxPoint &pt, const wxRect &rect, const wxRegion ®ion, const wxBitmap &bmp) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRegion a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRegion b{}; // cppcheck-suppress unreadVariable wxRegion c{x,x,x,x}; @@ -118,7 +120,7 @@ void unreadVariable_wxRegion(const wxCoord x, const wxPoint &pt, const wxRect &r void unreadVariable_wxVersionInfo(const wxString &name, const int major, const int minor, const int micro, const wxString &description, const wxString ©right) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxVersionInfo a; // cppcheck-suppress unreadVariable wxVersionInfo b(name); @@ -136,9 +138,9 @@ void unreadVariable_wxVersionInfo(const wxString &name, const int major, const i void unreadVariable_wxSize(const wxSize &s) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxSize a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxSize b{}; // cppcheck-suppress unreadVariable wxSize c{4, 2}; @@ -150,9 +152,9 @@ void unreadVariable_wxSize(const wxSize &s) void unreadVariable_wxPoint(const wxRealPoint &rp, const int x, const int y) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxPoint a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxPoint b{}; // cppcheck-suppress unreadVariable wxPoint c{4, 2}; @@ -168,9 +170,9 @@ void unreadVariable_wxPoint(const wxRealPoint &rp, const int x, const int y) void unreadVariable_wxRealPoint(const wxPoint &pt, const double x, const double y) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRealPoint a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRealPoint b{}; // cppcheck-suppress unreadVariable wxRealPoint c{4.0, 2.0}; @@ -186,9 +188,9 @@ void unreadVariable_wxRealPoint(const wxPoint &pt, const double x, const double void unreadVariable_wxRect(const int x, const wxPoint &pt, const wxSize &sz) { - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRect a; - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable wxRect b{}; // cppcheck-suppress unreadVariable wxRect c{x,x,x,x};