From bd05bc8c308bf91f84f747c05ba2f5263ce715d8 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Fri, 26 Jun 2026 07:15:00 +0000 Subject: [PATCH] fix(windows): clippy/build cleanups the on-glass build surfaced (-D warnings) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Built the host crate (`cargo clippy --features nvenc -D warnings`) and the driver workspace (`cargo build`) on the RTX box — the project's intended Windows gate, which `cargo check` (what the goal1/§2.5 work used) never runs. It surfaced lint issues accumulated across the goal1 / §2.5 / this-session Windows work: - 9× redundant `as *mut c_void` after `.as_raw_handle()` (already `*mut c_void`): idd_push.rs (3, this session), service.rs (3, this session), manager.rs (3, pre-existing §2.5 — my OwnedHandle work copied the idiom). Removed the casts + the now-unused `use std::ffi::c_void` in idd_push.rs / manager.rs (service still uses it). - `if_same_then_else` in session_plan.rs::resolve_topology (pre-existing goal1 stage 3): collapsed the two `false` arms into one condition (behavior identical). - `unused_unsafe` in the driver `pod_init!` macro: it expands at call sites already inside an `unsafe` block, where its own `unsafe` is redundant — `#[allow( unused_unsafe)]` (needed at the non-unsafe sites, redundant at the nested ones). After these, BOTH builds are clean on the box — validating the whole session's blind Windows + driver work compiles + passes clippy on real hardware. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/punktfunk-host/src/capture/windows/idd_push.rs | 9 +++------ crates/punktfunk-host/src/session_plan.rs | 4 +--- crates/punktfunk-host/src/vdisplay/windows/manager.rs | 7 +++---- crates/punktfunk-host/src/windows/service.rs | 6 +++--- packaging/windows/drivers/pf-vdisplay/src/log.rs | 6 +++++- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/crates/punktfunk-host/src/capture/windows/idd_push.rs b/crates/punktfunk-host/src/capture/windows/idd_push.rs index 1f6d09f..35bfe5e 100644 --- a/crates/punktfunk-host/src/capture/windows/idd_push.rs +++ b/crates/punktfunk-host/src/capture/windows/idd_push.rs @@ -14,7 +14,6 @@ use super::dxgi::{make_device, D3d11Frame, HdrConverter, WinCaptureTarget}; use super::{CapturedFrame, Capturer, FramePayload, PixelFormat}; use anyhow::{bail, Context, Result}; use pf_driver_proto::frame; -use std::ffi::c_void; use std::os::windows::io::{AsRawHandle, FromRawHandle, OwnedHandle}; use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; @@ -400,7 +399,7 @@ impl IddPushCapturer { // Own the mapping handle so it (and its view) free via `MappedSection` RAII even on bail. let map = OwnedHandle::from_raw_handle(map.0 as _); let view = MapViewOfFile( - HANDLE(map.as_raw_handle() as *mut c_void), + HANDLE(map.as_raw_handle()), FILE_MAP_ALL_ACCESS, 0, 0, @@ -450,7 +449,7 @@ impl IddPushCapturer { // Own the mapping handle so it (and its view) free via `MappedSection` RAII. let dm = OwnedHandle::from_raw_handle(dm.0 as _); let dv = MapViewOfFile( - HANDLE(dm.as_raw_handle() as *mut c_void), + HANDLE(dm.as_raw_handle()), FILE_MAP_ALL_ACCESS, 0, 0, @@ -936,9 +935,7 @@ impl Capturer for IddPushCapturer { fn next_frame(&mut self) -> Result { let deadline = Instant::now() + Duration::from_secs(20); loop { - let _ = unsafe { - WaitForSingleObject(HANDLE(self.event.as_raw_handle() as *mut c_void), 16) - }; + let _ = unsafe { WaitForSingleObject(HANDLE(self.event.as_raw_handle()), 16) }; if let Some(f) = self.try_consume()? { return Ok(f); } diff --git a/crates/punktfunk-host/src/session_plan.rs b/crates/punktfunk-host/src/session_plan.rs index ecb9d3d..f9a5b88 100644 --- a/crates/punktfunk-host/src/session_plan.rs +++ b/crates/punktfunk-host/src/session_plan.rs @@ -138,9 +138,7 @@ fn resolve_topology() -> SessionTopology { let cfg = crate::config::config(); // `NO_HELPER`/`NO_WGC` force single-process; IDD-push captures in-process in Session 0 (no helper); // otherwise the helper runs when forced or when we're SYSTEM (in-process WGC can't activate there). - let helper = if cfg.no_helper || crate::capture::wgc_disabled() { - false - } else if cfg.idd_push { + let helper = if cfg.no_helper || crate::capture::wgc_disabled() || cfg.idd_push { false } else { cfg.force_helper || crate::capture::wgc_relay::running_as_system() diff --git a/crates/punktfunk-host/src/vdisplay/windows/manager.rs b/crates/punktfunk-host/src/vdisplay/windows/manager.rs index 54d8a5a..ed8752f 100644 --- a/crates/punktfunk-host/src/vdisplay/windows/manager.rs +++ b/crates/punktfunk-host/src/vdisplay/windows/manager.rs @@ -13,7 +13,6 @@ //! its `Drop` releases the refcount (a *stale* lease — its monitor was preempted + recreated under it — //! is a no-op, so it can never tear down the live monitor). -use std::ffi::c_void; use std::os::windows::io::{AsRawHandle, OwnedHandle}; use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}; use std::sync::{Arc, Mutex, Once, OnceLock}; @@ -160,11 +159,11 @@ impl VirtualDisplayManager { /// double-open. fn ensure_device(&self) -> Result { if let Some(d) = self.device.get() { - return Ok(HANDLE(d.as_raw_handle() as *mut c_void)); + return Ok(HANDLE(d.as_raw_handle())); } let (handle, watchdog_s) = unsafe { self.driver.open()? }; self.watchdog_s.store(watchdog_s, Ordering::Relaxed); - let raw = HANDLE(handle.as_raw_handle() as *mut c_void); + let raw = HANDLE(handle.as_raw_handle()); let _ = self.device.set(Arc::new(handle)); Ok(raw) } @@ -174,7 +173,7 @@ impl VirtualDisplayManager { fn device_handle(&self) -> Option { self.device .get() - .map(|d| HANDLE(d.as_raw_handle() as *mut c_void)) + .map(|d| HANDLE(d.as_raw_handle())) } /// Open + initialise the backend (validates the driver is present). Mirrors the old diff --git a/crates/punktfunk-host/src/windows/service.rs b/crates/punktfunk-host/src/windows/service.rs index fc3eef2..5ca29bf 100644 --- a/crates/punktfunk-host/src/windows/service.rs +++ b/crates/punktfunk-host/src/windows/service.rs @@ -306,7 +306,7 @@ fn supervise(stop: HANDLE, session_ev: HANDLE) -> Result<()> { } // BORROW the owned job handle for AssignProcessToJobObject inside spawn_host. - let job_h = HANDLE(job.as_raw_handle() as *mut c_void); + let job_h = HANDLE(job.as_raw_handle()); let child = match unsafe { spawn_host(session, &cmdline, &workdir, job_h) } { Ok(child) => child, Err(e) => { @@ -323,7 +323,7 @@ fn supervise(stop: HANDLE, session_ev: HANDLE) -> Result<()> { // `proc_h` is a plain copy that does NOT close it). `child` owns the process + thread handles // and auto-closes BOTH when it drops — at the end of this iteration, on `continue`, or on // `break` — so every match arm below only stops/terminates and lets the drop do the closing. - let proc_h = HANDLE(child.process.as_raw_handle() as *mut c_void); + let proc_h = HANDLE(child.process.as_raw_handle()); // Wait on stop / session-change / child-exit. let reason = wait_any(&[stop, session_ev, proc_h], INFINITE); @@ -403,7 +403,7 @@ unsafe fn make_job() -> Result { info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK; SetInformationJobObject( - HANDLE(job.as_raw_handle() as *mut c_void), + HANDLE(job.as_raw_handle()), JobObjectExtendedLimitInformation, &info as *const _ as *const c_void, std::mem::size_of::() as u32, diff --git a/packaging/windows/drivers/pf-vdisplay/src/log.rs b/packaging/windows/drivers/pf-vdisplay/src/log.rs index cd94abe..af955b0 100644 --- a/packaging/windows/drivers/pf-vdisplay/src/log.rs +++ b/packaging/windows/drivers/pf-vdisplay/src/log.rs @@ -66,6 +66,10 @@ macro_rules! pod_init { ($t:ty) => {{ // SAFETY: $t is a C POD (windows-rs/WDK/IddCx struct); its all-zero bit pattern is a valid // zero-initialised value and the caller sets the required .Size/etc fields immediately after. - unsafe { ::core::mem::zeroed::<$t>() } + // `unused_unsafe`: pod_init! is also expanded at call sites already inside an `unsafe` block + // (where this `unsafe` is redundant), but it IS required at the non-unsafe sites — so allow it. + #[allow(unused_unsafe)] + let zeroed = unsafe { ::core::mem::zeroed::<$t>() }; + zeroed }}; }