fix Windows clippy errors and unreachable code

Gate version detection behind cfg(unix), fix unreachable Ok(()) after
return in trust_ca, use next_back() and is_some_and() per clippy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Razvan Dimescu
2026-03-22 08:23:25 +02:00
parent 5495107c9e
commit 50d17ae118

View File

@@ -229,7 +229,7 @@ fn discover_windows() -> SystemDnsInfo {
let trimmed = line.trim(); let trimmed = line.trim();
// Match "DNS Servers" line (English) or similar localized variants // Match "DNS Servers" line (English) or similar localized variants
if trimmed.contains("DNS Servers") || trimmed.contains("DNS-Server") { if trimmed.contains("DNS Servers") || trimmed.contains("DNS-Server") {
if let Some(ip) = trimmed.split(':').last() { if let Some(ip) = trimmed.split(':').next_back() {
let ip = ip.trim(); let ip = ip.trim();
if !ip.is_empty() && ip != "127.0.0.1" && ip != "::1" { if !ip.is_empty() && ip != "127.0.0.1" && ip != "::1" {
upstream = Some(ip.to_string()); upstream = Some(ip.to_string());
@@ -238,7 +238,7 @@ fn discover_windows() -> SystemDnsInfo {
} }
} }
// Continuation lines (indented IPs after DNS Servers line) // Continuation lines (indented IPs after DNS Servers line)
if upstream.is_none() && trimmed.chars().next().map_or(false, |c| c.is_ascii_digit()) { if upstream.is_none() && trimmed.chars().next().is_some_and(|c| c.is_ascii_digit()) {
// Skip continuation lines — we only need the first DNS server // Skip continuation lines — we only need the first DNS server
} }
} }
@@ -484,13 +484,15 @@ pub fn uninstall_service() -> Result<(), String> {
/// Restart the service (kill process, launchd/systemd auto-restarts with new binary). /// Restart the service (kill process, launchd/systemd auto-restarts with new binary).
pub fn restart_service() -> Result<(), String> { pub fn restart_service() -> Result<(), String> {
// Show version of the binary that will be running after restart #[cfg(any(target_os = "macos", target_os = "linux"))]
let version = match std::process::Command::new("/usr/local/bin/numa") let version = {
match std::process::Command::new("/usr/local/bin/numa")
.arg("--version") .arg("--version")
.output() .output()
{ {
Ok(o) => String::from_utf8_lossy(&o.stderr).trim().to_string(), Ok(o) => String::from_utf8_lossy(&o.stderr).trim().to_string(),
Err(_) => "unknown".to_string(), Err(_) => "unknown".to_string(),
}
}; };
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
@@ -874,6 +876,7 @@ fn trust_ca() -> Result<(), String> {
return Err("CA trust not supported on this OS".into()); return Err("CA trust not supported on this OS".into());
} }
#[cfg(any(target_os = "macos", target_os = "linux"))]
Ok(()) Ok(())
} }