From 89043b4867027678da3ce39bac355026e688b5a1 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 12 Aug 2021 10:31:08 +0200 Subject: [PATCH 01/19] github workflow --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2ea59ab --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: 🧪 build + +on: + push: + branches: * + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Get deps + run: | + apt-get install cmake ninja clang + + - name: Build + run: | + mkdir -p build + cd build + cmake -GNinja .. + ninja + From 078a0941fccf0bb634c677709d8031630fd4eaad Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 12 Aug 2021 10:32:55 +0200 Subject: [PATCH 02/19] fix workflow --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ea59ab..df0d8ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,6 @@ name: 🧪 build on: push: - branches: * pull_request: branches: - master From 2737de898a14bdbd75905196ed2da5ba7b4bf251 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 12 Aug 2021 10:33:36 +0200 Subject: [PATCH 03/19] sudo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df0d8ab..e21f7b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - name: Get deps run: | - apt-get install cmake ninja clang + sudo apt-get install cmake ninja clang - name: Build run: | From 83787e4c8c6a2a1e88305b8741946d0dcfc70e42 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Thu, 12 Aug 2021 10:34:25 +0200 Subject: [PATCH 04/19] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e21f7b7..9c7d0cf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - name: Get deps run: | - sudo apt-get install cmake ninja clang + sudo apt-get install cmake ninja-build clang - name: Build run: | From 600b589f115a5c9fa10c12f7a1c326679c79e03b Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 06:44:53 +1000 Subject: [PATCH 05/19] Remove travis --- .travis.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 94a50e8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: cpp - -matrix: - include: - - os: linux - dist: trusty - sudo: false - compiler: gcc - -cache: ccache - - -script: - - mkdir -p build - - cd build - - cmake .. - - make -j2 \ No newline at end of file From 5d8eb651913ebc47452d5c57a00e7a5afd87daf7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:20:14 +1000 Subject: [PATCH 06/19] cppcheck workflow --- .github/workflows/code_checks.yml | 62 +++++++++++++++++++++++++ scripts/cppcheck.sh | 76 +++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 .github/workflows/code_checks.yml create mode 100755 scripts/cppcheck.sh diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml new file mode 100644 index 0000000..34c3d34 --- /dev/null +++ b/.github/workflows/code_checks.yml @@ -0,0 +1,62 @@ +name: Code Checks + +on: + push: + pull_request: + branches: + - master + +jobs: + + cppcheck_1604: + runs-on: ubuntu-16.04 + if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Requirements + run: | + sudo apt update + sudo apt install -y cppcheck libsqlite3-dev ccache sqlite3 + + - name: Cache PROJ build + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-cache-cppcheck-1604 + + - name: Build PROJ + run: | + curl http://download.osgeo.org/proj/proj-6.3.2.tar.gz > proj-6.3.2.tar.gz + tar xzf proj-6.3.2.tar.gz + mv proj-6.3.2 proj + cd proj + CC="ccache gcc" CXX="ccache g++" CFLAGS=-O0 CXXFLAGS=-O0 ./configure --without-static --prefix=/tmp/projinstall + make -j$(nproc) + make install -j$(nproc) + + - name: Run configure + run: (cd gdal && ./configure --with-proj=/tmp/projinstall) + + - name: Run cppcheck test + run: ./gdal/scripts/cppcheck.sh + + cppcheck_2004: + runs-on: ubuntu-20.04 + if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Requirements + run: | + sudo apt update + sudo apt install -y cppcheck libsqlite3-dev ccache sqlite3 libproj-dev + + - name: Run configure + run: (cd gdal && ./configure) + + - name: Run cppcheck test + run: ./gdal/scripts/cppcheck.sh + diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh new file mode 100755 index 0000000..509ea84 --- /dev/null +++ b/scripts/cppcheck.sh @@ -0,0 +1,76 @@ +#!/bin/sh + +set -eu + +SCRIPT_DIR=$(dirname "$0") +case $SCRIPT_DIR in + "/"*) + ;; + ".") + SCRIPT_DIR=$(pwd) + ;; + *) + SCRIPT_DIR=$(pwd)/$(dirname "$0") + ;; +esac + +LOG_FILE=/tmp/cppcheck_libdxfrw.txt + +rm -f ${LOG_FILE} +echo "Checking ${SCRIPT_DIR}/../src ..." + +cppcheck --inline-suppr \ + --template='{file}:{line},{severity},{id},{message}' \ + --enable=all --inconclusive --std=c++11 \ + -j $(nproc) \ + ${SCRIPT_DIR}/../src \ + >>${LOG_FILE} 2>&1 & + +PID=$! +while kill -0 $PID 2>/dev/null; do + printf "." + sleep 1 +done +echo " done" +if ! wait $PID; then + echo "cppcheck failed" + exit 1 +fi + +ret_code=0 + +cat ${LOG_FILE} | grep -v -e "syntaxError," -e "cppcheckError," > ${LOG_FILE}.tmp +mv ${LOG_FILE}.tmp ${LOG_FILE} + +for category in "style" "performance" "portability"; do + if grep "${category}," ${LOG_FILE} >/dev/null; then + echo "INFO: Issues in '${category}' category found, but not considered as making script to fail:" + grep "${category}," ${LOG_FILE} | grep -v -e "clarifyCalculation," -e "duplicateExpressionTernary," -e "redundantCondition," -e "unusedPrivateFunction," -e "postfixOperator," + echo "" + fi +done + +# unusedPrivateFunction not reliable enough in cppcheck 1.72 of Ubuntu 16.04 +if test "$(cppcheck --version)" = "Cppcheck 1.72"; then + UNUSED_PRIVATE_FUNCTION="" +else + UNUSED_PRIVATE_FUNCTION="unusedPrivateFunction" +fi + +for category in "error" "warning" "clarifyCalculation" "duplicateExpressionTernary" "redundantCondition" "postfixOperator" "${UNUSED_PRIVATE_FUNCTION}"; do + if test "${category}" != ""; then + if grep "${category}," ${LOG_FILE} >/dev/null; then + echo "ERROR: Issues in '${category}' category found:" + grep "${category}," ${LOG_FILE} + echo "" + echo "${category} check failed !" + ret_code=1 + fi + fi +done + +if [ ${ret_code} = 0 ]; then + echo "cppcheck succeeded" +fi + +exit ${ret_code} From 51338d3a497b800b3c0a2a7fb08cedc23e7242e6 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:24:00 +1000 Subject: [PATCH 07/19] Fix workflow --- .github/workflows/code_checks.yml | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 34c3d34..d74a03d 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -18,29 +18,10 @@ jobs: - name: Install Requirements run: | sudo apt update - sudo apt install -y cppcheck libsqlite3-dev ccache sqlite3 - - - name: Cache PROJ build - uses: actions/cache@v2 - with: - path: ~/.ccache - key: ${{ runner.os }}-cache-cppcheck-1604 - - - name: Build PROJ - run: | - curl http://download.osgeo.org/proj/proj-6.3.2.tar.gz > proj-6.3.2.tar.gz - tar xzf proj-6.3.2.tar.gz - mv proj-6.3.2 proj - cd proj - CC="ccache gcc" CXX="ccache g++" CFLAGS=-O0 CXXFLAGS=-O0 ./configure --without-static --prefix=/tmp/projinstall - make -j$(nproc) - make install -j$(nproc) - - - name: Run configure - run: (cd gdal && ./configure --with-proj=/tmp/projinstall) + sudo apt install -y cppcheck - name: Run cppcheck test - run: ./gdal/scripts/cppcheck.sh + run: ./scripts/cppcheck.sh cppcheck_2004: runs-on: ubuntu-20.04 @@ -52,11 +33,8 @@ jobs: - name: Install Requirements run: | sudo apt update - sudo apt install -y cppcheck libsqlite3-dev ccache sqlite3 libproj-dev - - - name: Run configure - run: (cd gdal && ./configure) + sudo apt install -y cppcheck - name: Run cppcheck test - run: ./gdal/scripts/cppcheck.sh + run: ./scripts/cppcheck.sh From 22b2105839209e8492eb63d33a9e36cea29ea4fe Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:27:25 +1000 Subject: [PATCH 08/19] ifdef out debug function --- src/intern/dwgreader18.cpp | 6 +++++- src/intern/dwgreader18.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/intern/dwgreader18.cpp b/src/intern/dwgreader18.cpp index e55c8a0..858bbe7 100644 --- a/src/intern/dwgreader18.cpp +++ b/src/intern/dwgreader18.cpp @@ -21,6 +21,7 @@ #include "drw_textcodec.h" #include "../libdwgr.h" +#if 0 void dwgReader18::genMagicNumber(){ int size =0x114; duint8 *tmpMagicStr = new duint8[size]; @@ -45,6 +46,7 @@ void dwgReader18::genMagicNumber(){ } delete[]tmpMagicStr; } +#endif duint32 dwgReader18::checksum(duint32 seed, duint8* data, duint32 sz){ duint32 size = sz; @@ -208,7 +210,9 @@ bool dwgReader18::readFileHeader() { if (! fileBuf->setPosition(0x80)) return false; -// genMagicNumber(); DBG("\n"); DBG("\n"); +#if 0 + genMagicNumber(); DBG("\n"); DBG("\n"); +#endif DRW_DBG("Encripted Header Data=\n"); duint8 byteStr[0x6C]; int size =0x6C; diff --git a/src/intern/dwgreader18.h b/src/intern/dwgreader18.h index 50ab674..fb6dc43 100644 --- a/src/intern/dwgreader18.h +++ b/src/intern/dwgreader18.h @@ -81,7 +81,10 @@ class dwgReader18 : public dwgReader { duint64 uncompSize; private: +#if 0 void genMagicNumber(); +#endif + // dwgBuffer* bufObj; void parseSysPage(duint8 *decompSec, duint32 decompSize); //called: Section page map: 0x41630e3b bool parseDataPage(const dwgSectionInfo &si/*, duint8 *dData*/); //called ???: Section map: 0x4163003b From f389dc056d0d907bde58f3d2b0eb53d9664a08f2 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:30:26 +1000 Subject: [PATCH 09/19] Don't error on warning category for now --- scripts/cppcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 509ea84..7f2f33c 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -42,7 +42,7 @@ ret_code=0 cat ${LOG_FILE} | grep -v -e "syntaxError," -e "cppcheckError," > ${LOG_FILE}.tmp mv ${LOG_FILE}.tmp ${LOG_FILE} -for category in "style" "performance" "portability"; do +for category in "style" "performance" "portability" "warning"; do if grep "${category}," ${LOG_FILE} >/dev/null; then echo "INFO: Issues in '${category}' category found, but not considered as making script to fail:" grep "${category}," ${LOG_FILE} | grep -v -e "clarifyCalculation," -e "duplicateExpressionTernary," -e "redundantCondition," -e "unusedPrivateFunction," -e "postfixOperator," @@ -57,7 +57,7 @@ else UNUSED_PRIVATE_FUNCTION="unusedPrivateFunction" fi -for category in "error" "warning" "clarifyCalculation" "duplicateExpressionTernary" "redundantCondition" "postfixOperator" "${UNUSED_PRIVATE_FUNCTION}"; do +for category in "error" "clarifyCalculation" "duplicateExpressionTernary" "redundantCondition" "postfixOperator" "${UNUSED_PRIVATE_FUNCTION}"; do if test "${category}" != ""; then if grep "${category}," ${LOG_FILE} >/dev/null; then echo "ERROR: Issues in '${category}' category found:" From 458ae32f5ef2a9a9d4886b014381aa7f5237e5a1 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:32:59 +1000 Subject: [PATCH 10/19] Fix cpp check ubuntu versions --- .github/workflows/code_checks.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index d74a03d..b327e21 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -8,8 +8,8 @@ on: jobs: - cppcheck_1604: - runs-on: ubuntu-16.04 + cppcheck_18_04: + runs-on: ubuntu-18.04 if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Checkout @@ -38,3 +38,17 @@ jobs: - name: Run cppcheck test run: ./scripts/cppcheck.sh + cppcheck_latest: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Requirements + run: | + sudo apt update + sudo apt install -y cppcheck + + - name: Run cppcheck test + run: ./scripts/cppcheck.sh From 14ef86af14f781ebb3408fb95361ac5db1a4f870 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:37:59 +1000 Subject: [PATCH 11/19] cppcheck on 18.04 never finishes --- .github/workflows/code_checks.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index b327e21..3cebab2 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -8,21 +8,6 @@ on: jobs: - cppcheck_18_04: - runs-on: ubuntu-18.04 - if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Requirements - run: | - sudo apt update - sudo apt install -y cppcheck - - - name: Run cppcheck test - run: ./scripts/cppcheck.sh - cppcheck_2004: runs-on: ubuntu-20.04 if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" From e23273fc79e921e5d9eaaf8d295f8a078bc206bc Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:51:07 +1000 Subject: [PATCH 12/19] Try porting proj's mac build workflow --- .github/workflows/mac.yml | 42 +++++++++++++++++++++++++ .github/workflows/mac/before_install.sh | 11 +++++++ .github/workflows/mac/install.sh | 21 +++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 .github/workflows/mac.yml create mode 100644 .github/workflows/mac/before_install.sh create mode 100644 .github/workflows/mac/install.sh diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml new file mode 100644 index 0000000..96d76f8 --- /dev/null +++ b/.github/workflows/mac.yml @@ -0,0 +1,42 @@ +name: MacOS build + +on: + push: + pull_request: + branches: + - master + +jobs: + macos_build: + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: conda-incubator/setup-miniconda@v2 + with: + channels: conda-forge + auto-update-conda: true + + - name: Cache + uses: actions/cache@v2 + id: cache + with: + path: ~/.ccache + key: ${{ runner.os }}-cache-mac-${{ github.run_id }} + restore-keys: ${{ runner.os }}-cache-mac- + + - name: Install Requirements + shell: bash -l {0} + run: | + source .github/workflows/mac/before_install.sh + + - name: Build + shell: bash -l {0} + run: | + source .github/workflows/mac/install.sh + env: + TRAVIS_OS_NAME: osx + BUILD_NAME: osx + diff --git a/.github/workflows/mac/before_install.sh b/.github/workflows/mac/before_install.sh new file mode 100644 index 0000000..6b23d11 --- /dev/null +++ b/.github/workflows/mac/before_install.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + + +conda update -n base -c defaults conda +conda install compilers -y + +conda config --set channel_priority strict +conda install --yes --quiet libtool ccache -y + diff --git a/.github/workflows/mac/install.sh b/.github/workflows/mac/install.sh new file mode 100644 index 0000000..1d83e10 --- /dev/null +++ b/.github/workflows/mac/install.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +export CCACHE_CPP2=yes +export PROJ_DB_CACHE_DIR="$HOME/.ccache" + +ccache -M 200M +ccache -s + +export CC="ccache clang" +export CXX="ccache clang++" +export CFLAGS="-Werror -O2" +export CXXFLAGS="-Werror -O2" + +mkdir -p build +cd build +cmake .. +make + +ccache -s From 865a1eebbd6873db7ee732185bf0ddd648fad738 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 10:58:09 +1000 Subject: [PATCH 13/19] Try using ninja build --- .github/workflows/mac/before_install.sh | 2 +- .github/workflows/mac/install.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mac/before_install.sh b/.github/workflows/mac/before_install.sh index 6b23d11..369e732 100644 --- a/.github/workflows/mac/before_install.sh +++ b/.github/workflows/mac/before_install.sh @@ -7,5 +7,5 @@ conda update -n base -c defaults conda conda install compilers -y conda config --set channel_priority strict -conda install --yes --quiet libtool ccache -y +conda install --yes --quiet libtool ccache ninja -y diff --git a/.github/workflows/mac/install.sh b/.github/workflows/mac/install.sh index 1d83e10..87edbf9 100644 --- a/.github/workflows/mac/install.sh +++ b/.github/workflows/mac/install.sh @@ -15,7 +15,7 @@ export CXXFLAGS="-Werror -O2" mkdir -p build cd build -cmake .. -make +cmake -GNinja .. +ninja ccache -s From 14c004afbc41a0ceb2ce17509566ac9f2d9d2d96 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 11:08:00 +1000 Subject: [PATCH 14/19] Clang static analyzer build (port from proj) --- .github/workflows/clang_static_analyzer.yml | 15 ++++++ .../workflows/clang_static_analyzer/start.sh | 47 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/clang_static_analyzer.yml create mode 100644 .github/workflows/clang_static_analyzer/start.sh diff --git a/.github/workflows/clang_static_analyzer.yml b/.github/workflows/clang_static_analyzer.yml new file mode 100644 index 0000000..9751fec --- /dev/null +++ b/.github/workflows/clang_static_analyzer.yml @@ -0,0 +1,15 @@ +name: CLang Static Analyzer + +on: [push, pull_request] + +jobs: + + clang_static_analyzer: + runs-on: ubuntu-18.04 + if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run + run: .github/workflows/clang_static_analyzer/start.sh diff --git a/.github/workflows/clang_static_analyzer/start.sh b/.github/workflows/clang_static_analyzer/start.sh new file mode 100644 index 0000000..f39f67b --- /dev/null +++ b/.github/workflows/clang_static_analyzer/start.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +sudo apt update + +DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ + autoconf automake libtool g++ make jq + +CLANG_LLVM=clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04 +wget -nv https://releases.llvm.org/9.0.0/$CLANG_LLVM.tar.xz +tar xJf $CLANG_LLVM.tar.xz +mv $CLANG_LLVM clang+llvm-9 + +# prepare build files +mkdir -p build +cd build + +NPROC=$(nproc) +echo "NPROC=${NPROC}" +export MAKEFLAGS="-j ${NPROC}" + +export PATH=$PWD/clang+llvm-9/bin:$PATH +CXXFLAGS="-std=c++11" scan-build -o scanbuildoutput -plist -v cmake .. +rm -rf scanbuildoutput +TOPDIR=$PWD +scan-build -o $TOPDIR/scanbuildoutput -sarif -v -enable-checker alpha.unix.cstring.OutOfBounds,alpha.unix.cstring.BufferOverlap,optin.cplusplus.VirtualCall,optin.cplusplus.UninitializedObject make + +rm -f filtered_scanbuild.txt +files=$(find scanbuildoutput -name "*.sarif") +for f in $files; do + jq '.runs[].results[] | (if .locations[].physicalLocation.fileLocation.uri | (contains("_generated_parser") ) then empty else { "uri": .locations[].physicalLocation.fileLocation.uri, "msg": .message.text, "location": .codeFlows[-1].threadFlows[-1].locations[-1] } end)' < $f > tmp.txt + if [ -s tmp.txt ]; then + echo "Errors from $f: " + cat $f + echo "" + cat tmp.txt >> filtered_scanbuild.txt + fi +done +if [ -s filtered_scanbuild.txt ]; then + echo "" + echo "" + echo "========================" + echo "Summary of errors found:" + cat filtered_scanbuild.txt + /bin/false +fi From 0e097db79f606fc5cc2b4738c2c9f2033cd21aac Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 11:09:02 +1000 Subject: [PATCH 15/19] Fix permission --- .github/workflows/clang_static_analyzer/start.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/workflows/clang_static_analyzer/start.sh diff --git a/.github/workflows/clang_static_analyzer/start.sh b/.github/workflows/clang_static_analyzer/start.sh old mode 100644 new mode 100755 From 1210cf62fa43ce0929b21b0d9129a27e9cd9a5a8 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 11:11:41 +1000 Subject: [PATCH 16/19] Fix path --- .github/workflows/clang_static_analyzer/start.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/clang_static_analyzer/start.sh b/.github/workflows/clang_static_analyzer/start.sh index f39f67b..2537c16 100755 --- a/.github/workflows/clang_static_analyzer/start.sh +++ b/.github/workflows/clang_static_analyzer/start.sh @@ -12,6 +12,8 @@ wget -nv https://releases.llvm.org/9.0.0/$CLANG_LLVM.tar.xz tar xJf $CLANG_LLVM.tar.xz mv $CLANG_LLVM clang+llvm-9 +export PATH=$PWD/clang+llvm-9/bin:$PATH + # prepare build files mkdir -p build cd build @@ -20,7 +22,6 @@ NPROC=$(nproc) echo "NPROC=${NPROC}" export MAKEFLAGS="-j ${NPROC}" -export PATH=$PWD/clang+llvm-9/bin:$PATH CXXFLAGS="-std=c++11" scan-build -o scanbuildoutput -plist -v cmake .. rm -rf scanbuildoutput TOPDIR=$PWD From 362279f02e4fb840d032d3b206e18d90cdf54598 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 11:15:56 +1000 Subject: [PATCH 17/19] Try using more recent clang tools --- .github/workflows/clang_static_analyzer.yml | 2 +- .github/workflows/clang_static_analyzer/start.sh | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/clang_static_analyzer.yml b/.github/workflows/clang_static_analyzer.yml index 9751fec..4ed03df 100644 --- a/.github/workflows/clang_static_analyzer.yml +++ b/.github/workflows/clang_static_analyzer.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: clang_static_analyzer: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Checkout diff --git a/.github/workflows/clang_static_analyzer/start.sh b/.github/workflows/clang_static_analyzer/start.sh index 2537c16..33419b9 100755 --- a/.github/workflows/clang_static_analyzer/start.sh +++ b/.github/workflows/clang_static_analyzer/start.sh @@ -5,14 +5,7 @@ set -e sudo apt update DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ - autoconf automake libtool g++ make jq - -CLANG_LLVM=clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04 -wget -nv https://releases.llvm.org/9.0.0/$CLANG_LLVM.tar.xz -tar xJf $CLANG_LLVM.tar.xz -mv $CLANG_LLVM clang+llvm-9 - -export PATH=$PWD/clang+llvm-9/bin:$PATH + libtool g++ make jq clang-tools # prepare build files mkdir -p build From ebfd3790344ff52c2aef7cefaf755e6240f28e5e Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 11:23:57 +1000 Subject: [PATCH 18/19] Fix clang value is never read, uninitialized field warnings --- src/drw_header.cpp | 5 ++--- src/intern/dwgreader.cpp | 1 + src/intern/dwgreader.h | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drw_header.cpp b/src/drw_header.cpp index 0081725..8b8d65f 100644 --- a/src/drw_header.cpp +++ b/src/drw_header.cpp @@ -2400,9 +2400,8 @@ bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf } //temporary code to show header end sentinel - duint64 sz= buf->size()-1; if (version < DRW::AC1018) {//pre 2004 - sz= buf->size()-16; + const duint64 sz= buf->size()-16; buf->setPosition(sz); DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition()); DRW_DBG("\ndwg header end sentinel= "); @@ -2419,7 +2418,7 @@ bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf DRW_DBGH(buf->getRawChar8()); DRW_DBG(" "); } } else if (version == DRW::AC1021) {//2007 - sz= buf->size()-16; + const duint64 sz= buf->size()-16; buf->setPosition(sz); DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition()); DRW_DBG("\ndwg header end sentinel= "); diff --git a/src/intern/dwgreader.cpp b/src/intern/dwgreader.cpp index 05aa819..73c0e9c 100644 --- a/src/intern/dwgreader.cpp +++ b/src/intern/dwgreader.cpp @@ -710,6 +710,7 @@ bool dwgReader::readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf) { ret = false; } else { //reset position buff.resetPosition(); + (void)bs; /* RLZ: writeme ret2 = vpEntHeader.parseDwg(version, &buff, bs); if(ret) ret = ret2;*/ diff --git a/src/intern/dwgreader.h b/src/intern/dwgreader.h index 91aebc9..2d62b6f 100644 --- a/src/intern/dwgreader.h +++ b/src/intern/dwgreader.h @@ -60,13 +60,13 @@ class dwgPageInfo { dwgPageInfo(duint64 i, duint64 ad, duint32 sz){ Id=i; address=ad; size=sz; } - duint64 Id; - duint64 address; //in file stream, for rd18, rd21 - duint64 size; //in file stream, for rd18, rd21 - duint64 dataSize; //for rd18, rd21 - duint32 startOffset; //for rd18, rd21 - duint64 cSize; //compresed page size, for rd21 - duint64 uSize; //uncompresed page size, for rd21 + duint64 Id{0}; + duint64 address{0}; //in file stream, for rd18, rd21 + duint64 size{0}; //in file stream, for rd18, rd21 + duint64 dataSize{0}; //for rd18, rd21 + duint32 startOffset{0}; //for rd18, rd21 + duint64 cSize{0}; //compressed page size, for rd21 + duint64 uSize{0}; //uncompressed page size, for rd21 }; // sections of file From 61f2fb9992231b725cd6d5bc7d1bd539ac86d679 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 13 Aug 2021 11:24:06 +1000 Subject: [PATCH 19/19] Fix memory leak --- src/intern/dwgreader21.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intern/dwgreader21.cpp b/src/intern/dwgreader21.cpp index 6d8af23..bf6ff6a 100644 --- a/src/intern/dwgreader21.cpp +++ b/src/intern/dwgreader21.cpp @@ -260,8 +260,10 @@ bool dwgReader21::readFileHeader() { duint8 *SectionsMapData = new duint8[SectionsMapSizeUncompressed]; dwgPageInfo sectionMap = sectionPageMapTmp[SectionsMapId]; ret = parseSysPage(SectionsMapSizeCompressed, SectionsMapSizeUncompressed, SectionsMapCorrectionFactor, sectionMap.address, SectionsMapData); - if (!ret) + if (!ret) { + delete[]SectionsMapData; return false; + } //reads sections: //Note: compressed value are not stored in file then, commpresed field are use to store