diff options
| author | Linus Färnstrand <faern@faern.net> | 2023-04-21 13:07:02 +0200 |
|---|---|---|
| committer | Linus Färnstrand <faern@faern.net> | 2023-04-21 13:24:07 +0200 |
| commit | 7ceb29d73f0b057e96410268bc2e1e822b4b1790 (patch) | |
| tree | def4a1b2dd53ba2ab489a6d833c5ca36be2528d8 | |
| parent | 764f1ac11668d4d44f87d683d293dcd4f3e8e240 (diff) | |
| download | mullvadvpn-7ceb29d73f0b057e96410268bc2e1e822b4b1790.tar.xz mullvadvpn-7ceb29d73f0b057e96410268bc2e1e822b4b1790.zip | |
Fix misc clippy warnings for Windows
| -rw-r--r-- | mullvad-paths/src/windows.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/dns/windows/auto.rs | 10 | ||||
| -rw-r--r-- | talpid-core/src/split_tunnel/windows/path_monitor.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/tunnel_state_machine/connecting_state.rs | 5 | ||||
| -rw-r--r-- | talpid-openvpn/src/wintun.rs | 2 | ||||
| -rw-r--r-- | talpid-tunnel/src/tun_provider/stub.rs | 6 | ||||
| -rw-r--r-- | talpid-windows-net/src/net.rs | 5 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt.rs | 2 |
8 files changed, 19 insertions, 19 deletions
diff --git a/mullvad-paths/src/windows.rs b/mullvad-paths/src/windows.rs index 8237a983b9..900f4b67e6 100644 --- a/mullvad-paths/src/windows.rs +++ b/mullvad-paths/src/windows.rs @@ -153,7 +153,7 @@ fn adjust_token_privilege( return Err(std::io::Error::last_os_error()); } - let mut privileges = TOKEN_PRIVILEGES { + let privileges = TOKEN_PRIVILEGES { PrivilegeCount: 1, Privileges: [LUID_AND_ATTRIBUTES { Luid: privilege_luid, @@ -164,7 +164,7 @@ fn adjust_token_privilege( AdjustTokenPrivileges( token_handle, 0, - &mut privileges, + &privileges, 0, ptr::null_mut(), ptr::null_mut(), diff --git a/talpid-core/src/dns/windows/auto.rs b/talpid-core/src/dns/windows/auto.rs index a09804b700..a5575820b3 100644 --- a/talpid-core/src/dns/windows/auto.rs +++ b/talpid-core/src/dns/windows/auto.rs @@ -44,13 +44,11 @@ impl DnsMonitorT for DnsMonitor { type Error = super::Error; fn new() -> Result<Self, Self::Error> { - let current_monitor; - - if iphlpapi::DnsMonitor::is_supported() { - current_monitor = InnerMonitor::Iphlpapi(iphlpapi::DnsMonitor::new()?); + let current_monitor = if iphlpapi::DnsMonitor::is_supported() { + InnerMonitor::Iphlpapi(iphlpapi::DnsMonitor::new()?) } else { - current_monitor = InnerMonitor::Netsh(netsh::DnsMonitor::new()?); - } + InnerMonitor::Netsh(netsh::DnsMonitor::new()?) + }; Ok(Self { current_monitor }) } diff --git a/talpid-core/src/split_tunnel/windows/path_monitor.rs b/talpid-core/src/split_tunnel/windows/path_monitor.rs index ce6fe827e0..db673f16e9 100644 --- a/talpid-core/src/split_tunnel/windows/path_monitor.rs +++ b/talpid-core/src/split_tunnel/windows/path_monitor.rs @@ -680,7 +680,7 @@ impl PathMonitor { /// Remove the element in `discarded_contexts` that owns the `OVERLAPPED` object, if it exists. fn free_discarded_context(&mut self, overlapped: *const OVERLAPPED) -> bool { - if overlapped == ptr::null_mut() { + if overlapped.is_null() { return false; } let mut was_discarded = false; @@ -773,7 +773,7 @@ impl PathMonitor { Err((error, result)) => { if error.raw_os_error() != Some(ERROR_OPERATION_ABORTED as i32) { log::error!("GetQueuedCompletionStatus failed: {:?}", error); - if result.used_overlapped == ptr::null_mut() { + if result.used_overlapped.is_null() { continue; } } diff --git a/talpid-core/src/tunnel_state_machine/connecting_state.rs b/talpid-core/src/tunnel_state_machine/connecting_state.rs index 821e076db6..8f1dafe2bf 100644 --- a/talpid-core/src/tunnel_state_machine/connecting_state.rs +++ b/talpid-core/src/tunnel_state_machine/connecting_state.rs @@ -528,10 +528,7 @@ fn should_retry(error: &tunnel::Error, retry_attempt: u32) -> bool { #[cfg(windows)] fn is_recoverable_routing_error(error: &talpid_routing::Error) -> bool { - match error { - talpid_routing::Error::AddRoutesFailed(_) => true, - _ => false, - } + matches!(error, talpid_routing::Error::AddRoutesFailed(_)) } impl TunnelState for ConnectingState { diff --git a/talpid-openvpn/src/wintun.rs b/talpid-openvpn/src/wintun.rs index 06fb443928..8b21ce9fd7 100644 --- a/talpid-openvpn/src/wintun.rs +++ b/talpid-openvpn/src/wintun.rs @@ -260,7 +260,7 @@ impl WintunDll { None => ptr::null_mut(), }; let handle = unsafe { (self.func_create)(name.as_ptr(), tunnel_type.as_ptr(), guid_ptr) }; - if handle == ptr::null_mut() { + if handle.is_null() { return Err(io::Error::last_os_error()); } Ok(handle) diff --git a/talpid-tunnel/src/tun_provider/stub.rs b/talpid-tunnel/src/tun_provider/stub.rs index ff659210cf..4227c2f8fb 100644 --- a/talpid-tunnel/src/tun_provider/stub.rs +++ b/talpid-tunnel/src/tun_provider/stub.rs @@ -15,3 +15,9 @@ impl StubTunProvider { unimplemented!(); } } + +impl Default for StubTunProvider { + fn default() -> Self { + Self::new() + } +} diff --git a/talpid-windows-net/src/net.rs b/talpid-windows-net/src/net.rs index 3491f3bf66..984b792e42 100644 --- a/talpid-windows-net/src/net.rs +++ b/talpid-windows-net/src/net.rs @@ -129,9 +129,8 @@ impl AddressFamily { /// Convert an [`AddressFamily`] to one of the `AF_*` constants. pub fn to_af_family(&self) -> u16 { match self { - // These values are both small enough to fit in a u16 - Self::Ipv4 => u16::try_from(AF_INET).unwrap(), - Self::Ipv6 => u16::try_from(AF_INET6).unwrap(), + Self::Ipv4 => AF_INET, + Self::Ipv6 => AF_INET6, } } } diff --git a/talpid-wireguard/src/wireguard_nt.rs b/talpid-wireguard/src/wireguard_nt.rs index bdb51c74a7..ced6ec4869 100644 --- a/talpid-wireguard/src/wireguard_nt.rs +++ b/talpid-wireguard/src/wireguard_nt.rs @@ -735,7 +735,7 @@ impl WgNtDll { None => ptr::null_mut(), }; let handle = unsafe { (self.func_create)(name.as_ptr(), tunnel_type.as_ptr(), guid_ptr) }; - if handle == ptr::null_mut() { + if handle.is_null() { return Err(io::Error::last_os_error()); } Ok(handle) |
