Skip to content

build(obs-qsv11): mask in unsigned so MSVC keeps the constant intact (#2965) - #2969

Merged
zackees merged 1 commit into
masterfrom
fix/2965-msvc-c4310
Oct 30, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2965-msvc-c4310

Conversation

@zackees

@zackees zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member

master's Windows app lane is red on the ratchet slice #2965 merged: the NAL-mask cast states the right byte but truncates a constant, which MSVC turns into an error under warnings-as-errors.

RED — the Windows app lane

Scheduled on fix/2625-frontend-tools-scripts-conversions (#2968), run 40971591142, job Build 🧱 / Windows 🪟 (x64) (123789581762), on master 217b3cf08+:

plugins/obs-qsv11/obs-qsv11.c.h(1072,25): warning C4310: cast truncates constant value
plugins/obs-qsv11/obs-qsv11.c.h(1072,25): error C2220: the following warning is treated as an error

The site is untouched by that PR; it is the cast #2965 added when it ratcheted plugins/obs-qsv11.

What changed

-start[0] &= (uint8_t)~(3u << 5);
+start[0] &= (uint8_t)(0xFFu & ~(3u << 5));

~(3u << 5) is 0xFFFFFF9F; masking in unsigned first makes the cast operand 0x9F, a value that already fits uint8_t. The mask and the byte written are identical (bits 5-6 cleared), and the expression still says what it means.

GREEN evidence

  • The two-line TU replicating the expression (s &= (uint8_t)(0xFFu & ~(3u << 5)); s |= priority << 5;) compiles clean under GCC and Clang with -Wconversion -Wsign-conversion -Wfloat-conversion -Werror, and returns the same byte as before (0xFF → 0xBF with priority 1).
  • clang-format --dry-run --Werror on the edited file: clean.
  • No -Wno- flag, no target change: plugins/obs-qsv11 stays ratcheted.
  • MSVC confirmation is the Windows lane on this branch; there is no MSVC host here, so I am dispatching scheduled.yaml on the branch and will comment its Build 🧱 / Windows 🪟 (x64) result here.

Tiers that do not apply: a mask constant in a plugin's NAL rewrite; no Rust unit, no C test, no protocol or runtime behaviour change.

Refs #2625, #2938

…2965)

#2965 stated the NAL-mask conversion as `(uint8_t)~(3u << 5)`. The mask
is right (0x9F), but the cast truncates a constant, and MSVC reports that
as C4310, which the ratchet's warnings-as-errors turn makes fatal:

  plugins/obs-qsv11/obs-qsv11.c.h(1072,25): warning C4310: cast truncates
  constant value
  plugins/obs-qsv11/obs-qsv11.c.h(1072,25): error C2220: the following
  warning is treated as an error

Masking in `unsigned` first keeps the expression's intent and leaves the
cast a value that already fits, so no compiler sees a truncation. The
byte written is unchanged.

Refs #2625
@zackees

zackees commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Windows lane result for the dispatch on this branch — the C4310 site is gone.

Scheduled Repository Actions ⏰ on fix/2965-msvc-c4310 (run 40975673680), head 109ceac:

job result
Build 🧱 / Windows 🪟 (x64) (123803097572) success
Build 🧱 / Windows 🪟 (arm64) (123803097488) success

No C4310 / C2220 in either job, so plugins/obs-qsv11/obs-qsv11.c.h:1072 is accepted by MSVC at the target's warning level with the ratchet still on.

The other reds in that dispatch are master's, not this commit's diff (this PR touches one plugin file and no lane skips it here):

So #2969 should queue behind #2968 (both now have auto-merge on).

@zackees
zackees enabled auto-merge October 30, 2026 00:01
@zackees

zackees commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

Windows x64 + arm64 green on the nightly dispatch above; auto-merge is on and the queue should take it after #2968 (same scripts.cpp.hpp conversions gate this branch's Ubuntu/macOS app lanes).

@zackees

zackees commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Windows verdict from scheduled.yaml dispatched on this branch (40975673680):

  • Build 🧱 / Windows 🪟 (x64) — success (job 123803097572). This is the lane that failed on master with plugins/obs-qsv11/obs-qsv11.c.h(1072,25): warning C4310: cast truncates constant value / error C2220. It compiles clean with the mask taken in unsigned.
  • Build 🧱 / Windows 🪟 (arm64) — success, as it was on master.

The other app lanes in that run are not this PR: Ubuntu 🐧 (OBS-Studio-Rust) and Flatpak 📦 are the plugins/frontend-tools/scripts.cpp.hpp sites (#2968, currently at position 1 in the merge queue), and macOS 🍏 (arm64)/(x86_64) plus Analyze 🔬 / macOS are the Qt 6.11 deps headers of #2950, which waits on a maintainer Decision needed:. Their logs are not published until the run completes.

PR CI on this branch: asan 🧪 is the only check still pending.

@zackees

zackees commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

GREEN — MSVC confirmation

scheduled.yaml dispatch on this branch (109ceac08), run 40975673680:

  • Build 🧱 / Windows 🪟 (x64) — success (job 123803097572)
  • Build 🧱 / Windows 🪟 (arm64) — success (job 123803097488)
  • Build 🧱 / Rust Cross Lint 🦀 (Windows, macOS) — success

So plugins/obs-qsv11/obs-qsv11.c.h:1072 no longer trips C4310 under MSVC /W4-as-error, on both architectures.

The same run's Linux/macOS app lanes are red only because this branch predates master's #2968 (43af74187, merged 00:14 UTC), which states the plugins/frontend-tools/scripts.cpp.hpp conversions those lanes stop on; the diff here does not touch them. The PR's own Linux lanes (Fast Gate, Tier 2, Qt Frontend Linux) are green.

Waiting on the PR's asan lane, then handing off.

@zackees

zackees commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Green on Windows 🪟: scheduled.yaml on this branch (40975673680), job Build 🧱 / Windows 🪟 (x64) — success, with Build 🧱 / Windows 🪟 (arm64) also green. The obs-qsv11.c.h(1072) C4310/C2220 pair is gone.

The two failures on this branch are not this change:

The CEF job failed on the same run; it is a Chrome-release-data check, unrelated to this branch.

@zackees
zackees added this pull request to the merge queue Oct 30, 2026
Merged via the queue into master with commit 5e25ac5 Oct 30, 2026
71 of 77 checks passed
@zackees
zackees deleted the fix/2965-msvc-c4310 branch October 30, 2026 00:23
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In review to Done in obs-rust Multiview Oct 30, 2026
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