Skip to content

fix(lint): bring the cpu tidy lane back to its baseline - #1785

Merged
lusoris merged 1 commit into
masterfrom
fix/cpu-tidy-regressions
Oct 1, 2026
Merged

lusoris merged 1 commit into
masterfrom
fix/cpu-tidy-regressions

Conversation

@lusoris

@lusoris lusoris commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Bring the CPU clang-tidy lane back to its baseline of zero regressions.

The local merge train does not run the clang-tidy ratchet, and PRs landed on 2026-10-01 raised the CPU lane above its baseline by 13 findings across 5 files. All 13 findings have been resolved via refactoring without raising any baseline and without adding any uncited NOLINT comments.

Baselined Findings & Origin PRs

  1. core/src/picture_pool.cpp (+1 finding)
    • Finding: misc-const-correctness at line 76 (int err could be declared const).
    • Origin PR: PR perf(sycl): preallocate pinned host pictures for zero-copy 4K CLI upload (ADR-1410) #1693 (commit 67169ca4c).
    • Fix: Declared const int err = munmap(...) in default_picture_free.
  2. core/src/read_json_model.cpp (+1 finding)
    • Finding: modernize-use-integer-sign-comparison at line 72 ((size_t)sz >= buf_sz compares signed and unsigned integers).
    • Origin PR: PR port(upstream): avoid submodel name truncation in read_json_model (#1428) #1671 (commit 70a7c3c84).
    • Fix: Used C++20 std::cmp_greater_equal(sz, buf_sz) to compare signed off_t with unsigned size_t safely.
  3. core/test/test_psnr_hvs_score.c (+3 findings)
    • Findings: 2x bugprone-implicit-widening-of-multiplication-result (lines 53, 56: w * h * sizeof(float) evaluated as 32-bit before widening to 64-bit size_t); 1x readability-function-size (96 lines exceeds 80-line threshold).
    • Origin PR: PR perf(sycl,hip): compact nonzero terms before psnr_hvs readback (ADR-1397) #1733 (commit 2a3661c6f).
    • Fix: Explicitly cast leading dimension (size_t)w * h * sizeof(float). Extracted buffer allocation and synthetic pattern generation into static helper alloc_test_buffers, reducing test_psnr_hvs_score to 47 LOC.
  4. core/test/test_read_pictures_failure_ownership.c (+1 finding)
    • Finding: readability-function-size (84 lines exceeds 80-line threshold).
    • Origin PR: PR fix(core): vmaf_read_pictures owns its pictures on every return (ADR-1431) #1752 (commit b57f27201).
    • Fix: Extracted picture pool ownership verification loop into static helper verify_pictures_returned_to_pool, reducing test function length to 54 LOC.
  5. core/tools/vmaf.cpp (+7 findings)
    • Findings: 7x cert-dcl03-c,misc-static-assert (runtime assert() statements triggered static assert check recommendations).
    • Origin PR: PR perf(cli): read each input on its own thread, two frames ahead of scoring #1635 (commit 49de09bbd).
    • Fix: Replaced assert() assertions in FrameReader::read_frame with explicit runtime boundary checks returning EINVAL, adhering to project error-handling standards.

Verification

• scripts/ci/tidy-ratchet.py --lane cpu --build-dir build --allow-slack:
• 0 regressions over baseline (exit code 0).
• Total warnings down to 470 (baseline is 474).
• Zero uncited NOLINTs.
• python3 scripts/ci/run_meson_test.py -- -C build --suite=fast: 228/228 tests passed.
• python3 scripts/ci/run_meson_test.py -- -C build: 243/243 tests passed (1 skipped).
• vmaf CLI output on Netflix reference pair (src01_hrc00_576x324.yuv vs src01_hrc01_576x324.yuv): JSON output byte-identical before and after (excluding non-deterministic runtime "fps" field).
• scripts/ci/check-state-md-rows.sh: All 1,028 rows clean.
• Pre-push hooks: mkdocs strict build, Praetor HISS invariant checks, dedupe scan, and security audit all passed.

Bug-status hygiene (ADR-0165)

  • docs/state.md updated in this PR: T-TIDY-CPU-LANE-ABOVE-BASELINE-2026-10-02 opened and closed in this PR with before/after counts and root cause analysis (local merge train lacks clang-tidy ratchet gate).

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: lint refactor and test helper restructuring.
  • Decision matrix — no alternatives: only-one-way fix.
  • AGENTS.md invariant note — no rebase-sensitive invariants.
  • Reproducer / smoke-test command — pasted below under "Reproducer".
  • CHANGELOG fragment — changelog.d/fixed/cpu-lane-tidy-regressions.md added.
  • Rebase note — entry added to docs/rebase-notes.md.

Reproducer

python3 scripts/ci/tidy-ratchet.py --lane cpu --build-dir build --allow-slack

@lusoris
lusoris force-pushed the fix/cpu-tidy-regressions branch from e996bf4 to ac97a4d Compare October 1, 2026 23:47
* fix(picture_pool): declare callback error code const to resolve misc-const-correctness

* fix(model): use std::cmp_greater_equal for buffer size check in read_json_model

* fix(test): resolve implicit widening and function size in test_psnr_hvs_score

* refactor(test): split pool return check into helper in test_read_pictures_failure_ownership

* fix(cli): replace runtime assert with explicit guards in FrameReader

* docs: record T-TIDY-CPU-LANE-ABOVE-BASELINE-2026-10-02 resolution and rebase note

* docs: regenerate the indexes and the citation map after rebasing
@lusoris
lusoris force-pushed the fix/cpu-tidy-regressions branch from ac97a4d to a16253b Compare October 1, 2026 23:55
@lusoris
lusoris merged commit a16253b into master Oct 1, 2026
4 of 53 checks passed
@lusoris
lusoris deleted the fix/cpu-tidy-regressions branch October 1, 2026 23:55
lusoris added a commit that referenced this pull request Oct 2, 2026
* fix(cli): restore the read-ahead's invariant assertions

A lint cleanup (#1785) replaced the seven assert()s of FrameReader and
release_fetched_picture() by early returns and folded conditions. The
clang-tidy finding behind it (misc-static-assert, cert-dcl03-c) is a false
positive of clang-tidy 22 on glibc 2.44 hosts: glibc's C++ assert macro
expands to a conditional with a constant arm, and the check then fires for
every runtime assert. The CI image (glibc 2.39) reports none, so the
committed baseline was right.

The replacements changed what a broken invariant does: publish() dropped the
frame, wait_for_free_slot() ended the reader as if the stream were over,
start() and next() returned silently. All seven assertions and <cassert> are
back; the other four files of #1785 keep their fixes.

test_cli_frame_reader_asserts_contract lists all seven on master and none
here, and reports two planted replacements. Debug build with the assertions
active: fast suite 232 of 232, CLI on the Netflix pair exits 0.

Closes T-CLI-FRAME-READER-ASSERTS-REPLACED-2026-10-02 and defers
T-TIDY-GLIBC-244-STATIC-ASSERT-FALSE-POSITIVE-2026-10-02.

* docs: regenerate the indexes and the citation map after rebasing
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