Repository navigation
build(linux-alsa): compile one target with the conversion warnings enabled (#2625) - #2690
Conversation
…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
left a comment
There was a problem hiding this comment.
Reviewed the diff, the RED/GREEN split and the flags themselves.
Correctness, site by site — all six casts keep the value they had:
data->rateand thealsa_updatelocal areunsigned int(alsa-input.c.h:52,:191), andratecomes from the settings enum, so the two(uint32_t)casts onobs_data_get_intnarrow a small positive value only.sample_sizeisunsigned int(:53);channelsisunsigned int, sochannels * (uint32_t)snd_pcm_format_physical_width(...) / 8is unsigned × unsigned, evaluated in the same order as before.snd_pcm_recovertakes anintand the path is guarded byframes <= 0, so(int)framescannot truncate a positive count.out.frames/out.timestampare only reached after theframes <= 0re-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.
Refs #2625. First slice of the conversion ratchet: one target, compile-enforced.
What this does
plugins/linux-alsanow compiles with-Wconversion -Wsign-conversion -Wfloat-conversionon its owntarget, 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 lasttarget 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-conversionor-Wfloat-conversion; the pins cancel warnings that are off by default (-Wextradoes not includethem). Replaying the real Tier 2 compile commands for six
libobsunity TUs, three ways: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-onlyover every C TU in the Tier 2 compdb (zccache does not key on flags, so anormal rebuild would report stale objects as clean):
That is several hundred first-party sites after the vendored trees (
librtmp,deps/) and the Ctests 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-alsahere).RED
2ffe6b01dadds only the three flags to this target. It fails with exactly six diagnostics:GREEN
9e2e9188efixes them, each keeping the value it had:ratereads are settings values (32000/44100/48000) narrowed to the plugin's unsigned rate;sample_sizebecomes unsigned*unsigned (channelsisunsigned int, the physical width is apositive bit count) instead of a signed product that converts on assignment;
snd_pcm_recovertakes aninterror code andframesis<= 0on that path;out.frames/out.timestampare only reached after theframes <= 0check, so the positive framecount 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,-Werrorkept) returnsrc 0.
clang-format --dry-run --Werroris clean on the changed C file. PR CI is the real gate —this touches no Rust, Python or workflow file.
No
docs/features.mdline: build tooling only.