Skip to content

Commit 028596f

Browse files
authored
enabled and mitigated debug warnings in cfg tests (#5840)
1 parent 950b285 commit 028596f

File tree

16 files changed

+47
-4
lines changed

16 files changed

+47
-4
lines changed

cfg/cairo.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<define name="cairo_bool_t" value="int"/>
77
<!-- TODO: Configure cairo_status_t as an enum when this is implemented in Cppcheck -->
88
<podtype name="cairo_status_t"/>
9+
<define name="CAIRO_STATUS_READ_ERROR" value="10"/>
910
<!-- ########## cairo Macros / Defines ########## -->
1011
<define name="CAIRO_HAS_MIME_SURFACE" value="1"/>
1112
<define name="CAIRO_MIME_TYPE_CCITT_FAX" value="&quot;image/g3fax&quot;"/>

cfg/gtk.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!-- This file once has been generated automatically. See https://github.com/scriptum/cppcheck-libs -->
33
<!-- Now it is maintained and extended manually. -->
44
<def format="2">
5+
<define name="TRUE" value="(!FALSE)"/>
6+
<define name="FALSE" value="(0)"/>
57
<define name="g_return_if_fail(expr)" value="do{if(!(expr)){return;}}while(0)"/>
68
<define name="g_return_val_if_fail(expr, val)" value="do{if(!(expr)){return val;}}while(0)"/>
79
<define name="g_return_if_reached()" value="do{return;}while(0)"/>

test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,22 @@ if (BUILD_TESTS)
113113
else()
114114
# TODO: remove missingInclude disabling when it no longer is implied by --enable=information
115115
# TODO: add syntax check
116+
# need to suppress unmatchedSuppression in case valueFlowBailout is not reported
116117
add_test(NAME cfg-${TEST_NAME}
117118
COMMAND $<TARGET_FILE:cppcheck>
119+
--library=${LIBRARY}
118120
--check-library
119121
--platform=${PLATFORM}
120-
--library=${LIBRARY}
121122
--enable=style,information
122123
--inconclusive
123124
--force
124125
--error-exitcode=1
125126
--disable=missingInclude
126127
--inline-suppr
128+
--template="{file}:{line}:{severity}:{id}:{message}"
129+
--debug-warnings
130+
--suppress=valueFlowBailout
131+
--suppress=unmatchedSuppression
127132
${CMAKE_CURRENT_SOURCE_DIR}/cfg/${CFG_TEST}
128133
)
129134
endif()

test/cfg/boost.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void macros()
8383
BOOST_PP_REPEAT(5, DECL, int x)
8484

8585
BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc) {
86+
// cppcheck-suppress valueFlowBailoutIncompleteVar
8687
no_state
8788
}
8889
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)

test/cfg/gnu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ void valid_code(int argInt1, va_list valist_arg, const int * parg)
316316

317317
if (__alignof__(int) == 4) {}
318318

319+
// cppcheck-suppress valueFlowBailoutIncompleteVar
319320
const void * p_mmap = mmap(NULL, 1, PROT_NONE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
320321
printf("%p", p_mmap);
321322
munmap(p_mmap, 1);

test/cfg/googletest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ namespace ExampleNamespace {
1515
constexpr long long TOLERANCE = 10;
1616

1717
// #9397 syntaxError when MATCHER_P is not known
18+
// cppcheck-suppress symbolDatabaseWarning
1819
MATCHER_P(ExampleMatcherPTest, expected, "")
1920
{
21+
// cppcheck-suppress valueFlowBailoutIncompleteVar
2022
return ((arg <= (expected + TOLERANCE)) && (arg >= (expected - TOLERANCE)));
2123
}
2224

2325
// syntaxError when MATCHER is not known
26+
// cppcheck-suppress symbolDatabaseWarning
2427
MATCHER(ExampleMatcherTest, "")
2528
{
2629
return (arg == TOLERANCE);

test/cfg/gtk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ void g_new_if_test()
289289
};
290290

291291
const struct a * pNew3;
292+
// cppcheck-suppress valueFlowBailoutIncompleteVar
292293
if (pNew3 = g_new(struct a, 6)) {
293294
printf("%p", pNew3);
294295
}

test/cfg/libcurl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void validCode()
1515
CURL *curl = curl_easy_init();
1616
if (curl) {
1717
CURLcode res;
18+
// cppcheck-suppress valueFlowBailoutIncompleteVar
1819
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
1920
res = curl_easy_perform(curl);
2021
if (res != CURLE_OK) {

test/cfg/opencv2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
void validCode(const char* argStr)
1515
{
1616
cv::Mat image;
17+
// cppcheck-suppress valueFlowBailoutIncompleteVar
1718
image = cv::imread(argStr, cv::IMREAD_COLOR);
1819
if (!image.data) {
1920
printf("No image data \n");

test/cfg/posix.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ void validCode(va_list valist_arg1, va_list valist_arg2)
895895
void *ptr;
896896
if (posix_memalign(&ptr, sizeof(void *), sizeof(void *)) == 0)
897897
free(ptr);
898+
// cppcheck-suppress valueFlowBailoutIncompleteVar
898899
syslog(LOG_ERR, "err %u", 0U);
899900
syslog(LOG_WARNING, "warn %d %d", 5, 1);
900901
vsyslog(LOG_EMERG, "emerg %d", valist_arg1);

0 commit comments

Comments
 (0)