fix(windows): clippy/build cleanups the on-glass build surfaced (-D warnings)

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) <noreply@anthropic.com>
This commit is contained in:
2026-06-26 07:15:00 +00:00
parent 658564353c
commit bd05bc8c30
5 changed files with 15 additions and 17 deletions
@@ -14,7 +14,6 @@ use super::dxgi::{make_device, D3d11Frame, HdrConverter, WinCaptureTarget};
use super::{CapturedFrame, Capturer, FramePayload, PixelFormat}; use super::{CapturedFrame, Capturer, FramePayload, PixelFormat};
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use pf_driver_proto::frame; use pf_driver_proto::frame;
use std::ffi::c_void;
use std::os::windows::io::{AsRawHandle, FromRawHandle, OwnedHandle}; use std::os::windows::io::{AsRawHandle, FromRawHandle, OwnedHandle};
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; 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. // 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 map = OwnedHandle::from_raw_handle(map.0 as _);
let view = MapViewOfFile( let view = MapViewOfFile(
HANDLE(map.as_raw_handle() as *mut c_void), HANDLE(map.as_raw_handle()),
FILE_MAP_ALL_ACCESS, FILE_MAP_ALL_ACCESS,
0, 0,
0, 0,
@@ -450,7 +449,7 @@ impl IddPushCapturer {
// Own the mapping handle so it (and its view) free via `MappedSection` RAII. // Own the mapping handle so it (and its view) free via `MappedSection` RAII.
let dm = OwnedHandle::from_raw_handle(dm.0 as _); let dm = OwnedHandle::from_raw_handle(dm.0 as _);
let dv = MapViewOfFile( let dv = MapViewOfFile(
HANDLE(dm.as_raw_handle() as *mut c_void), HANDLE(dm.as_raw_handle()),
FILE_MAP_ALL_ACCESS, FILE_MAP_ALL_ACCESS,
0, 0,
0, 0,
@@ -936,9 +935,7 @@ impl Capturer for IddPushCapturer {
fn next_frame(&mut self) -> Result<CapturedFrame> { fn next_frame(&mut self) -> Result<CapturedFrame> {
let deadline = Instant::now() + Duration::from_secs(20); let deadline = Instant::now() + Duration::from_secs(20);
loop { loop {
let _ = unsafe { let _ = unsafe { WaitForSingleObject(HANDLE(self.event.as_raw_handle()), 16) };
WaitForSingleObject(HANDLE(self.event.as_raw_handle() as *mut c_void), 16)
};
if let Some(f) = self.try_consume()? { if let Some(f) = self.try_consume()? {
return Ok(f); return Ok(f);
} }
+1 -3
View File
@@ -138,9 +138,7 @@ fn resolve_topology() -> SessionTopology {
let cfg = crate::config::config(); let cfg = crate::config::config();
// `NO_HELPER`/`NO_WGC` force single-process; IDD-push captures in-process in Session 0 (no helper); // `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). // 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() { let helper = if cfg.no_helper || crate::capture::wgc_disabled() || cfg.idd_push {
false
} else if cfg.idd_push {
false false
} else { } else {
cfg.force_helper || crate::capture::wgc_relay::running_as_system() cfg.force_helper || crate::capture::wgc_relay::running_as_system()
@@ -13,7 +13,6 @@
//! its `Drop` releases the refcount (a *stale* lease — its monitor was preempted + recreated under it — //! 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). //! 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::os::windows::io::{AsRawHandle, OwnedHandle};
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}; use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering};
use std::sync::{Arc, Mutex, Once, OnceLock}; use std::sync::{Arc, Mutex, Once, OnceLock};
@@ -160,11 +159,11 @@ impl VirtualDisplayManager {
/// double-open. /// double-open.
fn ensure_device(&self) -> Result<HANDLE> { fn ensure_device(&self) -> Result<HANDLE> {
if let Some(d) = self.device.get() { 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()? }; let (handle, watchdog_s) = unsafe { self.driver.open()? };
self.watchdog_s.store(watchdog_s, Ordering::Relaxed); 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)); let _ = self.device.set(Arc::new(handle));
Ok(raw) Ok(raw)
} }
@@ -174,7 +173,7 @@ impl VirtualDisplayManager {
fn device_handle(&self) -> Option<HANDLE> { fn device_handle(&self) -> Option<HANDLE> {
self.device self.device
.get() .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 /// Open + initialise the backend (validates the driver is present). Mirrors the old
+3 -3
View File
@@ -306,7 +306,7 @@ fn supervise(stop: HANDLE, session_ev: HANDLE) -> Result<()> {
} }
// BORROW the owned job handle for AssignProcessToJobObject inside spawn_host. // 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) } { let child = match unsafe { spawn_host(session, &cmdline, &workdir, job_h) } {
Ok(child) => child, Ok(child) => child,
Err(e) => { 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 // `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 // 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. // `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. // Wait on stop / session-change / child-exit.
let reason = wait_any(&[stop, session_ev, proc_h], INFINITE); let reason = wait_any(&[stop, session_ev, proc_h], INFINITE);
@@ -403,7 +403,7 @@ unsafe fn make_job() -> Result<OwnedHandle> {
info.BasicLimitInformation.LimitFlags = info.BasicLimitInformation.LimitFlags =
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK; JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK;
SetInformationJobObject( SetInformationJobObject(
HANDLE(job.as_raw_handle() as *mut c_void), HANDLE(job.as_raw_handle()),
JobObjectExtendedLimitInformation, JobObjectExtendedLimitInformation,
&info as *const _ as *const c_void, &info as *const _ as *const c_void,
std::mem::size_of::<JOBOBJECT_EXTENDED_LIMIT_INFORMATION>() as u32, std::mem::size_of::<JOBOBJECT_EXTENDED_LIMIT_INFORMATION>() as u32,
@@ -66,6 +66,10 @@ macro_rules! pod_init {
($t:ty) => {{ ($t:ty) => {{
// SAFETY: $t is a C POD (windows-rs/WDK/IddCx struct); its all-zero bit pattern is a valid // 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. // 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
}}; }};
} }