`packaging/windows/drivers/*` has run `deny(unsafe_op_in_unsafe_fn)` +
`deny(clippy::undocumented_unsafe_blocks)` for a while, with `forbid(unsafe_code)`
on the modules that need no unsafe at all. The main workspace had no lint config
whatsoever, so nothing stopped a clean crate from quietly growing an `unsafe`, and
nothing distinguished the handful of genuinely-unsafe lines inside a 600-line
`unsafe fn` from the safe ones surrounding them.
Three things, all mechanical:
* `#![forbid(unsafe_code)]` on the eight crates that already contain zero unsafe
(`pf-driver-proto`, `pf-host-config`, `pf-paths`, the three clean clients, both
tools). These were clean by accident, not by contract; now they are clean by
contract.
* `unsafe_op_in_unsafe_fn = "warn"` workspace-wide. `unsafe fn` states a contract
the CALLER must uphold — it was never meant to switch off checking for the whole
body. Measured fallout is 300 sites on Linux, and they are concentrated: six
files carry all of them, while `punktfunk-core`, `pf-frame`, `pf-clipboard` and
`pf-vdisplay` are already at zero. `warn` (not `deny`) so the build stays green
while those six are worked down; it flips to `deny` once they are. This is also
the Rust 2024 default, so it pays off the edition migration early.
* `proc::current_uid()` replaces eight `unsafe { libc::getuid() }` blocks. Each
site had copied out the same SAFETY note verbatim, which is the tell: `getuid()`
is parameterless, always succeeds and touches no memory, so there is no contract
for a caller to uphold and no reason for the unsafe to be visible eight times.
One `unsafe` behind a safe wrapper, none at the call sites.
Verified: `pf-vdisplay` builds clean on Linux (Nobara) at zero E0133; the
macOS-buildable crates build clean locally. No behaviour change.
42 lines
1.9 KiB
TOML
42 lines
1.9 KiB
TOML
# The Windows display-topology cluster (plan §W6): CCD/GDI path activation, mode-setting, HDR
|
|
# advanced-colour toggles, source-rect geometry ([`win_display`]); PnP monitor devnode enable/disable
|
|
# ([`monitor_devnode`]); and the WM_DISPLAYCHANGE / device-arrival watch ([`display_events`]). A leaf
|
|
# so the IDD-push capturer (pf-capture) and the pf-vdisplay backend (host) depend on it as a PEER
|
|
# instead of the capturer reaching back into the host for display utilities. Windows-only content;
|
|
# compiles to an empty lib elsewhere.
|
|
[package]
|
|
name = "pf-win-display"
|
|
version.workspace = true
|
|
edition = "2021"
|
|
rust-version.workspace = true
|
|
license = "MIT OR Apache-2.0"
|
|
description = "punktfunk host Windows display-topology helpers: CCD/GDI mode-set + path activation, HDR advanced colour, PnP monitor devnodes, and the display-change event watch."
|
|
publish = false
|
|
|
|
[target.'cfg(target_os = "windows")'.dependencies]
|
|
# `Mode` (the negotiated display mode) is the core wire type; `pf-paths` for the pnp-disabled-monitors
|
|
# state file.
|
|
punktfunk-core = { path = "../punktfunk-core", features = ["quic"] }
|
|
pf-paths = { path = "../pf-paths" }
|
|
anyhow = "1"
|
|
tracing = "0.1"
|
|
# The pnp-disabled-monitors state file (a `Vec<String>` of instance ids) is serialized as JSON.
|
|
serde_json = "1"
|
|
windows = { version = "0.62", features = [
|
|
"Win32_Foundation",
|
|
"Win32_Devices_DeviceAndDriverInstallation",
|
|
"Win32_Devices_Display",
|
|
"Win32_Graphics_Gdi",
|
|
"Win32_UI_WindowsAndMessaging",
|
|
"Win32_System_LibraryLoader",
|
|
# console_session_mismatch: WTSGetActiveConsoleSessionId + ProcessIdToSessionId + GetCurrentProcessId.
|
|
"Win32_System_RemoteDesktop",
|
|
# input_desktop: OpenInputDesktop/SetThreadDesktop/GetUserObjectInformationW — display writes
|
|
# follow the input desktop so a UAC/lock screen can't refuse them.
|
|
"Win32_System_StationsAndDesktops",
|
|
"Win32_System_Threading",
|
|
] }
|
|
|
|
[lints]
|
|
workspace = true
|