Lint & CI: cppcheck, IWYU, cast/linkage warnings#17
Merged
Conversation
cppcheck's unusedFunction check sees every first-party source in one pass, so it can flag functions with no caller anywhere in the project, which the per-TU clang-tidy pass cannot. Fix its two findings in the benchmark example: default-initialize TaskParams members and replace a C-style cast from void* with static_cast.
Add -Wmissing-prototypes (clang) / -Wmissing-declarations (GCC) to the first-party warning sets: any function not declared in a header must be static, which keeps -Wunused-function able to see dead internal functions. Mark the three vorbis_to_wav helpers it flagged static. Mark decode() MICRO_VORBIS_NODISCARD ([[nodiscard]] at C++17, GNU warn_unused_result at C++14) so silently ignoring the decoder's only error channel warns at every call site.
cppcheck's cstyleCast check only flags casts to pointer or reference types; the compiler flag catches value casts too. Convert the three (int32_t) bitrate casts in vorbis_header.cpp it found. The forked tremor include directory becomes SYSTEM so headers shared with the C sources don't leak their C-style casts into first-party compiles -- the header-side counterpart of the existing -w suppression.
script/check-includes.sh runs clang-include-cleaner over every source and header in two passes: a host pass, and an ESP pass with -DESP_PLATFORM plus stub ESP-IDF headers (materialized from script/esp_stubs.py) so guarded ESP32 branches are analyzed without a cross toolchain. A foo.cpp may rely on its matching header's direct includes; IWYU pragmas are honored. The forked src/tremor decoder and lib/micro-ogg-demuxer submodule are excluded, mirroring cppcheck. Fixes it surfaced: ogg_vorbis_decoder.cpp used ogg_int32_t via a transitive include (now includes <ogg/os_types.h>); decode_benchmark called esp_get_free_heap_size() without esp_system.h and was missing <cstdint>.
Bring the tooling in line with other microCodec projects.
- clang-tidy.sh: honor a pre-set $CLANG_TIDY (CI pins clang-tidy-18) instead
of unconditionally clobbering it, validate the binary up front, and pass
--warnings-as-errors='*' on both the main and tests passes.
- ci.yml lint job: export CLANG_TIDY=clang-tidy-18 so the pin takes effect.
- cppcheck.sh: scan the src directory instead of a hand-listed file set
(the src/tremor suppression already fences off the vendored fork).
- ci.yml cppcheck job: build a pinned cppcheck 2.21.0 from source with a
cache step, replacing the lagging apt package.
- check_includes.py: adopt the canonical gather_files(dirs, prune=()) engine.
- Bump stale action pins: cache v6.1.0, setup-python v6.3.0, drafter v7.5.1.
- release-drafter: force-major/force-minor labels and strict permissions: {}.
- .clang-tidy: label the header C++14 (matches the actual build standard in
cmake/host.cmake and the library's own C++14 baseline), not C++11.
- .gitignore: record .conventions-version as a local-only marker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tooling and static-analysis pass bringing the repo in line with the other microCodec projects. Adds whole-program and include analysis to CI, tightens the first-party warning set, and fixes the handful of findings each check surfaced. No decoder logic changes; the forked
src/tremorand demuxer submodule stay excluded from the new checks.script/cppcheck.sh+ CI job run unusedFunction across all first-party sources in one pass. Fixes its two findings in the benchmark example (default-init TaskParams, replace a C-stylevoid*cast).-Wmissing-prototypes/-Wmissing-declarationsso any non-header function must be static (keeps-Wunused-functioneffective); mark the three vorbis_to_wav helpers static. Markdecode()MICRO_VORBIS_NODISCARDso ignoring the decoder's only error channel warns at every call site.-Wold-style-cast: catches value casts cppcheck's cstyleCast misses; converts the three(int32_t)bitrate casts invorbis_header.cpp. The forked tremor include dir becomes SYSTEM so its C-style casts don't leak into first-party compiles.script/check-includes.shruns clang-include-cleaner over every source/header in a host pass and an ESP pass (with stub ESP-IDF headers fromesp_stubs.py) so guarded ESP32 branches are analyzed without a cross toolchain. Fixes a transitive-include reliance inogg_vorbis_decoder.cppand missing includes in the benchmark.$CLANG_TIDY(CI pins clang-tidy-18) and pass--warnings-as-errors; scan the whole src dir in cppcheck; build a pinned cppcheck 2.21.0 from source; adopt the canonicalgather_filesengine incheck_includes.py; bump stale action pins; label.clang-tidyas C++14.