summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2023-04-24 16:26:38 +0200
committerDavid Lönnhager <david.l@mullvad.net>2023-04-26 11:02:59 +0200
commit45d3c24a44aea918c93bae7dabf5b69a9ddacb3a (patch)
tree2f27f582430e8e252e553857cc74eecdab42d8b4
parente1be481046f4086330135d831f39387883b2f453 (diff)
downloadmullvadvpn-45d3c24a44aea918c93bae7dabf5b69a9ddacb3a.tar.xz
mullvadvpn-45d3c24a44aea918c93bae7dabf5b69a9ddacb3a.zip
Fix remaining clippy warnings
-rw-r--r--mullvad-cli/src/cmds/split_tunnel/windows.rs2
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs2
-rw-r--r--mullvad-daemon/src/lib.rs4
-rw-r--r--mullvad-daemon/src/management_interface.rs3
-rw-r--r--mullvad-daemon/src/migrations/mod.rs6
-rw-r--r--mullvad-daemon/src/migrations/v6.rs3
-rw-r--r--mullvad-daemon/src/settings.rs3
-rw-r--r--mullvad-daemon/src/system_service.rs4
-rw-r--r--mullvad-version/build.rs7
-rw-r--r--talpid-core/build.rs4
-rw-r--r--talpid-core/src/firewall/mod.rs7
-rw-r--r--talpid-core/src/firewall/windows.rs4
-rw-r--r--talpid-core/src/offline/windows.rs1
-rw-r--r--talpid-core/src/split_tunnel/windows/path_monitor.rs4
-rw-r--r--talpid-tunnel-config-client/src/kyber.rs3
15 files changed, 30 insertions, 27 deletions
diff --git a/mullvad-cli/src/cmds/split_tunnel/windows.rs b/mullvad-cli/src/cmds/split_tunnel/windows.rs
index 9766607ce1..a133ab9682 100644
--- a/mullvad-cli/src/cmds/split_tunnel/windows.rs
+++ b/mullvad-cli/src/cmds/split_tunnel/windows.rs
@@ -21,7 +21,7 @@ impl Command for SplitTunnel {
.arg(
clap::Arg::new("policy")
.required(true)
- .possible_values(&["on", "off"]),
+ .possible_values(["on", "off"]),
),
)
.subcommand(clap::App::new("get").about("Display the split tunnel status"))
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index 647c3627d1..1d2fd1a7bb 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -92,7 +92,7 @@ fn create_wireguard_use_wg_nt_subcommand() -> clap::App<'static> {
clap::Arg::new("policy")
.required(true)
.takes_value(true)
- .possible_values(&["on", "off"]),
+ .possible_values(["on", "off"]),
),
)
}
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index b68bf8f0d0..3e18341818 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -1040,7 +1040,7 @@ where
#[cfg(target_os = "windows")]
UseWireGuardNt(tx, state) => self.on_use_wireguard_nt(tx, state).await,
#[cfg(target_os = "windows")]
- CheckVolumes(tx) => self.on_check_volumes(tx).await,
+ CheckVolumes(tx) => self.on_check_volumes(tx),
SetObfuscationSettings(tx, settings) => {
self.on_set_obfuscation_settings(tx, settings).await
}
@@ -1762,7 +1762,7 @@ where
}
#[cfg(windows)]
- async fn on_check_volumes(&mut self, tx: ResponseTx<(), Error>) {
+ fn on_check_volumes(&mut self, tx: ResponseTx<(), Error>) {
if self.volume_update_tx.unbounded_send(()).is_ok() {
let _ = tx.send(Ok(()));
}
diff --git a/mullvad-daemon/src/management_interface.rs b/mullvad-daemon/src/management_interface.rs
index c231c8a49e..ad2b556bcb 100644
--- a/mullvad-daemon/src/management_interface.rs
+++ b/mullvad-daemon/src/management_interface.rs
@@ -757,8 +757,7 @@ impl ManagementService for ManagementServiceImpl {
processes: processes
.into_iter()
.map(|process| types::ExcludedProcess {
- // FIXME: This is necessarily 32 bits or less
- pid: u32::try_from(process.pid).unwrap(),
+ pid: process.pid,
image: process.image.into_os_string().to_string_lossy().to_string(),
inherited: process.inherited,
})
diff --git a/mullvad-daemon/src/migrations/mod.rs b/mullvad-daemon/src/migrations/mod.rs
index 5d93045b04..8cf7b4a636 100644
--- a/mullvad-daemon/src/migrations/mod.rs
+++ b/mullvad-daemon/src/migrations/mod.rs
@@ -226,7 +226,7 @@ mod windows {
WrongOwner,
#[error(display = "Failed to copy files during migration")]
- IoError(#[error(source)] io::Error),
+ Io(#[error(source)] io::Error),
}
/// Attempts to restore the Mullvad settings from `C:\windows.old` after an update of Windows.
@@ -278,7 +278,7 @@ mod windows {
if !destination_settings_dir.exists() {
fs::create_dir_all(destination_settings_dir)
.await
- .map_err(Error::IoError)?;
+ .map_err(Error::Io)?;
}
let mut result = Ok(true);
@@ -303,7 +303,7 @@ mod windows {
))
);
if *required {
- result = Err(Error::IoError(error));
+ result = Err(Error::Io(error));
}
}
}
diff --git a/mullvad-daemon/src/migrations/v6.rs b/mullvad-daemon/src/migrations/v6.rs
index 66e6f90343..54dc2268e4 100644
--- a/mullvad-daemon/src/migrations/v6.rs
+++ b/mullvad-daemon/src/migrations/v6.rs
@@ -1,6 +1,5 @@
use super::{Error, Result};
-use mullvad_types::relay_constraints::Constraint;
-use mullvad_types::settings::SettingsVersion;
+use mullvad_types::{relay_constraints::Constraint, settings::SettingsVersion};
// ======================================================
// Section for vendoring types and values that
diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs
index ec73aabbe5..5e90067166 100644
--- a/mullvad-daemon/src/settings.rs
+++ b/mullvad-daemon/src/settings.rs
@@ -297,7 +297,8 @@ impl<'a> Display for SettingsSummary<'a> {
write!(f, "{}", content.join(" "))?;
}
DnsState::Custom => {
- // NOTE: Technically inaccurate, as the gateway IP is a local IP but isn't treated as one.
+ // NOTE: Technically inaccurate, as the gateway IP is a local IP but isn't treated
+ // as one.
let contains_local = self
.settings
.tunnel_options
diff --git a/mullvad-daemon/src/system_service.rs b/mullvad-daemon/src/system_service.rs
index 7b0a903324..9432e8449b 100644
--- a/mullvad-daemon/src/system_service.rs
+++ b/mullvad-daemon/src/system_service.rs
@@ -4,7 +4,7 @@ use mullvad_daemon::{runtime::new_runtime_builder, DaemonShutdownHandle};
use std::{
env,
ffi::OsString,
- mem, ptr, slice,
+ ptr, slice,
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
mpsc, Arc,
@@ -463,7 +463,7 @@ impl HibernationDetector {
break;
}
}
- mem::drop(logons);
+ // SAFETY: `logons` must no longer be referenced after this
unsafe { LsaFreeReturnBuffer(logon_session_list as *mut c_void) };
interactive
}
diff --git a/mullvad-version/build.rs b/mullvad-version/build.rs
index 2e1ce9f3c1..08145b0924 100644
--- a/mullvad-version/build.rs
+++ b/mullvad-version/build.rs
@@ -1,5 +1,8 @@
-use std::path::Path;
-use std::{env, fs, path::PathBuf, process::Command};
+use std::{
+ env, fs,
+ path::{Path, PathBuf},
+ process::Command,
+};
/// How many characters of the git commit that should be added to the version name
/// in dev builds.
diff --git a/talpid-core/build.rs b/talpid-core/build.rs
index e9afafe39c..1c16a35e74 100644
--- a/talpid-core/build.rs
+++ b/talpid-core/build.rs
@@ -2,10 +2,10 @@
mod win {
use std::{env, path::PathBuf};
- pub static WINFW_BUILD_DIR: &'static str = "..\\windows\\winfw\\bin";
+ pub static WINFW_BUILD_DIR: &str = "..\\windows\\winfw\\bin";
pub fn default_windows_build_artifact_dir(build_dir: &str) -> PathBuf {
- manifest_dir().join(build_dir).join(&target_platform_dir())
+ manifest_dir().join(build_dir).join(target_platform_dir())
}
fn target_platform_dir() -> PathBuf {
diff --git a/talpid-core/src/firewall/mod.rs b/talpid-core/src/firewall/mod.rs
index 2def49bc17..e168ec3f39 100644
--- a/talpid-core/src/firewall/mod.rs
+++ b/talpid-core/src/firewall/mod.rs
@@ -1,11 +1,10 @@
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};
use lazy_static::lazy_static;
-use std::net::IpAddr;
#[cfg(windows)]
use std::path::PathBuf;
use std::{
fmt,
- net::{Ipv4Addr, Ipv6Addr},
+ net::{IpAddr, Ipv4Addr, Ipv6Addr},
};
use talpid_types::net::{AllowedEndpoint, AllowedTunnelTraffic, Endpoint};
@@ -136,8 +135,8 @@ pub enum FirewallPolicy {
allow_lan: bool,
/// Host that should be reachable while in the blocked state.
allowed_endpoint: Option<AllowedEndpoint>,
- /// Destination port for DNS traffic redirection. Traffic destined to `127.0.0.1:53` will be
- /// redirected to `127.0.0.1:$dns_redirect_port`.
+ /// Destination port for DNS traffic redirection. Traffic destined to `127.0.0.1:53` will
+ /// be redirected to `127.0.0.1:$dns_redirect_port`.
#[cfg(target_os = "macos")]
dns_redirect_port: u16,
},
diff --git a/talpid-core/src/firewall/windows.rs b/talpid-core/src/firewall/windows.rs
index 9935834595..b7b4ac39f6 100644
--- a/talpid-core/src/firewall/windows.rs
+++ b/talpid-core/src/firewall/windows.rs
@@ -168,8 +168,8 @@ impl Firewall {
ptr::null()
};
- // SAFETY: `endpoint1_ip`, `endpoint2_ip`, `endpoint1` and `endpoint2` must not be dropped until
- // `WinFw_ApplyPolicyConnecting` has returned.
+ // SAFETY: `endpoint1_ip`, `endpoint2_ip`, `endpoint1` and `endpoint2` must not be dropped
+ // until `WinFw_ApplyPolicyConnecting` has returned.
let mut endpoint1_ip = WideCString::new();
let mut endpoint2_ip = WideCString::new();
let (endpoint1, endpoint2) = match allowed_tunnel_traffic {
diff --git a/talpid-core/src/offline/windows.rs b/talpid-core/src/offline/windows.rs
index d669a018fa..2756f9c690 100644
--- a/talpid-core/src/offline/windows.rs
+++ b/talpid-core/src/offline/windows.rs
@@ -138,6 +138,7 @@ impl BroadcastListener {
state.apply_change(change);
}
+ #[allow(clippy::unused_async)]
pub async fn host_is_offline(&self) -> bool {
let state = self.system_state.lock();
state.is_offline_currently()
diff --git a/talpid-core/src/split_tunnel/windows/path_monitor.rs b/talpid-core/src/split_tunnel/windows/path_monitor.rs
index cdee28c147..9470c66d9f 100644
--- a/talpid-core/src/split_tunnel/windows/path_monitor.rs
+++ b/talpid-core/src/split_tunnel/windows/path_monitor.rs
@@ -499,7 +499,7 @@ impl PathMonitor {
std::thread::spawn(move || {
loop {
- if !monitor.service_commands(&mut original_paths, &cmd_rx) {
+ if !monitor.process_command(&mut original_paths, &cmd_rx) {
break;
}
match monitor.handle_next_completion_packet() {
@@ -529,7 +529,7 @@ impl PathMonitor {
}
/// Handle the next command from the `PathMonitorHandle`, if there is one.
- fn service_commands(
+ fn process_command(
&mut self,
original_paths: &mut Vec<PathBuf>,
cmd_rx: &sync_mpsc::Receiver<PathMonitorCommand>,
diff --git a/talpid-tunnel-config-client/src/kyber.rs b/talpid-tunnel-config-client/src/kyber.rs
index 0946e7f5c2..5654b2e10b 100644
--- a/talpid-tunnel-config-client/src/kyber.rs
+++ b/talpid-tunnel-config-client/src/kyber.rs
@@ -6,7 +6,8 @@ pub use pqc_kyber::{keypair, KyberError};
/// benefit of going with anything lower.
pub const ALGORITHM_NAME: &str = "Kyber1024";
-// Always inline in order to try to avoid potential copies of `shared_secret` to multiple places on the stack.
+// Always inline in order to try to avoid potential copies of `shared_secret` to multiple places on
+// the stack.
#[inline(always)]
pub fn decapsulate(
secret_key: SecretKey,