Skip to content

Commit

Permalink
made all suppressions in cfg tests inline / added TODOs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Mar 19, 2024
1 parent e2081e8 commit 781ad94
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 48 deletions.
4 changes: 0 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_FILE:cppcheck>
--library=${LIBRARY}
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <boost/config.hpp>
#include <boost/math/special_functions/round.hpp>
#include <boost/endian/conversion.hpp>
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <string.h>
#include <stdlib.h>
#include <stdint.h>
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/cppunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <cppunit/TestAssert.h>

void cppunit_assert_equal(int x, double y)
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <string.h>
#include <stdlib.h>
#include <stdint.h>
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/googletest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <gmock/gmock-generated-matchers.h>
#include <gtest/gtest.h>

Expand Down
2 changes: 2 additions & 0 deletions test/cfg/libcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <curl/curl.h>
#include <stdio.h>

Expand Down
2 changes: 2 additions & 0 deletions test/cfg/opencv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <iostream>
#include <opencv2/opencv.hpp>

Expand Down
2 changes: 2 additions & 0 deletions test/cfg/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file [valueFlowBailout,purgedConfiguration]

#define _BSD_SOURCE

#include <aio.h>
Expand Down
31 changes: 16 additions & 15 deletions test/cfg/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file [valueFlowBailout,unmatchedSuppression] - TODO: remove unmatchedSuppression

#include <QObject>
#include <QString>
#include <QVector>
Expand Down Expand Up @@ -35,9 +37,9 @@

void unreadVariable_QRegion(const int x, const QRegion::RegionType type, const QPolygon &polygon, const QBitmap &bm, const QRegion &region, 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};
Expand All @@ -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};
Expand All @@ -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};
Expand All @@ -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};
Expand All @@ -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};
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
2 changes: 2 additions & 0 deletions test/cfg/std.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
16 changes: 9 additions & 7 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file valueFlowBailout

#include <algorithm>
#include <bitset>
#include <cassert>
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 5 additions & 3 deletions test/cfg/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

// cppcheck-suppress-file [valueFlowBailout,purgedConfiguration]

#include <Windows.h>
#include <WinCon.h>
#include <cstdio>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down
Loading

0 comments on commit 781ad94

Please sign in to comment.