Skip to content

Fix clippy needless_late_init in txt_helpers - #2332

Merged
cfsmp3 merged 1 commit into
masterfrom
fix/clippy-needless-late-init
Sep 5, 2026
Merged

Fix clippy needless_late_init in txt_helpers#2332
cfsmp3 merged 1 commit into
masterfrom
fix/clippy-needless-late-init

Conversation

@cfsmp3

@cfsmp3 cfsmp3 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Why

cargo clippy -- -D warnings fails on master:

error: unneeded late initialization
  --> src/encoder/txt_helpers.rs:45:9
error: could not compile `lib_ccxr` (lib) due to 1 previous error

So format_rust (./src/rust/lib_ccxr) is red on every open PR regardless of what it changes — #2327, #2329 and #2331 all fail on this line and not on their own code.

The side effect is worse than the red tick: authors have been fixing it inside unrelated PRs to get CI green. #2331 carried this exact fix alongside a C string change until it was asked to drop it, at which point its CI went red for a reason that had nothing to do with the PR. That is the wrong shape — a lint fix on shared code should land once, on its own.

What

Assign c_len from an if-expression rather than declaring it and assigning in every branch. Semantically identical; clippy stops objecting.

The added comment records why the final else yields 1: a byte matching no UTF-8 lead pattern is consumed singly so the loop always advances. That is the one branch whose value is not obvious from the pattern above it.

Testing

  • cargo clippy -- -D warnings clean on both crates (lib_ccxr and src/rust); master fails the first
  • cargo fmt --check clean
  • 45 lib_ccxr tests pass
  • Builds with no compiler messages
  • A/B against a master build (982586e8): 59 samples × --out=ttxt and --out=srt, 112 outputs byte-identical, 0 differences, 0 exit-code changes (6 produced no output on either side)

Once this lands, #2327/#2329/#2331-style PRs go green on their own merits, and the next PR touching Rust does not have to carry someone else's lint fix.

Master fails `cargo clippy -- -D warnings` on lib_ccxr, so format_rust
is red on every open pull request regardless of what it changes. Authors
have been fixing it inside unrelated PRs to get their CI green, which
couples a one-line lint fix to whatever else they are working on.

Assign c_len from an if-expression instead of declaring it and filling
it in on each branch. Behaviour is identical.
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. 171/237 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 25/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 32/34

66 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.


Compared with the tip of mastertest 9514, commit 982586e:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 66 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 9514), so the comparison above already covers it.


No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch.

@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. 171/237 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 25/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 12/13
XDS 32/34

66 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.


Compared with the tip of mastertest 9515, commit 982586e:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 66 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 9515), so the comparison above already covers it.


No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch.

@cfsmp3
cfsmp3 merged commit cf42e6c into master Sep 5, 2026
47 of 49 checks passed
@cfsmp3
cfsmp3 deleted the fix/clippy-needless-late-init branch September 5, 2026 21:58
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.

2 participants