From 74c9e46faff47779ce01f911474994e03809fdab Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Sun, 5 Jul 2026 19:04:06 +0000 Subject: [PATCH] =?UTF-8?q?fix(vdisplay/windows):=20Windows=20clippy=20?= =?UTF-8?q?=E2=80=94=20per-block=20SAFETY=20comments=20+=20then=5Fsome?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The branch's Windows-host code never ran through the fleet Windows clippy (kept off CI); the merge to main exposed it. Fix the 4 -D warnings failures in cfg(windows) code: - manager.rs: 3 unsafe blocks (isolate_displays_ccd / force_extend_topology / set_virtual_primary_ccd) had one "both arms" SAFETY comment on the `match` line — clippy::undocumented_unsafe_blocks wants it immediately before each block. Split into per-block SAFETY comments. - win_display.rs: `.then(|| …)` on a POD u32 union read → `.then_some(…)` (eager is fine, discarded when false) for clippy::unnecessary_lazy_evaluations. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/punktfunk-host/src/vdisplay/windows/manager.rs | 10 +++++++--- crates/punktfunk-host/src/windows/win_display.rs | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/punktfunk-host/src/vdisplay/windows/manager.rs b/crates/punktfunk-host/src/vdisplay/windows/manager.rs index e2b20e5..28dfaac 100644 --- a/crates/punktfunk-host/src/vdisplay/windows/manager.rs +++ b/crates/punktfunk-host/src/vdisplay/windows/manager.rs @@ -655,10 +655,10 @@ impl VirtualDisplayManager { // MODE_CHANGE storm). Opt out (extend) with PUNKTFUNK_NO_ISOLATE=1 / the console policy. use crate::vdisplay::policy::Topology; match topology_action() { - // SAFETY (both arms): the CCD helper is `unsafe` for its topology FFI; it takes a - // `Copy` `u32` by value and returns an owned `SavedConfig` (no borrowed memory crosses), - // and runs under the `state` lock, the sole mutator of the topology. Topology::Exclusive => { + // SAFETY: `isolate_displays_ccd` is `unsafe` for its CCD topology FFI; it takes the + // `Copy` target id by value and returns an owned `SavedConfig` (no borrowed memory + // crosses), under the `state` lock — the sole topology mutator. ccd_saved = unsafe { isolate_displays_ccd(added.target_id) }; } Topology::Primary => { @@ -668,8 +668,12 @@ impl VirtualDisplayManager { // alongside the virtual, THEN reposition to make the virtual primary — so the // physical stays active. (The bring-up above only force-EXTENDs when the // virtual FAILS to auto-resolve; here it resolved, so we do it explicitly.) + // SAFETY: `force_extend_topology` drives the CCD topology FFI (no args, no borrowed + // memory), under the `state` lock — the sole topology mutator. unsafe { force_extend_topology() }; thread::sleep(Duration::from_millis(300)); + // SAFETY: `set_virtual_primary_ccd` takes the `Copy` target id by value and returns + // an owned `SavedConfig` (no borrowed memory crosses), under the `state` lock. ccd_saved = unsafe { set_virtual_primary_ccd(added.target_id) }; } Topology::Extend | Topology::Auto => { diff --git a/crates/punktfunk-host/src/windows/win_display.rs b/crates/punktfunk-host/src/windows/win_display.rs index e5f5411..dff5108 100644 --- a/crates/punktfunk-host/src/windows/win_display.rs +++ b/crates/punktfunk-host/src/windows/win_display.rs @@ -492,8 +492,10 @@ pub(crate) unsafe fn set_virtual_primary_ccd(keep_target_id: u32) -> Option