From 81726e35923c2444b471be483db6fd26eeeb1ed5 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 13 Aug 2023 23:04:27 +0200 Subject: [PATCH 1/4] added missing `__GNUC__` define for selfcheck --- .github/workflows/CI-unixish.yml | 4 +++- .github/workflows/asan.yml | 2 +- .github/workflows/tsan.yml | 2 +- .github/workflows/ubsan.yml | 2 +- createrelease | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 902417375a8..1e51f0d6faa 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -460,9 +460,11 @@ jobs: - name: Self check run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings --check-level=exhaustive" + selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings --check-level=exhaustive" ec=0 + # TODO: add --check-config + # early exit if [ $ec -eq 1 ]; then exit $ec diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index fe7c5a95a77..c29ecde8a4a 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -82,7 +82,7 @@ jobs: - name: Self check if: false run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings" + selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json cli lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml index 6114817c194..876e1976141 100644 --- a/.github/workflows/tsan.yml +++ b/.github/workflows/tsan.yml @@ -82,7 +82,7 @@ jobs: - name: Self check if: false run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings" + selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json -DCHECK_INTERNAL cli lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index 3076801002e..2a422710b74 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -78,7 +78,7 @@ jobs: # TODO: only fail the step on sanitizer issues - since we use processes it will only fail the underlying process which will result in an cppcheckError - name: Self check run: | - selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings" + selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=top5 -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2/ --inconclusive --enable=style,performance,portability,warning,missingInclude,internal --exception-handling --debug-warnings" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options --addon=naming.json cli lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 diff --git a/createrelease b/createrelease index c99964be13d..0a98f850266 100755 --- a/createrelease +++ b/createrelease @@ -11,7 +11,7 @@ # # self check, fix critical issues: # make clean && make CXXFLAGS=-O2 MATCHCOMPILER=yes -j4 -# ./cppcheck -D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --std=c++11 --library=cppcheck-lib --library=qt --enable=style --inconclusive --inline-suppr --suppress=bitwiseOnBoolean --suppress=shadowFunction --suppress=useStlAlgorithm --suppress=*:externals/picojson.h --suppress=functionConst --suppress=functionStatic --xml cli gui/*.cpp lib 2> selfcheck.xml +# ./cppcheck -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --std=c++11 --library=cppcheck-lib --library=qt --enable=style --inconclusive --inline-suppr --suppress=bitwiseOnBoolean --suppress=shadowFunction --suppress=useStlAlgorithm --suppress=*:externals/picojson.h --suppress=functionConst --suppress=functionStatic --xml cli gui/*.cpp lib 2> selfcheck.xml # # Update translations # lupdate gui.pro @@ -82,7 +82,7 @@ # 2. scp -i ../.ssh/osuosl_id_rsa tools/donate-cpu-server.py danielmarjamaki@cppcheck1.osuosl.org:/var/daca@home/ # # self check, fix stylistic issues: -# ./cppcheck -D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib --enable=style --inconclusive --inline-suppr --suppress=bitwiseOnBoolean --suppress=shadowFunction --suppress=useStlAlgorithm --suppress=*:externals/picojson.h cli gui/*.cpp lib +# ./cppcheck -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib --enable=style --inconclusive --inline-suppr --suppress=bitwiseOnBoolean --suppress=shadowFunction --suppress=useStlAlgorithm --suppress=*:externals/picojson.h cli gui/*.cpp lib # # Set debug version (see 803eea912c9512c810a7e78d58bb927d89a6daa1) From 013f603bb56b7c71812571e070e3f8e414e732d6 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 13 Aug 2023 23:21:11 +0200 Subject: [PATCH 2/4] cppcheckexecutorsig.cpp: fixed `unreadVariable` selfcheck warning --- cli/cppcheckexecutorsig.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/cppcheckexecutorsig.cpp b/cli/cppcheckexecutorsig.cpp index e8d447682eb..7327a02f405 100644 --- a/cli/cppcheckexecutorsig.cpp +++ b/cli/cppcheckexecutorsig.cpp @@ -119,7 +119,9 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) const Signalmap_t::const_iterator it=listofsignals.find(signo); const char * const signame = (it==listofsignals.end()) ? "unknown" : it->second.c_str(); +#ifdef USE_UNIX_BACKTRACE_SUPPORT bool lowMem=false; // was low-memory condition detected? Be careful then! Avoid allocating much more memory then. +#endif bool unexpectedSignal=true; // unexpected indicates program failure bool terminate=true; // exit process/thread const bool isAddressOnStack = IsAddressOnStack(info->si_addr); @@ -135,7 +137,9 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) " - out of memory or assertion?\n", #endif output); +#ifdef USE_UNIX_BACKTRACE_SUPPORT lowMem=true; // educated guess +#endif break; case SIGBUS: fputs("Internal error: cppcheck received signal ", output); From 9fca92aba6b0cc6e554f4fb7d4040ea1bf9601c3 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 13 Aug 2023 23:22:23 +0200 Subject: [PATCH 3/4] cppcheckexecutorsig.cpp: fixed `cstyleCast` selfcheck warning --- cli/cppcheckexecutorsig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cppcheckexecutorsig.cpp b/cli/cppcheckexecutorsig.cpp index 7327a02f405..7e853976ad1 100644 --- a/cli/cppcheckexecutorsig.cpp +++ b/cli/cppcheckexecutorsig.cpp @@ -300,7 +300,7 @@ int check_wrapper_sig(CppCheckExecutor& executor, int (CppCheckExecutor::*f)(Cpp { // determine stack vs. heap char stackVariable; - char *heapVariable=(char*)malloc(1); + char *heapVariable=static_cast(malloc(1)); bStackBelowHeap = &stackVariable < heapVariable; free(heapVariable); From 2186a2d162e1cb72b30d8f7a9af7d3203e5f8407 Mon Sep 17 00:00:00 2001 From: firewave Date: Sun, 13 Aug 2023 23:23:52 +0200 Subject: [PATCH 4/4] cppcheckexecutorsig.cpp: suppress `constParameterCallback` selfcheck warning --- cli/cppcheckexecutorsig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/cppcheckexecutorsig.cpp b/cli/cppcheckexecutorsig.cpp index 7e853976ad1..c5347d8e5ac 100644 --- a/cli/cppcheckexecutorsig.cpp +++ b/cli/cppcheckexecutorsig.cpp @@ -101,6 +101,7 @@ static const Signalmap_t listofsignals = { * but when ending up here something went terribly wrong anyway. * And all which is left is just printing some information and terminate. */ +// cppcheck-suppress constParameterCallback static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context) { int type = -1;