Skip to content

build(linux-alsa): compile one target with the conversion warnings enabled (#2625) - #2690

Merged
zackees merged 2 commits into
masterfrom
infra/2625-conversion-alsa
Oct 27, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/2625-conversion-alsa

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Refs #2625. First slice of the conversion ratchet: one target, compile-enforced.

What this does

plugins/linux-alsa now compiles with -Wconversion -Wsign-conversion -Wfloat-conversion on its own
target, and its six implicit conversions are fixed at the call sites. The three global pins
(-Wno-conversion, -Wno-sign-conversion, -Wno-float-conversion) stay in place until the last
target is ratcheted — deleting them now would change nothing (see below), so the ratchet has to be
per target.

Measurement first: the pins are currently inert

The issue asks for a re-measure before any of this is planned, and the re-measure changes the shape
of the work. Nothing in either CMake flag list enables -Wconversion, -Wsign-conversion or
-Wfloat-conversion; the pins cancel warnings that are off by default (-Wextra does not include
them). Replaying the real Tier 2 compile commands for six libobs unity TUs, three ways:

flags diagnostics
master as configured (pins in place) 25
the three pins deleted, nothing else 25
pins deleted and the groups enabled 143

So "drop the pins" alone is a no-op, and criterion 4 of the issue ("a new implicit conversion fails
the build") cannot hold without enabling the groups. Full unique-source survey with the groups
enabled, -fsyntax-only over every C TU in the Tier 2 compdb (zccache does not key on flags, so a
normal rebuild would report stale objects as clean):

unique C TUs: 682, conversion diagnostics: 1599  (sign 1070, plain 519, float 10)
per area: obs-outputs 480 (196 of them librtmp, vendored) | test 315 (C tests, not editable)
          libobs 210 | obs-ffmpeg 125 | linux-v4l2 108 | libobs-opengl 90 | linux-capture 58
          linux-pipewire 44 | shared 38 | deps 32 (vendored) | nvenc 28 | filters 22
          text-freetype2 17 | image-source 9 | alsa 6 | x264 6 | decklink 4 | pulseaudio 4 | vlc 3
159 distinct source files, worst: librtmp/rtmp.c 196, xcomposite-input.c.h 60, v4l2-input.c.h 55,
pipewire.c.h 52, rtmp-av1.c.h 49, obs-ffmpeg-srt.h 48, rtmp-hevc.c.h 45, xshm-input.c.h 44.

That is several hundred first-party sites after the vendored trees (librtmp, deps/) and the C
tests are excluded, i.e. a per-target series, not one PR. I will post the table on #2625 as well so
the split is reviewable there; the ratchet order will follow the table (smallest verified targets
first, linux-alsa here).

RED

2ffe6b01d adds only the three flags to this target. It fails with exactly six diagnostics:

alsa-input.c.h:131:22: conversion from 'long long int' to 'unsigned int' [-Wconversion]
alsa-input.c.h:206:16: conversion from 'long long int' to 'unsigned int' [-Wconversion]
alsa-input.c.h:514:45: conversion to 'unsigned int' from 'int' [-Wsign-conversion]
alsa-input.c.h:584:64: conversion from 'snd_pcm_sframes_t' to 'int' [-Wconversion]
alsa-input.c.h:594:30: conversion from 'snd_pcm_sframes_t' to 'uint32_t' [-Wconversion]
alsa-input.c.h:595:66: conversion to 'uint64_t' from 'snd_pcm_sframes_t' [-Wsign-conversion]

GREEN

9e2e9188e fixes them, each keeping the value it had:

  • the two rate reads are settings values (32000/44100/48000) narrowed to the plugin's unsigned rate;
  • sample_size becomes unsigned * unsigned (channels is unsigned int, the physical width is a
    positive bit count) instead of a signed product that converts on assignment;
  • snd_pcm_recover takes an int error code and frames is <= 0 on that path;
  • out.frames/out.timestamp are only reached after the frames <= 0 check, so the positive frame
    count fits uint32_t/uint64_t.

No #pragma, no per-file -Wno-*, no public header or C-test edit.

Verification

Local, against the Tier 2 build volume's own compdb, with the three groups enabled (the pins are
still global, so this is the only way to see the warning today): the plugin's unity TU went from 6
diagnostics to 0, and the plain compile of that TU (-fsyntax-only, -Werror kept) returns
rc 0. clang-format --dry-run --Werror is clean on the changed C file. PR CI is the real gate —
this touches no Rust, Python or workflow file.

No docs/features.md line: build tooling only.

…abled

RED for #2625. The three global pins (-Wno-conversion, -Wno-sign-conversion,
-Wno-float-conversion) hide every implicit conversion in this plugin, and with
nothing enabling those groups they hide nothing else: dropping them alone is a
no-op (25 -> 25 diagnostics over six libobs TUs). Enabling them on this one
target is the ratchet, and it currently fails:

  plugins/linux-alsa/alsa-input.c.h:131:22: conversion from 'long long int' to 'unsigned int' [-Wconversion]
  plugins/linux-alsa/alsa-input.c.h:206:16: same
  plugins/linux-alsa/alsa-input.c.h:514:45: conversion to 'unsigned int' from 'int' [-Wsign-conversion]
  plugins/linux-alsa/alsa-input.c.h:584:64: conversion from 'snd_pcm_sframes_t' to 'int' [-Wconversion]
  plugins/linux-alsa/alsa-input.c.h:594:30: conversion from 'snd_pcm_sframes_t' to 'uint32_t' [-Wconversion]
  plugins/linux-alsa/alsa-input.c.h:595:66: conversion to 'uint64_t' from 'snd_pcm_sframes_t' [-Wsign-conversion]
