Skip to content

fix(ci): make cppcheck gate robust to cppcheck 2.21 + bump flake.lock#22

Merged
ak2k merged 1 commit into
mainfrom
fix/cppcheck-2.21-gate
Jun 22, 2026
Merged

fix(ci): make cppcheck gate robust to cppcheck 2.21 + bump flake.lock#22
ak2k merged 1 commit into
mainfrom
fix/cppcheck-2.21-gate

Conversation

@ak2k

@ak2k ak2k commented Jun 22, 2026

Copy link
Copy Markdown
Owner

What

The nightly Update lockfiles job has been failing intermittently (Jun 1 ✗, Jun 8 ✓, Jun 15 ✗, Jun 22 ✗) because each run rolls a different nixpkgs, and recent revs ship cppcheck 2.21.0 (vs 2.18.3 on the current main lock). 2.21.0 changed two behaviours that trip the mockingbeacon-cppcheck test gate, so the auto-update PR never opens.

Reproduced exactly by pulling cppcheck 2.21.0 from the failing run's nixpkgs (3e41b24).

Two findings under cppcheck 2.21.0

  1. syntaxErrorsrc/zephyr_hardware.cpp:54 (false positive). 2.21 hard-errors when a #if invokes a function-like macro it can't expand. That line gates the battery-check ADC code on Zephyr devicetree macros (DT_NODE_EXISTS / DT_PATH / DT_NODE_HAS_PROP); standalone cppcheck has no DT headers, so it can't evaluate them. Older cppcheck assumed 0 and moved on. → suppress syntaxError for that one file. Real syntax is still validated by the Zephyr compiler in the smoke-build step.
  2. uninitMemberVarNoCtor ×5 — src/beacon_logic.hpp. 2.21 flags StatusInput's scalar members as uninitialised. → default member initializers (= 0); correct hygiene, zero behavioural change (callers overwrite).

Also

Bumps flake.lock (nixpkgs → 2026-06-16 / cppcheck 2.21.0, git-hooks → 2026-06-17) so the new toolchain lands and is validated in this PR rather than waiting on the next scheduled run.

west2nix.toml is intentionally untouched — that's the Zephyr/west side, refreshed separately by the scheduled job's own step.

Validation

nix build .#checks.default is green against the bumped lock: cppcheck (2.21.0) + clang-format + 317/317 host-test assertions.

The nightly lockfile-update job bumps nixpkgs, which moved cppcheck
2.18 -> 2.21. cppcheck 2.21 changed two behaviours that broke the test
gate (so the auto-update PR never opened):

- It now hard-errors (syntaxError) when a #if condition invokes a
  function-like macro it cannot expand. zephyr_hardware.cpp gates the
  battery-check ADC code on Zephyr devicetree macros (DT_NODE_EXISTS /
  DT_PATH / DT_NODE_HAS_PROP); standalone cppcheck has no DT headers, so
  it cannot evaluate them. Older cppcheck assumed 0 and moved on.
  Suppress syntaxError for that one file; real syntax is still validated
  by the Zephyr compiler in the smoke-build gate.

- It flags StatusInput's scalar members as uninitialised
  (uninitMemberVarNoCtor). Give them default member initializers, which
  is correct hygiene and zero behavioural change (callers overwrite).

Bump flake.lock (nixpkgs -> 2026-06-16, git-hooks -> 2026-06-17) so the
2.21 toolchain lands and is validated here. checks.default is green:
cppcheck + clang-format + 317/317 host tests.
@ak2k ak2k merged commit 6f30a92 into main Jun 22, 2026
32 of 34 checks passed
@ak2k ak2k deleted the fix/cppcheck-2.21-gate branch June 22, 2026 16:10
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.

1 participant