Commit e3a3aff
authored
Add include/cppcheck linting and extend strict warnings to every build (#81)
Introduces two new whole-repo static analysis passes, applies the strict
first-party warning set to every build that compiles our own code (not
just host), fixes what those turned up, and hardens the release
workflows.
New lint tooling
- `script/check-includes.sh` + `check_includes.py`: an
include-what-you-use pass over `src/`, `include/`, `tests/`,
`host_examples/`, and `examples/`, built on clang-include-cleaner. Files
with guarded ESP branches are analyzed twice: a host pass, and an ESP
pass with `-DESP_PLATFORM` against stub headers materialized from
`script/esp_stubs.py`, so ESP-only code paths are checked without a
cross toolchain. A .cpp may still rely on its matching .h's includes.
Supports `--fix` for unused-include removal.
- `script/cppcheck.sh`: whole-program cppcheck (warning, style,
unusedFunction) over first-party sources. It sees every caller in a
single pass, so it can flag functions that are dead beyond the public
API surface.
- `clang-tidy.sh` now passes `--warnings-as-errors='*'` so findings fail
CI even if `.clang-tidy` ever loses its WarningsAsErrors line.
- Both new checks run as CI jobs and are required by the merge gate.
`cppcheck` is pinned to 2.21.0 and built from source (cached) because
the distro package lags several minor versions and reports differently
than the version developers run locally.
Warning flags
- Extracted the wrapper warning set into `opus_wrapper_warning_flags()`
and applied it to the ESP-IDF component build as well as host. ESP-only
code paths (`#ifdef ESP_PLATFORM` branches, Xtensa sources) previously
compiled under strict warnings nowhere, since the host build never sees
them.
- Added `-Wmissing-prototypes`/`-Wmissing-declarations` and
`-Wold-style-cast` to the set, and applied the same flags to test
sources and `host_examples`.
- `-Werror` stays gated behind `ENABLE_WERROR` (default off), so
consumers building these source-distributed files with an arbitrary
toolchain get warnings only. CI turns it on for the host sanitizer build
and for both PlatformIO example builds, which act as the pinned ESP
gate.
Fixes for the newly enabled warnings
- Replaced C-style casts with `static_cast` across `src/`, tests, and
the benchmark examples. The end-trim arithmetic now stays in 64-bit
rather than narrowing early: the value derives from an untrusted granule
position and can exceed `SIZE_MAX` on 32-bit targets.
- Wrapped `OPUS_SET_GAIN`/`OPUS_SET_BITRATE` call sites in diagnostic
pragmas -- the C-style cast is inside the vendored libopus macro and
can't be fixed at the call site.
- Made file-local helpers in `opus_to_wav` static, added its missing
`<cstdint>`, and zero-initialized `EncodeResult` so the early
error-return path returns defined fields.
- Annotated the public accessors whose only callers are downstream
consumers, which cppcheck's unusedFunction cannot see.
API
- `decode()` and `conceal_loss()` on both decoders are now
[[nodiscard]], with a `warn_unused_result` fallback below C++17. These
report errors only through their return code, so ignoring it silently
loses failures.
- `OggOpusDecoder'`s constructor is now explicit.
- `ogg_opus_decoder.h` uses `<cstddef>`/`<cstdint>` instead of the C
headers.
Release and CI workflows
- release-drafter authenticates through a GitHub App token instead of
`GITHUB_TOKEN` plus a deploy key; the workflow's default token is now
granted no permissions at all.
- `publish.yml`: added a timeout to every job and re-granted contents:
read to the Espressif job, whose job-level permissions block had
replaced the workflow default that checkout relies on.
- Fixed the PlatformIO cache key: the nested expression inside
hashFiles() was passed as a literal string, so the key never varied by
example and never matched a real file.
- Dependabot PRs now carry `dependencies`/`github-actions` labels, and
the release-drafter version-resolver labels are
`force-major`/`force-minor` to avoid colliding with ordinary triage
labels.1 parent 5c9fbb5 commit e3a3aff
29 files changed
Lines changed: 1479 additions & 66 deletions
File tree
- .github
- workflows
- cmake
- examples
- decode_benchmark
- src
- encode_benchmark
- src
- host_examples/opus_to_wav
- include/micro_opus
- script
- src
- tests
- support
- tools
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
68 | 132 | | |
69 | 133 | | |
70 | 134 | | |
| |||
133 | 197 | | |
134 | 198 | | |
135 | 199 | | |
136 | | - | |
| 200 | + | |
137 | 201 | | |
138 | 202 | | |
139 | 203 | | |
| |||
339 | 403 | | |
340 | 404 | | |
341 | 405 | | |
342 | | - | |
| 406 | + | |
343 | 407 | | |
344 | 408 | | |
345 | 409 | | |
| |||
358 | 422 | | |
359 | 423 | | |
360 | 424 | | |
| 425 | + | |
| 426 | + | |
361 | 427 | | |
362 | 428 | | |
363 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
61 | 64 | | |
| 65 | + | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
| |||
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | | - | |
83 | 87 | | |
| 88 | + | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | | - | |
87 | 92 | | |
| 93 | + | |
| 94 | + | |
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
21 | | - | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | | - | |
| 33 | + | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
98 | 118 | | |
99 | 119 | | |
100 | 120 | | |
| |||
148 | 168 | | |
149 | 169 | | |
150 | 170 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
155 | 174 | | |
156 | 175 | | |
157 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
30 | 61 | | |
31 | 62 | | |
32 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
0 commit comments