Skip to content

build(shared): ratchet the conversion warnings on happy-eyeballs, opts-parser and bpm (#2625) - #2856

Merged
zackees merged 2 commits into
masterfrom
infra/2625-conversion-shared-net
Oct 29, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/2625-conversion-shared-net

Conversation

@zackees

@zackees zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member

Part of #2625 (the warning ratchet): the next slice after linux-v4l2 (#2849), moving to the shared/ targets the survey listed. Three targets, one commit each side of RED/GREEN.

RED 2570af96b: shared/happy-eyeballs, shared/opts-parser and plugins/obs-outputs/bpm compile with their own -Wconversion -Wsign-conversion -Wfloat-conversion instead of inheriting the global -Wno-* pins. The rebuild in obs-rust-linux-validate reports 12 diagnostics — 7 in bpm.c.h, 3 in opts-parser.c.h, 2 in happy-eyeballs.c.h — and stops.

GREEN c872f588a: 12 → 0 diagnostics, all three objects compile and link. Each site now states the type it already had:

file change
shared/opts-parser/opts-parser.c.h the two DARRAY walks are size_t counts in struct obs_options; bstrdup_n takes the size_t length between = and the param
shared/happy-eyeballs/happy-eyeballs.c.h connect() takes the ai_addrlen the addrinfo already carries (no (int) narrowing); the getter returns its socklen_t winner_addr_len as the int it has always returned
shared/bpm/bpm.c.h frame counters cast to the uint32_t the struct stores; the SEI payload length is size_t end to end; the metrics DARRAY drops the signed index — idx starts at bpm_metrics.num, which is also the not-found sentinel, so da_erase takes a size_t

No behavior change: every value is the same width or narrower on the path it already took. ./lint is green on the branch head (clang-format + gersemi).

Ratchet now covers 15 targets. Remaining from the survey: obs-ffmpeg, obs-outputs proper (407 diagnostics — the rtmp/mp4 muxers, a separate unit), linux-capture, win-capture, mac-capture, the frontend-ON C++ class, then the Linux pin deletion.

Refs #2625

…lpers (#2625)

RED: happy-eyeballs, opts-parser and bpm compile with their own -Wconversion,
-Wsign-conversion and -Wfloat-conversion instead of inheriting the global
-Wno-* pins. The target builds report 12 diagnostics: 7 in bpm.c.h, 3 in
opts-parser.c.h and 2 in happy-eyeballs.c.h, so the build stops.

Refs #2625
…lpers (#2625)

GREEN for the three shared targets the previous commit enables the groups on.
Each site now states the type it already had:

- opts-parser: the two DARRAY walks are `size_t` counts in `struct obs_options`,
  and `bstrdup_n` takes the `size_t` length between the `=` and the param.
- happy-eyeballs: `connect()` takes the address length the `addrinfo` already
  carries (no `(int)` narrowing), and the public getter returns its
  `socklen_t winner_addr_len` as the `int` it has always returned.
- bpm: the frame counters are the `uint32_t` the struct stores, the SEI payload
  length is a `size_t` end to end (`sei_message_size` -> `bmalloc` -> `memcpy`
  -> return), and the metrics DARRAY no longer carries a signed index: `idx`
  starts at `bpm_metrics.num`, which is also the "not found" sentinel, so
  `da_erase` takes a `size_t` and no `-1` round-trips through `int64_t`.

Rebuilt with the groups enabled: 12 -> 0 diagnostics, all three objects link.

Refs #2625

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — correctness holds and the change is mechanical; nothing here needs to go back to the author.

What I checked

  • RED → GREEN is honest. RED 2570af96b turns on -Wconversion -Wsign-conversion -Wfloat-conversion for the three targets without touching the sites (12 diagnostics reported in the PR body), GREEN c872f588a fixes exactly those sites and nothing else — 6 files, 34 insertions, 10 deletions, no other target in the diff.
  • No behaviour change on any edited path.
    • bpm.c.h frame counters: obs_output_get_total_frames/get_frames_dropped return uint64_t into a struct field that has always been uint32_t; the explicit cast states the existing width. payload_size was already returned as size_t by extract_buffer_from_sei, so dropping the int round-trip removes a truncation rather than adding one. The bpm_destroy index rewrite is equivalent: idx = bpm_metrics.num is the not-found sentinel, the walk sets idx = i - 1, and idx < bpm_metrics.num is the old idx >= 0 for a size_t — the found element is still erased.
    • opts-parser.c.h: the two DARRAY walks are pointer differences, so size_t is the type the struct already stores; bstrdup_n takes a size_t length.
    • happy-eyeballs.c.h: connect() takes the socklen_t the addrinfo already carries (the (int) cast was a narrowing, not a widening); the getter's (int) return keeps the documented int signature and winner_addr_len is bounded by sizeof(struct sockaddr_storage), so the cast cannot truncate.
  • Pattern matches the merged slices (plugins/linux-v4l2/CMakeLists.txt, #2849): COMPILE_LANG_AND_ID:C,... guard so C++ objects in these targets are unaffected, and the global pins stay until the last target is ratcheted.
  • No docs/features.md line needed: build flags only, no user-visible behaviour.

Nit, not blocking: the three identical target_compile_options blocks could eventually move to one helper when the remaining survey targets land, so the "leaves the flag lists once every target is ratcheted" comment has one home. Fine as three local blocks for now.

I'll queue it once the two still-running checks finish.

@zackees
zackees added this pull request to the merge queue Oct 29, 2026
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator: PR CI is green (Fast Gate, Format / checks, all six Rust Tier 2 Linux shards, CI Gate ✅), no local-gate stamp exists — PR CI measured the branch directly rather than a stamped tree. Two commits behind master; queue handles the merge result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant