enabled and mitigated debug warnings in cfg tests (#5840)
This commit is contained in:
parent
950b285608
commit
028596f100
|
@ -6,6 +6,7 @@
|
|||
<define name="cairo_bool_t" value="int"/>
|
||||
<!-- TODO: Configure cairo_status_t as an enum when this is implemented in Cppcheck -->
|
||||
<podtype name="cairo_status_t"/>
|
||||
<define name="CAIRO_STATUS_READ_ERROR" value="10"/>
|
||||
<!-- ########## cairo Macros / Defines ########## -->
|
||||
<define name="CAIRO_HAS_MIME_SURFACE" value="1"/>
|
||||
<define name="CAIRO_MIME_TYPE_CCITT_FAX" value=""image/g3fax""/>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<!-- This file once has been generated automatically. See https://github.com/scriptum/cppcheck-libs -->
|
||||
<!-- Now it is maintained and extended manually. -->
|
||||
<def format="2">
|
||||
<define name="TRUE" value="(!FALSE)"/>
|
||||
<define name="FALSE" value="(0)"/>
|
||||
<define name="g_return_if_fail(expr)" value="do{if(!(expr)){return;}}while(0)"/>
|
||||
<define name="g_return_val_if_fail(expr, val)" value="do{if(!(expr)){return val;}}while(0)"/>
|
||||
<define name="g_return_if_reached()" value="do{return;}while(0)"/>
|
||||
|
|
|
@ -113,17 +113,22 @@ 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}
|
||||
--check-library
|
||||
--platform=${PLATFORM}
|
||||
--library=${LIBRARY}
|
||||
--enable=style,information
|
||||
--inconclusive
|
||||
--force
|
||||
--error-exitcode=1
|
||||
--disable=missingInclude
|
||||
--inline-suppr
|
||||
--template="{file}:{line}:{severity}:{id}:{message}"
|
||||
--debug-warnings
|
||||
--suppress=valueFlowBailout
|
||||
--suppress=unmatchedSuppression
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cfg/${CFG_TEST}
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -83,6 +83,7 @@ void macros()
|
|||
BOOST_PP_REPEAT(5, DECL, int x)
|
||||
|
||||
BOOST_SCOPED_ENUM_DECLARE_BEGIN(future_errc) {
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
no_state
|
||||
}
|
||||
BOOST_SCOPED_ENUM_DECLARE_END(future_errc)
|
||||
|
|
|
@ -316,6 +316,7 @@ void valid_code(int argInt1, va_list valist_arg, const int * parg)
|
|||
|
||||
if (__alignof__(int) == 4) {}
|
||||
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
const void * p_mmap = mmap(NULL, 1, PROT_NONE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
|
||||
printf("%p", p_mmap);
|
||||
munmap(p_mmap, 1);
|
||||
|
|
|
@ -15,12 +15,15 @@ namespace ExampleNamespace {
|
|||
constexpr long long TOLERANCE = 10;
|
||||
|
||||
// #9397 syntaxError when MATCHER_P is not known
|
||||
// cppcheck-suppress symbolDatabaseWarning
|
||||
MATCHER_P(ExampleMatcherPTest, expected, "")
|
||||
{
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
return ((arg <= (expected + TOLERANCE)) && (arg >= (expected - TOLERANCE)));
|
||||
}
|
||||
|
||||
// syntaxError when MATCHER is not known
|
||||
// cppcheck-suppress symbolDatabaseWarning
|
||||
MATCHER(ExampleMatcherTest, "")
|
||||
{
|
||||
return (arg == TOLERANCE);
|
||||
|
|
|
@ -289,6 +289,7 @@ void g_new_if_test()
|
|||
};
|
||||
|
||||
const struct a * pNew3;
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
if (pNew3 = g_new(struct a, 6)) {
|
||||
printf("%p", pNew3);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ void validCode()
|
|||
CURL *curl = curl_easy_init();
|
||||
if (curl) {
|
||||
CURLcode res;
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
|
||||
res = curl_easy_perform(curl);
|
||||
if (res != CURLE_OK) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
void validCode(const char* argStr)
|
||||
{
|
||||
cv::Mat image;
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
image = cv::imread(argStr, cv::IMREAD_COLOR);
|
||||
if (!image.data) {
|
||||
printf("No image data \n");
|
||||
|
|
|
@ -895,6 +895,7 @@ void validCode(va_list valist_arg1, va_list valist_arg2)
|
|||
void *ptr;
|
||||
if (posix_memalign(&ptr, sizeof(void *), sizeof(void *)) == 0)
|
||||
free(ptr);
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
syslog(LOG_ERR, "err %u", 0U);
|
||||
syslog(LOG_WARNING, "warn %d %d", 5, 1);
|
||||
vsyslog(LOG_EMERG, "emerg %d", valist_arg1);
|
||||
|
|
|
@ -316,7 +316,7 @@ QVector<int>::iterator QVector2()
|
|||
// cppcheck-suppress passedByValue
|
||||
void duplicateExpression_QString_Compare(QString style) //#8723
|
||||
{
|
||||
// cppcheck-suppress duplicateExpression
|
||||
// cppcheck-suppress [duplicateExpression,valueFlowBailoutIncompleteVar]
|
||||
if (style.compare( "x", Qt::CaseInsensitive ) == 0 || style.compare( "x", Qt::CaseInsensitive ) == 0)
|
||||
{}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
set -e # abort on error
|
||||
#set -x # be verbose
|
||||
|
||||
# TODO: do not bail out on first error - always run all tests and return error instead
|
||||
|
||||
function exit_if_strict {
|
||||
if [ -n "${STRICT}" ] && [ "${STRICT}" -eq 1 ]; then
|
||||
exit 1
|
||||
|
@ -24,7 +26,8 @@ CFG="$DIR"../../cfg/
|
|||
|
||||
# TODO: remove missingInclude disabling when it no longer is implied by --enable=information
|
||||
# Cppcheck options
|
||||
CPPCHECK_OPT='--check-library --platform=unix64 --enable=style,information --inconclusive --force --error-exitcode=-1 --disable=missingInclude --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}"'
|
||||
# need to suppress unmatchedSuppression in case valueFlowBailout is not reported
|
||||
CPPCHECK_OPT='--check-library --platform=unix64 --enable=style,information --inconclusive --force --error-exitcode=-1 --disable=missingInclude --inline-suppr --template="{file}:{line}:{severity}:{id}:{message}" --debug-warnings --suppress=valueFlowBailout --suppress=unmatchedSuppression'
|
||||
|
||||
# Compiler settings
|
||||
CXX=g++
|
||||
|
@ -33,6 +36,7 @@ CC=gcc
|
|||
CC_OPT='-fsyntax-only -w -std=c11'
|
||||
|
||||
function get_pkg_config_cflags {
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
PKGCONFIG=$(pkg-config --cflags "$@")
|
||||
PKGCONFIG_RETURNCODE=$?
|
||||
|
@ -65,6 +69,7 @@ function qt_fn {
|
|||
if [ -n "$QTCONFIG" ]; then
|
||||
QTBUILDCONFIG=$(pkg-config --variable=qt_config Qt5Core Qt5Test)
|
||||
[[ $QTBUILDCONFIG =~ (^|[[:space:]])reduce_relocations($|[[:space:]]) ]] && QTCONFIG="${QTCONFIG} -fPIC"
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <QString>" | ${CXX} ${CXX_OPT} ${QTCONFIG} -x c++ -
|
||||
QTCHECK_RETURNCODE=$?
|
||||
|
@ -107,6 +112,7 @@ function windows_fn {
|
|||
|
||||
# wxwidgets.cpp
|
||||
function wxwidgets_fn {
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
WXCONFIG=$(wx-config --cxxflags)
|
||||
WXCONFIG_RETURNCODE=$?
|
||||
|
@ -115,6 +121,7 @@ function wxwidgets_fn {
|
|||
echo "wx-config does not work, skipping syntax check for wxWidgets tests."
|
||||
exit_if_strict
|
||||
else
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <wx/filefn.h>\n#include <wx/app.h>\n#include <wx/artprov.h>\n#include <wx/version.h>\n#if wxVERSION_NUMBER<2950\n#error \"Old version\"\n#endif" | ${CXX} ${CXX_OPT} ${WXCONFIG} -x c++ -
|
||||
WXCHECK_RETURNCODE=$?
|
||||
|
@ -137,6 +144,7 @@ function gtk_fn {
|
|||
GTKCONFIG=$(get_pkg_config_cflags gtk+-2.0)
|
||||
fi
|
||||
if [ -n "$GTKCONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <gtk/gtk.h>" | ${CC} ${CC_OPT} ${GTKCONFIG} -x c -
|
||||
GTKCHECK_RETURNCODE=$?
|
||||
|
@ -157,6 +165,7 @@ function gtk_fn {
|
|||
|
||||
# boost.cpp
|
||||
function boost_fn {
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <boost/config.hpp>" | ${CXX} ${CXX_OPT} -x c++ -
|
||||
BOOSTCHECK_RETURNCODE=$?
|
||||
|
@ -175,6 +184,7 @@ function sqlite3_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
SQLITE3CONFIG=$(get_pkg_config_cflags sqlite3)
|
||||
if [ -n "$SQLITE3CONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <sqlite3.h>" | ${CC} ${CC_OPT} ${SQLITE3CONFIG} -x c -
|
||||
SQLITE3CHECK_RETURNCODE=$?
|
||||
|
@ -206,6 +216,7 @@ function python_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
PYTHON3CONFIG=$(get_pkg_config_cflags python3)
|
||||
if [ -n "$PYTHON3CONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <Python.h>" | ${CC} ${CC_OPT} ${PYTHON3CONFIG} -x c -
|
||||
PYTHON3CONFIG_RETURNCODE=$?
|
||||
|
@ -229,6 +240,7 @@ function lua_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
LUACONFIG=$(get_pkg_config_cflags lua-5.3)
|
||||
if [ -n "$LUACONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <lua.h>" | ${CC} ${CC_OPT} ${LUACONFIG} -x c -
|
||||
LUACONFIG_RETURNCODE=$?
|
||||
|
@ -252,6 +264,7 @@ function libcurl_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
LIBCURLCONFIG=$(get_pkg_config_cflags libcurl)
|
||||
if [ -n "$LIBCURLCONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <curl/curl.h>" | ${CC} ${CC_OPT} ${LIBCURLCONFIG} -x c -
|
||||
LIBCURLCONFIG_RETURNCODE=$?
|
||||
|
@ -275,6 +288,7 @@ function cairo_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
CAIROCONFIG=$(get_pkg_config_cflags cairo)
|
||||
if [ -n "$CAIROCONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <cairo.h>" | ${CC} ${CC_OPT} ${CAIROCONFIG} -x c -
|
||||
CAIROCONFIG_RETURNCODE=$?
|
||||
|
@ -300,6 +314,7 @@ function googletest_fn {
|
|||
|
||||
# kde.cpp
|
||||
function kde_fn {
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
KDECONFIG=$(kde4-config --path include)
|
||||
KDECONFIG_RETURNCODE=$?
|
||||
|
@ -313,6 +328,7 @@ function kde_fn {
|
|||
echo "Suitable Qt not present, Qt is necessary for KDE. Skipping syntax check."
|
||||
exit_if_strict
|
||||
else
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <KDE/KGlobal>\n" | ${CXX} ${CXX_OPT} -I${KDECONFIG} ${KDEQTCONFIG} -x c++ -
|
||||
KDECHECK_RETURNCODE=$?
|
||||
|
@ -333,6 +349,7 @@ function libsigcpp_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
LIBSIGCPPCONFIG=$(get_pkg_config_cflags sigc++-2.0)
|
||||
if [ -n "$LIBSIGCPPCONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <sigc++/sigc++.h>\n" | ${CXX} ${CXX_OPT} ${LIBSIGCPPCONFIG} -x c++ -
|
||||
LIBSIGCPPCONFIG_RETURNCODE=$?
|
||||
|
@ -356,6 +373,7 @@ function openssl_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
OPENSSLCONFIG=$(get_pkg_config_cflags libssl)
|
||||
if [ -n "$OPENSSLCONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <openssl/ssl.h>" | ${CC} ${CC_OPT} ${OPENSSLCONFIG} -x c -
|
||||
OPENSSLCONFIG_RETURNCODE=$?
|
||||
|
@ -379,6 +397,7 @@ function opencv2_fn {
|
|||
if [ $HAS_PKG_CONFIG -eq 1 ]; then
|
||||
OPENCVCONFIG=$(get_pkg_config_cflags opencv)
|
||||
if [ -n "$OPENCVCONFIG" ]; then
|
||||
# TODO: get rid of the error enabling/disabling?
|
||||
set +e
|
||||
echo -e "#include <opencv2/opencv.hpp>\n" | ${CXX} ${CXX_OPT} ${OPENCVCONFIG} -x c++ -
|
||||
OPENCVCONFIG_RETURNCODE=$?
|
||||
|
|
|
@ -16,7 +16,7 @@ void validCode()
|
|||
|
||||
int rc = sqlite3_open("/db", &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
fprintf(stderr, "Error opening sqlite3 db: %s\n", sqlite3_errmsg(db));
|
||||
printf("Error opening sqlite3 db: %s\n", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
} else {
|
||||
sqlite3_close(db);
|
||||
|
|
|
@ -185,6 +185,7 @@ size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size
|
|||
void bufferAccessOutOfBounds(void)
|
||||
{
|
||||
char a[5];
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
fgets(a,5,stdin);
|
||||
// cppcheck-suppress bufferAccessOutOfBounds
|
||||
fgets(a,6,stdin);
|
||||
|
|
|
@ -588,6 +588,7 @@ void *bufferAccessOutOfBounds_memchr(void *s, int c, size_t n)
|
|||
#ifdef __STDC_LIB_EXT1__
|
||||
void uninitvar_localtime_s(const std::time_t *restrict time, struct tm *restrict result)
|
||||
{
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
const std::time_t *restrict Time;
|
||||
// TODO cppcheck-suppress uninitvar
|
||||
(void)std::localtime_s(Time, result);
|
||||
|
@ -640,6 +641,7 @@ void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t po
|
|||
(void)str.substr(pos,-1);
|
||||
// no warning is expected for
|
||||
(void)str.substr(pos,len);
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
(void)str.substr(pos, std::string::npos);
|
||||
}
|
||||
|
||||
|
@ -4602,8 +4604,10 @@ void stdbind()
|
|||
std::bind(stdbind_helper, 1);
|
||||
|
||||
// TODO cppcheck-suppress unreadVariable
|
||||
// cppcheck-suppress autoNoType
|
||||
auto f1 = std::bind(stdbind_helper, _1);
|
||||
// TODO cppcheck-suppress unreadVariable
|
||||
// cppcheck-suppress autoNoType
|
||||
auto f2 = std::bind(stdbind_helper, 10);
|
||||
}
|
||||
|
||||
|
@ -4778,6 +4782,7 @@ void smartPtr_get()
|
|||
|
||||
void smartPtr_get2(std::vector<std::unique_ptr<int>>& v)
|
||||
{
|
||||
// cppcheck-suppress autoNoType
|
||||
for (auto& u : v) {
|
||||
int* p = u.get();
|
||||
*p = 0;
|
||||
|
|
|
@ -234,6 +234,7 @@ void validCode()
|
|||
hSemaphore1 = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
CloseHandle(hSemaphore1);
|
||||
HANDLE hSemaphore2;
|
||||
// cppcheck-suppress valueFlowBailoutIncompleteVar
|
||||
hSemaphore2 = CreateSemaphoreEx(NULL, 0, 1, NULL, 0, SEMAPHORE_ALL_ACCESS);
|
||||
CloseHandle(hSemaphore2);
|
||||
HANDLE hSemaphore3;
|
||||
|
|
Loading…
Reference in New Issue