Skip to content

Add cppcheck static analysis for the NIF - #207

Merged
ausimian merged 2 commits into
mainfrom
claude/nif-static-analysis-tools-t3rmhg
Jul 20, 2026
Merged

Add cppcheck static analysis for the NIF#207
ausimian merged 2 commits into
mainfrom
claude/nif-static-analysis-tools-t3rmhg

Conversation

@ausimian

@ausimian ausimian commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Wire cppcheck over the C++ NIF sources in c_src/. Add a self-contained
make cppcheck target so developers can run it locally without a built
libmlx or the BEAM toolchain — it analyses only our own tree and
suppresses the third-party headers (<mlx/...>, <fine.hpp>, <erl_nif.h>)
it can't see. passedByValueCallback is suppressed because every NIF
entry point takes its container args by value by Fine's FINE_NIF
convention.

Add a macOS CI job that installs cppcheck via brew and runs the same
target, so the check gates PRs on the platform the NIF ships on.
Document make cppcheck under Local debugging in MAINTAINING.md.

Also value-initialize CompiledInstr::opcode: cppcheck's
uninitMemberVarNoCtor flags the scalar member as having no initializer
while its sibling containers self-init. Every real construction
aggregate-initializes all fields, so this was never a live bug, but
value-initializing keeps the check clean.

claude added 2 commits July 20, 2026 19:27
Wire cppcheck over the C++ NIF sources in c_src/. Add a self-contained
`make cppcheck` target so developers can run it locally without a built
libmlx or the BEAM toolchain — it analyses only our own tree and
suppresses the third-party headers (<mlx/...>, <fine.hpp>, <erl_nif.h>)
it can't see. `passedByValueCallback` is suppressed because every NIF
entry point takes its container args by value by Fine's FINE_NIF
convention.

Add a macOS CI job that installs cppcheck via brew and runs the same
target, so the check gates PRs on the platform the NIF ships on.
Document `make cppcheck` under Local debugging in MAINTAINING.md.
cppcheck (uninitMemberVarNoCtor) flags the scalar `opcode` member as
having no initializer while its sibling container members self-init.
Every real construction aggregate-initializes all fields, so this was
never a live bug, but value-initializing it gives a default-constructed
instr a defined opcode and keeps the check clean.

Surfaced by the brew cppcheck (2.21) in CI, which enables this check
where the older local 2.13 did not.
@ausimian
ausimian force-pushed the claude/nif-static-analysis-tools-t3rmhg branch from 158d675 to 752353b Compare July 20, 2026 19:27
@ausimian
ausimian merged commit 29b90ac into main Jul 20, 2026
4 checks passed
@ausimian
ausimian deleted the claude/nif-static-analysis-tools-t3rmhg branch July 20, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants