Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made all suppressions in cfg tests inline / added TODOs #6154

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
--suppress=checkersReport
${CMAKE_CURRENT_SOURCE_DIR}/cfg/${CFG_TEST}
)
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
4 changes: 3 additions & 1 deletion 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

#include <QObject>
#include <QString>
#include <QVector>
Expand Down Expand Up @@ -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);
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 --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++
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 @@ -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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in #5845 and was never detected. @orbitcowboy

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like !0.0: doesn't work, e.g. log() has <valid>4.94066e-324:</valid>.

(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 @@ -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);
Expand Down Expand Up @@ -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);
}
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
2 changes: 2 additions & 0 deletions test/cfg/wxwidgets.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 <wx/wx.h>
#include <wx/accel.h>
#include <wx/app.h>
Expand Down
Loading