diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2023-04-24 11:43:30 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2023-04-24 11:43:30 +0200 |
| commit | c826091de45ae9af387472d24ecebb7ad5600fad (patch) | |
| tree | ec81a5e1fd10265e199eff08a4a3b5ce6e068943 | |
| parent | 905a2860b18540fbb39bf0afaaf563fa365ef252 (diff) | |
| parent | 21fb0a5693f08b9cd5667a3869b8de75d634f737 (diff) | |
| download | mullvadvpn-c826091de45ae9af387472d24ecebb7ad5600fad.tar.xz mullvadvpn-c826091de45ae9af387472d24ecebb7ad5600fad.zip | |
Merge branch 'clippy-fix-windows-3'
| -rw-r--r-- | talpid-core/src/dns/windows/dnsapi.rs | 19 | ||||
| -rw-r--r-- | talpid-core/src/ffi.rs | 6 | ||||
| -rw-r--r-- | talpid-core/src/firewall/windows.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/split_tunnel/windows/path_monitor.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/mod.rs | 9 | ||||
| -rw-r--r-- | talpid-core/src/window.rs | 18 | ||||
| -rw-r--r-- | talpid-windows-net/src/net.rs | 1 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_go.rs | 2 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt.rs | 2 |
9 files changed, 36 insertions, 25 deletions
diff --git a/talpid-core/src/dns/windows/dnsapi.rs b/talpid-core/src/dns/windows/dnsapi.rs index f315aba3f4..9554c874db 100644 --- a/talpid-core/src/dns/windows/dnsapi.rs +++ b/talpid-core/src/dns/windows/dnsapi.rs @@ -82,16 +82,15 @@ impl DnsApi { } fn flush_cache(&self) -> Result<(), Error> { - if self - .in_flight_flush_count - .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| { - if val >= MAX_CONCURRENT_FLUSHES { - return None; - } - Some(val + 1) - }) - .is_err() - { + let update_flush_count_result = + self.in_flight_flush_count + .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| { + if val >= MAX_CONCURRENT_FLUSHES { + return None; + } + Some(val + 1) + }); + if update_flush_count_result.is_err() { return Err(Error::TooManyFlushAttempts); } diff --git a/talpid-core/src/ffi.rs b/talpid-core/src/ffi.rs index 7f994b787a..dda7de9bd7 100644 --- a/talpid-core/src/ffi.rs +++ b/talpid-core/src/ffi.rs @@ -17,9 +17,9 @@ macro_rules! ffi_error { } } - impl Into<Result<(), Error>> for $result { - fn into(self) -> Result<(), Error> { - self.into_result() + impl From<$result> for Result<(), Error> { + fn from(result: $result) -> Self { + result.into_result() } } }; diff --git a/talpid-core/src/firewall/windows.rs b/talpid-core/src/firewall/windows.rs index 6ec3fcc102..9935834595 100644 --- a/talpid-core/src/firewall/windows.rs +++ b/talpid-core/src/firewall/windows.rs @@ -231,7 +231,9 @@ impl Firewall { // has returned. drop(endpoint1_ip); drop(endpoint2_ip); + #[allow(clippy::drop_non_drop)] drop(endpoint1); + #[allow(clippy::drop_non_drop)] drop(endpoint2); res } diff --git a/talpid-core/src/split_tunnel/windows/path_monitor.rs b/talpid-core/src/split_tunnel/windows/path_monitor.rs index db673f16e9..fa90896024 100644 --- a/talpid-core/src/split_tunnel/windows/path_monitor.rs +++ b/talpid-core/src/split_tunnel/windows/path_monitor.rs @@ -419,7 +419,7 @@ struct StrippedPath { } impl StrippedPath { - fn new(path: &PathBuf) -> io::Result<StrippedPath> { + fn new(path: &Path) -> io::Result<StrippedPath> { let mut iter = path.components(); let prefix = iter.next().ok_or(io::Error::new( io::ErrorKind::InvalidInput, diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs index 15422f0b94..aa875ac83c 100644 --- a/talpid-core/src/tunnel/mod.rs +++ b/talpid-core/src/tunnel/mod.rs @@ -109,13 +109,8 @@ impl TunnelMonitor { let resource_dir = resource_dir.to_path_buf(); let process_string = match params { TunnelParameters::OpenVpn(params) => { - if let Some(proxy) = ¶ms.proxy { - match proxy { - openvpn_types::ProxySettings::Shadowsocks(..) => { - return std::env::current_exe().unwrap() - } - _ => "openvpn.exe", - } + if let Some(openvpn_types::ProxySettings::Shadowsocks(..)) = ¶ms.proxy { + return std::env::current_exe().unwrap(); } else { "openvpn.exe" } diff --git a/talpid-core/src/window.rs b/talpid-core/src/window.rs index a9bf945eb1..a78080d716 100644 --- a/talpid-core/src/window.rs +++ b/talpid-core/src/window.rs @@ -64,7 +64,13 @@ pub fn create_hidden_window<F: (Fn(HWND, u32, WPARAM, LPARAM) -> LRESULT) + Send unsafe { SetWindowLongPtrW(dummy_window, GWLP_USERDATA, raw_callback as isize); - SetWindowLongPtrW(dummy_window, GWLP_WNDPROC, window_procedure::<F> as isize); + SetWindowLongPtrW( + dummy_window, + GWLP_WNDPROC, + // Clippy does not like casting function pointers to anything but usize. + // But this is correct, since the Windows API expects a signed int for pointer. + window_procedure::<F> as usize as isize, + ); } let mut msg = unsafe { std::mem::zeroed() }; @@ -85,8 +91,8 @@ pub fn create_hidden_window<F: (Fn(HWND, u32, WPARAM, LPARAM) -> LRESULT) + Send } } else { unsafe { - TranslateMessage(&mut msg); - DispatchMessageW(&mut msg); + TranslateMessage(&msg); + DispatchMessageW(&msg); } } } @@ -196,6 +202,12 @@ impl PowerManagementListener { } } +impl Default for PowerManagementListener { + fn default() -> Self { + Self::new() + } +} + impl Clone for PowerManagementListener { fn clone(&self) -> Self { Self { diff --git a/talpid-windows-net/src/net.rs b/talpid-windows-net/src/net.rs index 984b792e42..cd7ff14358 100644 --- a/talpid-windows-net/src/net.rs +++ b/talpid-windows-net/src/net.rs @@ -138,6 +138,7 @@ impl AddressFamily { /// Context for [`notify_ip_interface_change`]. When it is dropped, /// the callback is unregistered. pub struct IpNotifierHandle<'a> { + #[allow(clippy::type_complexity)] callback: Mutex<Box<dyn FnMut(&MIB_IPINTERFACE_ROW, i32) + Send + 'a>>, handle: HANDLE, } diff --git a/talpid-wireguard/src/wireguard_go.rs b/talpid-wireguard/src/wireguard_go.rs index d4d542ff59..8b9f1f696d 100644 --- a/talpid-wireguard/src/wireguard_go.rs +++ b/talpid-wireguard/src/wireguard_go.rs @@ -437,7 +437,7 @@ extern "C" { iface_name: *const i8, mtu: i64, settings: *const i8, - iface_name_out: *const *mut std::os::raw::c_char, + iface_name_out: *mut *mut std::os::raw::c_char, iface_luid_out: *mut u64, logging_callback: Option<LoggingCallback>, logging_context: *mut libc::c_void, diff --git a/talpid-wireguard/src/wireguard_nt.rs b/talpid-wireguard/src/wireguard_nt.rs index 4ae7901a02..6fcc6ffd0b 100644 --- a/talpid-wireguard/src/wireguard_nt.rs +++ b/talpid-wireguard/src/wireguard_nt.rs @@ -597,6 +597,7 @@ impl WgNtAdapter { } } + #[allow(clippy::type_complexity)] fn get_config(&self) -> Result<(WgInterface, Vec<(WgPeer, Vec<WgAllowedIp>)>)> { unsafe { deserialize_config( @@ -881,6 +882,7 @@ fn serialize_config(config: &Config) -> Result<Vec<MaybeUninit<u8>>> { Ok(buffer) } +#[allow(clippy::type_complexity)] unsafe fn deserialize_config( config: &[MaybeUninit<u8>], ) -> Result<(WgInterface, Vec<(WgPeer, Vec<WgAllowedIp>)>)> { |
