Skip to content

Commit

Permalink
Merge pull request #395 from fangerer/fa/cppcheck
Browse files Browse the repository at this point in the history
Fix and re-enable cppcheck
  • Loading branch information
mattip authored Mar 4, 2023
2 parents 0c78f9f + 30e5292 commit 6b54518
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,8 @@ jobs:
cpp_check:
name: Cppcheck static analysis
runs-on: 'ubuntu-20.04'
runs-on: 'ubuntu-22.04'
continue-on-error: true
# Skip it, see issue gh-188
if: false
steps:
- uses: actions/checkout@v3

Expand All @@ -355,7 +353,7 @@ jobs:
python-version: '3.10'

- name: Install Cppcheck
run: sudo apt-get -qq -y install cppcheck
run: sudo apt-get -qq -y install cppcheck=2.7-1

- name: Run Cppcheck
run: make cppcheck
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,37 @@ cppcheck-build-dir:
cppcheck: cppcheck-build-dir
# azure pipelines doesn't show stderr, so we write the errors to a file and cat it later :(
$(eval PYTHON_INC = $(shell python3 -q -c "from sysconfig import get_paths as gp; print(gp()['include'])"))
$(eval PYTHON_PLATINC = $(shell python3 -q -c "from sysconfig import get_paths as gp; print(gp()['platinclude'])"))
cppcheck --version
cppcheck \
-v \
--error-exitcode=1 \
--cppcheck-build-dir=$(or ${CPPCHECK_BUILD_DIR}, .cppcheck) \
--output-file=$(or ${CPPCHECK_BUILD_DIR}, .cppcheck)/output.txt \
--enable=warning,performance,portability,information,missingInclude \
--inline-suppr \
--suppress=allocaCalled \
-I /usr/local/include \
-I /usr/include \
--suppress=syntaxError \
-I /usr/local/include/ \
-I /usr/include/ \
-I ${PYTHON_INC} \
-I ${PYTHON_PLATINC} \
-I . \
-I hpy/devel/include/ \
-I hpy/devel/include/hpy/ \
-I hpy/devel/include/hpy/cpython/ \
-I hpy/devel/include/hpy/universal/ \
-I hpy/devel/include/hpy/runtime/ \
-I hpy/universal/src/ \
-I hpy/debug/src/ \
-I hpy/debug/src/include \
-I hpy/trace/src/ \
-I hpy/trace/src/include \
--force \
-D NULL=0 \
-D HPY_ABI_CPYTHON \
. || (cat $(or ${CPPCHECK_BUILD_DIR}, .cppcheck)/output.txt && false)
-D __linux__=1 \
-D __x86_64__=1 \
-D __LP64__=1 \
.

infer:
python3 setup.py build_ext -if -U NDEBUG | compiledb
Expand Down
5 changes: 0 additions & 5 deletions hpy/devel/src/runtime/ctx_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ ctx_Tracker_New(HPyContext *ctx, HPy_ssize_t capacity)
}
hp->capacity = capacity;
hp->length = 0;
// cppcheck thinks that hp->handles is a memory leak because we cast the
// pointer to an int (and thus the pointer is "lost" from its POV, I
// suppose). But it's not a real leak because we free it in
// ctx_Tracker_Close:
// cppcheck-suppress memleak
return _hp2ht(hp);
}

Expand Down

0 comments on commit 6b54518

Please sign in to comment.