Repository navigation
build(c-oracle): Add -Wformat=2 and -Wconversion to STRICT_FLAGS - #2632
Conversation
|
Handed off to the coordinator. Both flags are in |
zackees
left a comment
There was a problem hiding this comment.
Coordinator review (author account, so this is a review comment rather than an approval).
Verdict: the flag change and the 30 casts are right; nothing to change. I read every hunk in the diff, not only the summary table:
rust/obs-c-oracle/build.rs—-Wformat=2and-WconversionjoinSTRICT_FLAGS; the MSVC branch is untouched, and no-Wno-*or#pragmais introduced anywhere in the diff.-Wformat=2is-Wformat -Wformat-security -Wformat-nonliteral, so next to the existing-Wformat-nonliteralthe net new coverage is-Wformat-security; that is the intent of #516's Phase 1 list.libobs/util/serializer.h—(uint8_t)(u16 >> 8)is the exact narrowings_w8's parameter already performed implicitly; same fors_wb16.libobs/util/source-profiler.c.h— four(uint8_t)((...) % FRAME_BUFFER_SIZE); the cast sits on the whole modulo expression (not on the addend), so the wrap-around stays identical.libobs/util/profiler-io.c.h— the 16 sites only make the already-implicituint64_t→doubleconversion explicit;(1. - (double)accu / (double)calls)keeps the original evaluation order, and the%-format arguments that wereuint64_t / 1000.become(double)x / 1000.with the same value.libobs/util/profiler.c.h,obs-audio-controls.c.h,media-remux.c.h,obs-output-interleave.c.h,pulseaudio-monitor-format.c.h— same pattern;(float)*cur * voland(float)sum / (float)nr_samplespreserve the promotions the C rules already applied, so no rounding changes.libobs/util/platform-nix.c.h—(int)sysconf(...)keeps the pre-existinglong→intnarrowing (including a-1failure value) and(useconds_t)remain_usis only reached in the< 1000000branch, which is where the ternary already produced auseconds_t-safe value.
Checks I ran: clang-format --dry-run --Werror on the nine libobs/ files is clean. (clang-format also flags rust/obs-c-oracle/build.rs:13, but that is pre-existing on origin/master and the repo's lane only runs clang-format over its own file list.) The build claim itself I did not reproduce locally — this worktree has its submodules uninitialised, so soldr cargo build -p obs-c-oracle would not be the same configuration as CI's — the Fast Gate's oracle build (pending on this head) is the evidence to trust here.
docs/features.md: correctly no line, build tooling only. I am enabling auto-merge; the queue takes it when the Fast Gate and Tier 2 finish.
The clang build of the oracle (Apple clang on macOS, and clang on Linux) surfaces -Wconversion diagnostics that the GCC Linux lane did not: explicit casts only, at utf8.c.h, crc32.c.h, bitstream.c.h, obs-properties.c.h, profiler-io.c.h and pulseaudio-monitor-format.c.h. The casts are the same conversion the compiler already did implicitly, so no value changes. Verified: CC=clang soldr cargo build -p obs-c-oracle and the default (GCC) build are both clean; clang-format --dry-run --Werror clean. Refs #2622, #516.
|
Fixed the New commit Auto-merge is still on; re-queued for the merge gate. |
…jects on MinGW (obs-rust#516) (obs-rust#2651) obs-rust#2632 added -Wconversion to the obs-c-oracle STRICT_FLAGS. MinGW's isfinite(x) expands to fpclassify(x), whose float arm calls __fpclassifyf(float) from a plain ternary, so passing (double)db type-checks as a double->float conversion and the windows-gnu cross build of the oracle fails under -Werror: libobs/media-io/audio-math.h:38:25: error: conversion from 'double' to 'float' may change value [-Werror=float-conversion] rust/obs-c-oracle/oracle/audio_controls.c (via libobs-ported-audio-controls.pch.h) db is already a const float, so the cast was redundant: isfinite(db) selects __fpclassifyf on MinGW, keeps the double arm on glibc/MSVC, and produces identical code on every compiler. Every other oracle translation unit for x86_64-pc-windows-gnu is clean under the same flag set (167/171 compile; the 4 remaining need build-script generated .inc files that are not part of the checkout).
* ci: Compile the oracle's audio math with MinGW Since -Wconversion joined the C oracle's STRICT_FLAGS (obs-rust#2632), the windows-gnu oracle build stops in audio-math.h's db_to_mul(): audio-math.h:38:25: error: conversion from 'double' to 'float' may change value [-Werror=float-conversion] Add a test that compiles oracle/audio_math.c with build.rs's warning flags and its windows-gnu flags, using the MinGW GCC soldr builds the oracle with (15.3.0 here). It skips when no MinGW GCC is installed. It fails until the windows-gnu flags handle MinGW's isfinite(). Refs obs-rust#2648. * obs-c-oracle: Allow MinGW isfinite float casts Since -Wconversion joined STRICT_FLAGS (obs-rust#2632), the windows-gnu build of the oracle stops in audio-math.h's db_to_mul(): audio-math.h:38:25: error: conversion from 'double' to 'float' may change value [-Werror=float-conversion] MinGW's isfinite() is a type-generic macro whose float branch casts its argument to float, and GCC checks that branch even for a double. audio-math.h is a public header, so leave it alone and turn off -Wfloat-conversion for the windows-gnu oracle only. The Linux GCC, clang and macOS builds keep the check. Fixes obs-rust#2648. Local-Gate: v1 tree=1781bdd13482bba1ace2d93c6b343f5bf5fae7f8 secs=2389 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1793119525,"gate":"rust/all/fmt","host":"linux-x86_64","key":"63fd6734b0385def17d28b77c052752f9bc93577f72508e9c77d1f4b69edcd1b","lane":"lint","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":55,"stamp":"5f3882a13b4ec9bf30b28c3a2cf2541d","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"63fd6734b0385def17d28b77c052752f9bc93577f72508e9c77d1f4b69edcd1b","lane":"lint","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":55,"stamp":"7ba1beec8efdd8003885c951e4c0c954","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"45ffcb11a4c69ee4fb8de46b4d314d5d4271e97e8a7555bbdf1a23e1572a234e","lane":"rust-test","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":217,"stamp":"57fb2333b7c2b57f1c17a6966f1824cb","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"a5dbd80ed07189bdb58b9aa2f5c76537501e44be147c4f5b449861a01de660f7","lane":"cross","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":82,"stamp":"726529b19feb277258756d46d6321a45","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"a5dbd80ed07189bdb58b9aa2f5c76537501e44be147c4f5b449861a01de660f7","lane":"cross","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":82,"stamp":"0e111144496ee57d10cbcf8552d9d453","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"a5dbd80ed07189bdb58b9aa2f5c76537501e44be147c4f5b449861a01de660f7","lane":"cross","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":82,"stamp":"55cf4c0d6c52a4572844dce27f051721","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"a5dbd80ed07189bdb58b9aa2f5c76537501e44be147c4f5b449861a01de660f7","lane":"cross","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":82,"stamp":"34ae8fa379ae5761ac8c07391d0d4ca7","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"} Ci-Attestation: {"at":1793119525,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f07fb7478335ca7de18abdfaad6130439f5f75b149977cf0d547e5a16931cb3e","lane":"tier2-linux","parents":["b1eff2d60b0c233caf75d06ff2c75d76d35b2f44"],"secs":2034,"stamp":"492f336248dbc0fe482f1892fa955825","tree":"1781bdd13482bba1ace2d93c6b343f5bf5fae7f8","v":1,"via":"run"}
Adds the last two Phase 1 flags of #516 to the C oracle's
STRICT_FLAGSand makes every target clean under them.Fixes #2622.
RED —
b522192darust/obs-c-oracle/build.rs:STRICT_FLAGSgains-Wformat=2and-Wconversion(the MSVC branch is untouched).soldr cargo build -p obs-c-oraclefails on the first site:GREEN —
1bb55c4f737 findings at 30 sites over 9 first-party
libobs/files, each fixed with an explicit cast — exactly the conversion the compiler already performed implicitly, so no value changes:libobs/util/serializer.h(uint8_t)(u16 >> 8))libobs/util/source-profiler.c.h(uint8_t)((idx + 1) % FRAME_BUFFER_SIZE))libobs/util/profiler-io.c.h(double)…)libobs/util/profiler.c.h(double)map->occupied / (double)map->size)libobs/util/platform-nix.c.h(int)sysconf(...),(useconds_t)remain_us)libobs/obs-audio-controls.c.hsum / (float)nr_samples)libobs/obs-output-interleave.c.h(double)(out.pts * out.timebase_num))libobs/media-io/media-remux.c.h(float)pkt.pos / (float)job->in_size * 100.f)libobs/audio-monitoring/pulse/pulseaudio-monitor-format.c.h(float)*cur * vol)No
-Wno-*flag and no#pragmawas added; no exemption for a first-party file. Both flags stay inSTRICT_FLAGS.Verification
soldr cargo build -p obs-c-oracle— clean (Finished dev profile), all TUs compiled.soldr cargo test -p obs-c-oracle --no-run— clean.clang-format --dry-run --Werroron the nine changed files — clean.Host Linux is verified here; PR CI's cross lane (
ci/local_gate.py) compiles every oracle TU forx86_64-pc-windows-gnu,x86_64-pc-windows-msvcand both Apple targets.No
docs/features.mdline: build tooling only.