Repository navigation
Conversation
26 of 42 tasks
v0lumehi
force-pushed
the
ci-lint-c
branch
5 times, most recently
from
October 28, 2026 09:07
172342b to
ef68571
Compare
… report Add .github/workflows/lint-c.yml and dm/tools/lint_c.py for dm/host and dm/gfx (roadmap seedds#313). compdb builds a compile database from dry runs of the Makefiles (host, host tests, gfx tests, texture tests, Metal sample; 166 sources). tidy runs clang-tidy with the bug-finding checks of .clang-tidy and clang's static analyzer and counts findings per file and check against dm/tools/lint_c_baseline.tsv: more fail, fewer ask for a refresh. format runs clang-format (.clang-format) on the changed lines and reports spacing changes in the job summary without failing. Checks that mostly flag deliberate idioms are left out with a reason in .clang-tidy (signed bitwise operations alone were 1,799 of 2,464 findings), CERT aliases are not listed twice, and `if (!strcmp(...))` is allowed. The baseline holds 213 findings in 107 file/check pairs. The job runs on xcode-27 with Xcode 27.1 and LLVM 23.1.4's release archive (sha256-checked; clang-tidy, clang-format and clang's headers unpacked), in about five minutes. test_lint_c.py covers the baseline and ratchet, the compile database's dedupe, clang-tidy's output and the format line filter, and keeps the workflow's LLVM and the baseline's in step. Validation: compdb 0.4 s, tidy 73 s at -j8 (213 findings, 0 above or below the baseline), format 0.1 s; a probe null dereference fails tidy and a lowered count only prints a notice. 371 tool tests pass, docs test passes, lint_python reports 0 new.
seedds
added a commit
that referenced
this pull request
Oct 30, 2026
…(PR #425) .clang-tidy runs the bugprone checks and clang's static analyzer (core, unix, osx, nullability, two security checks) over dm/host and dm/gfx, with each excluded check's reason on its line. dm/tools/lint_c.py builds a compile database from the Makefiles' dry runs (196 sources) and counts findings per file and check against dm/tools/lint_c_baseline.tsv (273 findings in 140 pairs, LLVM 23.1.4, current main). The lint-c workflow downloads that LLVM release (sha256 pinned) on xcode-27. The ratchet works like lint_python.py's: a new finding fails (fix it, or // NOLINT a false positive with a reason), so does a fixed one still listed (tidy --update only shrinks), and a pull request's baseline may not grow over its base's (--against), unless LLVM_VERSION was raised (--rebaseline). Left out of the PR: the clang-format report. .clang-format cannot state the house style (one statement per line), and a root .clang-format would let editors' format-on-save and git clang-format rewrite dense lines. Co-authored-by: v0lumehi <[email protected]>
Owner
|
Thank you! This landed on
Working the baseline down stays with #313. |
Know-It-All-Brother
pushed a commit
to Know-It-All-Brother/nxnative
that referenced
this pull request
Nov 9, 2026
…(PR seedds#425) .clang-tidy runs the bugprone checks and clang's static analyzer (core, unix, osx, nullability, two security checks) over dm/host and dm/gfx, with each excluded check's reason on its line. dm/tools/lint_c.py builds a compile database from the Makefiles' dry runs (196 sources) and counts findings per file and check against dm/tools/lint_c_baseline.tsv (273 findings in 140 pairs, LLVM 23.1.4, current main). The lint-c workflow downloads that LLVM release (sha256 pinned) on xcode-27. The ratchet works like lint_python.py's: a new finding fails (fix it, or // NOLINT a false positive with a reason), so does a fixed one still listed (tidy --update only shrinks), and a pull request's baseline may not grow over its base's (--against), unless LLVM_VERSION was raised (--rebaseline). Left out of the PR: the clang-format report. .clang-format cannot state the house style (one statement per line), and a root .clang-format would let editors' format-on-save and git clang-format rewrite dense lines. Co-authored-by: v0lumehi <[email protected]>
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.
Update (Oct 28): rebased on
main2f1a044. Code that landed since (the capture and replay tests,hle_sdk16.c,t_fpslock.cand others) brought new findings in 11 file/check pairs; the baseline is refreshed withtidy --updateand now holds 244 findings in 127 file/check pairs across 69 files. None of them is fixed here; they are for the "work the baselines down" step of #313.Update: rebased on
main81d53bf. Your fixes for #424 (18d65b3) took four findings out, and the ratchet saw them as four file/check pairs below the baseline (for examplehle_hid.ccore.BitwiseShift2 → 0). The baseline is refreshed withtidy --updateand now holds 208 findings (213 − 5; one fix removed two).Result: the first CI run is green in every job. The lint job took 2m54s on
xcode-27: LLVM 23.1.4 from the pinned tarball (sha256 checked),compdbfound the same 166 sources as locally, andtidygave213 findings in 55 files, 107 file/check pairs, matching the baseline exactly (0 above, 0 below).formatreported 0 changed C lines, since this PR changes none.Part of #313 ("Code quality checks in CI": clang-tidy, plus clang-format on changed lines only). Uses the same runner setup as #421 (
xcode-27, Xcode 27.1).Problem
Python has a lint ratchet (#323), but the C and Objective-C host and NVN layer (most of the code) has none. clang's static analyzer finds null dereferences, use-after-free, leaks and uninitialized reads that a review of a 10,000-line file misses.
Change
.clang-tidy: checks that find bugs, not style:bugprone-*, the analyzer'score,unix,osxandnullabilitygroups,security.ArrayBound/FloatLoopCounter,misc-redundant-expression,misc-misplaced-const.bugprone-signed-bitwisewas 1,799 of the first run's 2,464 findings (deliberate bit masking onints); uncheckedatoi/sscanf(133) is deliberate forDM_*switches and profile tables.dm/tools/lint_c.py:compdbbuilds a compile database frommake -n -Bdry runs of the host, the tests and the gfx tests (166 sources).tidyruns clang-tidy and compares per-file / per-check counts withdm/tools/lint_c_baseline.tsv: 213 findings in 107 pairs. Counts don't include line numbers, so moving code doesn't change them. Growth fails with the finding annotated on its line; shrinking asks for--update.formatrunsgit clang-formaton the lines a PR changes and reports spacing differences in the job summary. Report only, and existing code is never reformatted..github/workflows/lint-c.yml:xcode-27/ Xcode 27.1, only when C / Objective-C sources, Makefiles or the lint files change;contents: read;dm/tools/tests/test_lint_c.py: 19 tests for the pure logic (baseline parsing and comparison, compdb dedupe, the format line filter, the LLVM version matching the baseline's). No LLVM needed.docs/development.md(Continuous integration),06-dev-loop.md§7.What it found
Most findings in the baseline are false positives that depend on invariants the analyzer can't see, or
reallocfailures that only matter when memory runs out. Four look like real (small) bugs; I filed them together as #424:DM_NVN_PASSDUMP).Each fix takes its baseline entry with it.
Checked
lint_c.py compdblint_c.py tidy -j 8onmain1963fab213 findings; 0 file/check pairs above it, 0 below it, 79 s on 8 coreshle_os.c::erroron its line, exit 1::notice … refresh it, exit 0lint_c.py formatover 30 recent commitstest_docs, Python lint ratchetNot yet run on GitHub: this PR's own CI run is the first. I'd expect about 5 minutes on the runner's 3 cores.