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 a74d9a4bbb
commit ca1f51652b

View File

@@ -229,7 +229,7 @@ fn discover_windows() -> SystemDnsInfo {
let trimmed = line.trim();
// Match "DNS Servers" line (English) or similar localized variants
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();
if !ip.is_empty() && ip != "127.0.0.1" && ip != "::1" {
upstream = Some(ip.to_string());
@@ -238,7 +238,7 @@ fn discover_windows() -> SystemDnsInfo {
}
}
// 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
}
}
@@ -484,13 +484,15 @@ pub fn uninstall_service() -> Result<(), String> {
/// Restart the service (kill process, launchd/systemd auto-restarts with new binary).
pub fn restart_service() -> Result<(), String> {
// Show version of the binary that will be running after restart
let version = match std::process::Command::new("/usr/local/bin/numa")
#[cfg(any(target_os = "macos", target_os = "linux"))]
let version = {
match std::process::Command::new("/usr/local/bin/numa")
.arg("--version")
.output()
{
Ok(o) => String::from_utf8_lossy(&o.stderr).trim().to_string(),
Err(_) => "unknown".to_string(),
}
};
#[cfg(target_os = "macos")]
@@ -874,6 +876,7 @@ fn trust_ca() -> Result<(), String> {
return Err("CA trust not supported on this OS".into());
}
#[cfg(any(target_os = "macos", target_os = "linux"))]
Ok(())
}