Skip to content

Commit

Permalink
Merge branch 'fix-clippy-lints' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Jan 2, 2024
2 parents 710a6fe + a160b3b commit cdd8c97
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion mullvad-api/src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl MullvadRestHandle {
}
match api_proxy.clone().get_api_addrs().await {
Ok(new_addrs) => {
if let Some(addr) = new_addrs.get(0) {
if let Some(addr) = new_addrs.first() {
log::debug!(
"Fetched new API address {:?}. Fetching again in {} hours",
addr,
Expand Down
12 changes: 6 additions & 6 deletions mullvad-daemon/src/access_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub enum Error {
NoSuchMethod(access_method::Id),
/// Access method could not be rotate
#[error(display = "Access method could not be rotated")]
RotationError,
RotationFailed,
/// Some error occured in the daemon's state of handling
/// [`AccessMethodSetting`]s & [`ApiConnectionMode`]s.
#[error(display = "Error occured when handling connection settings & details")]
ConnectionMode(#[error(source)] api::Error),
#[error(display = "API endpoint rotation failed")]
RestError(#[error(source)] rest::Error),
Rest(#[error(source)] rest::Error),
/// Access methods settings error
#[error(display = "Settings error")]
Settings(#[error(source)] settings::Error),
Expand Down Expand Up @@ -190,7 +190,7 @@ where
.await
.map_err(|error| {
log::error!("Failed to rotate API endpoint: {}", error);
Error::RotationError
Error::RotationFailed
})
}

Expand Down Expand Up @@ -261,7 +261,7 @@ pub async fn test_access_method(
.await
.map_err(|err| {
log::error!("Failed to rotate API endpoint: {err}");
Error::RestError(err)
Error::Rest(err)
})?;

// Set up the reset
Expand Down Expand Up @@ -289,7 +289,7 @@ pub async fn test_access_method(
let result = mullvad_api::ApiProxy::new(rest_handle)
.api_addrs_available()
.await
.map_err(Error::RestError)?;
.map_err(Error::Rest)?;

// We need to perform a rotation of API endpoint after a set action
// Note that this will be done automatically if the API call fails,
Expand All @@ -301,7 +301,7 @@ pub async fn test_access_method(
.await
.map_err(|err| {
log::error!("Failed to rotate API endpoint: {err}");
Error::RestError(err)
Error::Rest(err)
})?;
}

Expand Down
6 changes: 3 additions & 3 deletions mullvad-daemon/src/migrations/account_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn migrate_formats_inner(
} else if let Ok(token) = try_format_v1(account_bytes) {
Ok(token)
} else {
Err(Error::ParseHistoryError)
Err(Error::ParseHistory)
}
}

Expand Down Expand Up @@ -110,7 +110,7 @@ fn try_format_v2(bytes: &[u8]) -> Result<Option<(AccountToken, serde_json::Value
pub wireguard: serde_json::Value,
}
Ok(serde_json::from_slice::<'_, Vec<AccountEntry>>(bytes)
.map_err(|_error| Error::ParseHistoryError)?
.map_err(|_error| Error::ParseHistory)?
.into_iter()
.next()
.map(|entry| (entry.account, entry.wireguard)))
Expand All @@ -122,7 +122,7 @@ fn try_format_v1(bytes: &[u8]) -> Result<Option<AccountToken>> {
accounts: Vec<AccountToken>,
}
Ok(serde_json::from_slice::<'_, OldFormat>(bytes)
.map_err(|_error| Error::ParseHistoryError)?
.map_err(|_error| Error::ParseHistory)?
.accounts
.into_iter()
.next())
Expand Down
6 changes: 3 additions & 3 deletions mullvad-daemon/src/migrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ pub enum Error {
WriteHistory(#[error(source)] io::Error),

#[error(display = "Failed to parse account history")]
ParseHistoryError,
ParseHistory,

#[cfg(windows)]
#[error(display = "Failed to restore Windows update backup")]
WinMigrationError(#[error(source)] windows::Error),
WinMigration(#[error(source)] windows::Error),
}

pub type Result<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -119,7 +119,7 @@ pub async fn migrate_all(cache_dir: &Path, settings_dir: &Path) -> Result<Option
#[cfg(windows)]
windows::migrate_after_windows_update(settings_dir)
.await
.map_err(Error::WinMigrationError)?;
.map_err(Error::WinMigration)?;

let path = settings_dir.join(SETTINGS_FILE);

Expand Down
6 changes: 3 additions & 3 deletions mullvad-exclude/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum Error {
Exec(#[error(source)] nix::Error),

#[error(display = "An argument contains interior nul bytes")]
ArgumentNulError(#[error(source)] NulError),
ArgumentNul(#[error(source)] NulError),

#[error(display = "Failed to find net_cls controller")]
FindNetClsController(#[error(source)] io::Error),
Expand Down Expand Up @@ -76,13 +76,13 @@ fn main() {
fn run() -> Result<Infallible, Error> {
let mut args_iter = env::args_os().skip(1);
let program = args_iter.next().ok_or(Error::InvalidArguments)?;
let program = CString::new(program.as_bytes()).map_err(Error::ArgumentNulError)?;
let program = CString::new(program.as_bytes()).map_err(Error::ArgumentNul)?;

let args: Vec<CString> = env::args_os()
.skip(1)
.map(|arg| CString::new(arg.as_bytes()))
.collect::<Result<Vec<CString>, NulError>>()
.map_err(Error::ArgumentNulError)?;
.map_err(Error::ArgumentNul)?;

let cgroup_dir = find_net_cls_mount()
.map_err(Error::FindNetClsController)?
Expand Down
2 changes: 1 addition & 1 deletion talpid-openvpn/src/proxy/shadowsocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ShadowsocksProxyMonitor {

fn get_listener_addr(srv: &local::Server) -> io::Result<SocketAddr> {
let no_addr_err = || io::Error::new(io::ErrorKind::Other, "Missing listener address");
let socks_server = srv.socks_servers().get(0).ok_or_else(no_addr_err)?;
let socks_server = srv.socks_servers().first().ok_or_else(no_addr_err)?;
socks_server
.tcp_server()
.ok_or_else(no_addr_err)?
Expand Down
2 changes: 1 addition & 1 deletion talpid-routing/src/windows/get_best_default_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn get_best_default_route(family: AddressFamily) -> Result<Option<InterfaceA
annotated.sort_by(|lhs, rhs| lhs.effective_metric.cmp(&rhs.effective_metric));

annotated
.get(0)
.first()
.map(|annotated| {
Ok(InterfaceAndGateway {
iface: annotated.route.InterfaceLuid,
Expand Down
2 changes: 1 addition & 1 deletion talpid-routing/src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use futures::{
},
StreamExt,
};
pub use get_best_default_route::{get_best_default_route, route_has_gateway, InterfaceAndGateway};
pub use get_best_default_route::{get_best_default_route, InterfaceAndGateway};
use net::AddressFamily;
pub use route_manager::{Callback, CallbackHandle, Route, RouteManagerInternal};
use std::{collections::HashSet, io, net::IpAddr};
Expand Down
2 changes: 1 addition & 1 deletion talpid-routing/src/windows/route_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ fn interface_luid_from_gateway(gateway: &SOCKADDR_INET) -> Result<NET_LUID_LH> {
// Select the interface with the best (lowest) metric.
//
matches
.get(0)
.first()
.map(|interface| interface.Luid)
.ok_or_else(|| {
log::error!("Unable to find network adapter with specified gateway");
Expand Down
2 changes: 1 addition & 1 deletion talpid-tunnel-config-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod sys {
#[cfg(target_os = "windows")]
mod sys {
pub use std::os::windows::io::{AsRawSocket, RawSocket};
pub use windows_sys::Win32::Networking::WinSock::{IPPROTO_IP, IPPROTO_TCP, IP_USER_MTU};
pub use windows_sys::Win32::Networking::WinSock::{IPPROTO_IP, IP_USER_MTU};
}
use sys::*;

Expand Down

0 comments on commit cdd8c97

Please sign in to comment.