GREEN for #2625. Each site keeps the value it had:

- rate from obs_data_get_int is a settings value (32000/44100/48000), so the
  narrowing to the plugin's unsigned int rate is in bounds.
- sample_size is computed as unsigned * unsigned: channels is unsigned int and
  snd_pcm_format_physical_width returns the positive width in bits, so the
  product no longer becomes a signed int that has to convert on assignment.
- snd_pcm_recover takes an int error code; frames is <= 0 on that path and is
  an ALSA error code, which is an int.
- out.frames/out.timestamp are reached only after the frames <= 0 check, so
  frames is a positive frame count that fits uint32_t and uint64_t.

No pragma, no per-file -Wno-*, no change to a public header or a C test.

Verified: replaying the plugin's unity compile command from the Tier 2 compdb
with the three pins dropped and -Wconversion/-Wsign-conversion/
-Wfloat-conversion enabled gives 0 diagnostics and rc 0 (was 6); the same TU
still needs the -fsyntax-only form because the pins are global today.

@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 the diff, the RED/GREEN split and the flags themselves.

Correctness, site by site — all six casts keep the value they had:

  • data->rate and the alsa_update local are unsigned int (alsa-input.c.h:52, :191), and rate comes from the settings enum, so the two (uint32_t) casts on obs_data_get_int narrow a small positive value only.
  • sample_size is unsigned int (:53); channels is unsigned int, so channels * (uint32_t)snd_pcm_format_physical_width(...) / 8 is unsigned × unsigned, evaluated in the same order as before.
  • snd_pcm_recover takes an int and the path is guarded by frames <= 0, so (int)frames cannot truncate a positive count.
  • out.frames/out.timestamp are only reached after the frames <= 0 re-check, so (uint32_t) / (uint64_t) carry a positive frame count.

No #pragma, no per-file -Wno-*, no public header or C-test edit, and no docs/features.md line needed — this is build tooling only, which matches the ledger rule.

Flag placement is sound. target_compile_options lands after the global -Wno-conversion/-Wno-sign-conversion/-Wno-float-conversion on the compile line, so this target really sees the warnings even while the pins stay global; the COMPILE_LANG_AND_ID:C,GNU,Clang,AppleClang guard keeps them off a C++ unity TU. Build / Rust Tier 2 Linux (build) passing in 5m19s on this head is the evidence the plugin compiles with them enabled.

Commit split is clean. 2ffe6b01d touches only plugins/linux-alsa/CMakeLists.txt (+8), 9e2e9188e only alsa-input.c.h (+6/−6), so the RED commit is genuinely the failing configuration alone.

One thing the author needs to answer before this becomes a series. #2689, filed seventeen seconds before this PR by the same account, argues that warning-ratchet work should be one PR per warning class, any number of directories, with the fixes and the global pin removal in the same change — because each target/ directory slice pays a full Pull run (~35 min measured on #2643: Rust Tests windows 14, macOS 13, Fast Gate 12, Tier 2 macOS 12, Tier 2 windows 10) plus a queue run. This PR is slice 1 of the per-target series (#2625's table is ~19 first-party areas over 159 files). The mechanisms are not the same: this PR enables the groups per target rather than adding per-directory -Wno-*, so it does not hit #2689's objection (2), but #2689's cost objection (3) applies to 18 more slices, and under that plan the three global pins can only be deleted by the last one.

So: is the rest of #2625 a series of target PRs like this one, or one class-wide PR per #2689? If it is the latter, this lands as a small, self-contained ratchet and the remaining sites should go into a single PR that also deletes the pins — which is the shape #2689's acceptance criteria ask for. That is a scoping call for the author/maintainer; I am not deciding it here.

Checks: Rust Tier 2 Linux (tests OFF) and (tests ON) were still pending when I reviewed, so the PR is not in the queue yet.

@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit ea42564 Oct 27, 2026
37 checks passed
@zackees
zackees deleted the infra/2625-conversion-alsa branch October 27, 2026 21:10
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