From 6bd40640bfc9e5b94f6f04c1cf395d246319733d Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Sun, 17 May 2026 17:55:52 +0000 Subject: [PATCH] chore: quiet platform-specific warnings The non-Linux test build was emitting warnings from code that is intentionally platform-specific: the nftables firewall parser is Linux-only, the utun address-family helper is only used in macOS TUN paths, and one macOS Ethernet test module trips a clippy layout lint. These warnings made focused test runs noisy and encouraged bundling unrelated warning fixes into behavioral PRs. - Gate the firewall parser dead-code allowance to non-Linux targets, where the parser is compiled but not used. - Mark the macOS utun helper and long TUN reader entry point with narrow allowances. - Rewrite the small MAC-copy loop to satisfy clippy and mark the macOS Ethernet test module layout explicitly. No runtime behavior change. --- src/control/firewall_state.rs | 2 ++ src/transport/ethernet/socket_macos.rs | 5 +++-- src/upper/tun.rs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/control/firewall_state.rs b/src/control/firewall_state.rs index 10f7c3d..1bf8d71 100644 --- a/src/control/firewall_state.rs +++ b/src/control/firewall_state.rs @@ -31,6 +31,8 @@ //! and the ICMPv6-echo-request accept are not classified — they //! don't pertain to listening TCP/UDP ports the operator binds. +#![cfg_attr(not(target_os = "linux"), allow(dead_code))] + use serde_json::Value; use crate::control::listening::Proto; diff --git a/src/transport/ethernet/socket_macos.rs b/src/transport/ethernet/socket_macos.rs index 4f24fdc..b31eaf5 100644 --- a/src/transport/ethernet/socket_macos.rs +++ b/src/transport/ethernet/socket_macos.rs @@ -534,8 +534,8 @@ fn get_mac_addr(interface: &str) -> Result<[u8; 6], TransportError> { // MAC address starts after the interface name in sdl_data let data_ptr = sdl.sdl_data.as_ptr(); let mut mac = [0u8; 6]; - for i in 0..6 { - mac[i] = unsafe { *data_ptr.add(nlen + i) } as u8; + for (i, byte) in mac.iter_mut().enumerate() { + *byte = unsafe { *data_ptr.add(nlen + i) } as u8; } return Ok(mac); } @@ -565,6 +565,7 @@ fn get_mac_addr(interface: &str) -> Result<[u8; 6], TransportError> { #[cfg(test)] #[cfg(target_os = "macos")] +#[allow(clippy::items_after_test_module)] mod tests { use super::*; diff --git a/src/upper/tun.rs b/src/upper/tun.rs index 0d01dcb..e9dddd6 100644 --- a/src/upper/tun.rs +++ b/src/upper/tun.rs @@ -389,6 +389,7 @@ fn utun_af_inet6_header() -> [u8; 4] { /// from the dup'd fd directly. #[cfg(target_os = "macos")] #[inline] +#[allow(dead_code)] fn parse_utun_af_prefix(buf: &[u8]) -> Option { if buf.len() < 4 { return None; @@ -565,6 +566,7 @@ impl Drop for ShutdownFd { /// avoiding the need to close the TUN fd externally (which would cause a /// double-close when `TunDevice` drops). #[cfg(target_os = "macos")] +#[allow(clippy::too_many_arguments)] pub fn run_tun_reader( mut device: TunDevice, mtu: u16,