From d1570e88154d06e26ec073076f226263bfcb03ab Mon Sep 17 00:00:00 2001 From: ak2k <19240940+ak2k@users.noreply.github.com> Date: Mon, 22 Jun 2026 11:52:54 -0400 Subject: [PATCH] fix(ci): make cppcheck gate robust to cppcheck 2.21 + bump flake.lock 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. --- flake.lock | 12 ++++++------ flake.nix | 7 +++++++ src/beacon_logic.hpp | 12 ++++++------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index 049e276..af85ee8 100644 --- a/flake.lock +++ b/flake.lock @@ -59,11 +59,11 @@ ] }, "locked": { - "lastModified": 1775585728, - "narHash": "sha256-8Psjt+TWvE4thRKktJsXfR6PA/fWWsZ04DVaY6PUhr4=", + "lastModified": 1781733627, + "narHash": "sha256-U3yTuGBnmXvXoQI3qkpfEDsn9RovQPAjN7ndRco+3u0=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "580633fa3fe5fc0379905986543fd7495481913d", + "rev": "3bbec39bc90eadfa031e6f3b77272f3f60803e39", "type": "github" }, "original": { @@ -147,11 +147,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1776329215, - "narHash": "sha256-a8BYi3mzoJ/AcJP8UldOx8emoPRLeWqALZWu4ZvjPXw=", + "lastModified": 1781607440, + "narHash": "sha256-rxO+uc/KFbSJp+pgyXRuAX6QlG9hJdnt0BXpEQRXY+U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b86751bc4085f48661017fa226dee99fab6c651b", + "rev": "3e41b24abd260e8f71dbe2f5737d24122f972158", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a333dcb..8ff7b7d 100644 --- a/flake.nix +++ b/flake.nix @@ -606,10 +606,17 @@ runtimeInputs = [ pkgs.cppcheck ]; text = '' cd "''${1:-.}" + # zephyr_hardware.cpp gates the battery-check ADC code on Zephyr + # devicetree macros (DT_NODE_EXISTS/DT_PATH/DT_NODE_HAS_PROP) in a + # #if. Standalone cppcheck has no DT headers to expand them; + # cppcheck >= 2.21 hard-errors (syntaxError) on the unevaluatable + # condition where older versions assumed 0. Real syntax is checked + # by the Zephyr compiler in the smoke-build gate. cppcheck --enable=warning,performance,portability \ --std=c++20 --error-exitcode=1 --force \ --suppress=missingIncludeSystem \ --suppress=normalCheckLevelMaxBranches \ + --suppress=syntaxError:src/zephyr_hardware.cpp \ src/*.cpp src/*.hpp ''; }; diff --git a/src/beacon_logic.hpp b/src/beacon_logic.hpp index a6cb471..de5b5b3 100644 --- a/src/beacon_logic.hpp +++ b/src/beacon_logic.hpp @@ -24,12 +24,12 @@ bool is_key_empty(const uint8_t* key, size_t len); /// Input to the status computation (replaces all globals). struct StatusInput { - StatusFlags status; // Decoded status configuration - uint16_t battery_voltage; // Battery voltage in millivolts (e.g. 3800 = 3.8V) - uint16_t keys_changes; // Rolling counter of AirTag key rotations (used by mode 2) - uint8_t what_in_status; // Telemetry cycle selector: 0=voltage, 1=accel, 2=temperature - uint8_t accel_byte; // 7-bit movement summary from MovementTracker::compute_accel_byte() - int16_t temperature; // Accelerometer die temperature in 0.1C units (e.g. 235 = 23.5C) + StatusFlags status; // Decoded status configuration + uint16_t battery_voltage = 0; // Battery voltage in millivolts (e.g. 3800 = 3.8V) + uint16_t keys_changes = 0; // Rolling counter of AirTag key rotations (used by mode 2) + uint8_t what_in_status = 0; // Telemetry cycle selector: 0=voltage, 1=accel, 2=temperature + uint8_t accel_byte = 0; // 7-bit movement summary from MovementTracker::compute_accel_byte() + int16_t temperature = 0; // Accelerometer die temperature in 0.1C units (e.g. 235 = 23.5C) }; /// Output of the status computation.