From 57f360ba21ab7861814d2472cce1b44536db81b8 Mon Sep 17 00:00:00 2001 From: "Gabriele N. Tornetta" Date: Sun, 4 Jun 2023 12:46:58 +0100 Subject: [PATCH] ci(checks): build cppcheck from sources The version of cppcheck available from the package manager tends to be outdated. In this change we build from sources instead. We cache the build result for faster execution. --- .github/workflows/checks.yml | 40 +++++++++++++++++++++++++++++++++--- src/mac/py_proc.h | 2 +- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e841f3ea..8fc2524d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -34,16 +34,50 @@ jobs: cppcheck: runs-on: ubuntu-20.04 name: Static code analysis + env: + cppcheck-version: 2.10.3 + steps: - uses: actions/checkout@v2 - - name: Install cppcheck + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get -y install libpcre3-dev + + - name: Restore cppcheck build + id: cppcheck-build-restore + uses: actions/cache/restore@v3 + with: + path: | + ${{ github.workspace }}/cppcheck + key: ${{ runner.os }}-cppcheck-${{ env.cppcheck-version }} + + - name: Check out cppcheck + uses: actions/checkout@v2 + with: + repository: danmar/cppcheck + ref: ${{ env.cppcheck-version }} + path: ${{ github.workspace }}/cppcheck + + - name: Compile cppcheck run: | sudo apt-get update - sudo apt-get -y install cppcheck + sudo apt-get -y install libpcre3-dev + cd cppcheck + make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" + cd - + + - name: Save cppcheck build + id: cppcheck-build-save + uses: actions/cache/save@v3 + with: + path: | + ${{ github.workspace }}/cppcheck + key: ${{ runner.os }}-cppcheck-${{ env.cppcheck-version }} - name: Check soure code - run: cppcheck -q -f --error-exitcode=1 --inline-suppr src + run: ${{ github.workspace }}/cppcheck/cppcheck -q -f --error-exitcode=1 --inline-suppr src codespell: runs-on: ubuntu-20.04 diff --git a/src/mac/py_proc.h b/src/mac/py_proc.h index 7ba7402b..f235c9e0 100644 --- a/src/mac/py_proc.h +++ b/src/mac/py_proc.h @@ -653,7 +653,7 @@ _py_proc__get_resident_memory(py_proc_t * self) { mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT; return task_info( - self->proc_ref, MACH_TASK_BASIC_INFO, (task_info_t) &info, &count + self->proc_ref, MACH_TASK_BASIC_INFO, (task_info_t) &info, &count // cppcheck-suppress [uninitvar] ) == KERN_SUCCESS ? info.resident_size : -1;