summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2023-04-21 13:06:49 +0200
committerLinus Färnstrand <faern@faern.net>2023-04-21 13:06:49 +0200
commit764f1ac11668d4d44f87d683d293dcd4f3e8e240 (patch)
treea300e9868a691af07b94010865c40f71c19d17e5
parent9af6a50e24714ab191527d6a5a786ae4491f4574 (diff)
downloadmullvadvpn-764f1ac11668d4d44f87d683d293dcd4f3e8e240.tar.xz
mullvadvpn-764f1ac11668d4d44f87d683d293dcd4f3e8e240.zip
Fix clippy warnings in Windows route manager
-rw-r--r--talpid-routing/src/windows/route_manager.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/talpid-routing/src/windows/route_manager.rs b/talpid-routing/src/windows/route_manager.rs
index 4a3713f7e3..14fbbf3f52 100644
--- a/talpid-routing/src/windows/route_manager.rs
+++ b/talpid-routing/src/windows/route_manager.rs
@@ -173,7 +173,7 @@ impl RouteManagerInternal {
});
let existing_record_idx =
- Self::find_route_record(&mut route_manager_routes, &new_record.registered_route);
+ Self::find_route_record(&route_manager_routes, &new_record.registered_route);
match existing_record_idx {
None => route_manager_routes.push(new_record),
@@ -311,13 +311,13 @@ impl RouteManagerInternal {
}
}
- fn find_route_record(records: &mut Vec<RouteRecord>, route: &RegisteredRoute) -> Option<usize> {
+ fn find_route_record(records: &[RouteRecord], route: &RegisteredRoute) -> Option<usize> {
records
.iter()
.position(|record| route == &record.registered_route)
}
- fn undo_events(event_log: &Vec<EventEntry>, records: &mut Vec<RouteRecord>) -> Result<()> {
+ fn undo_events(event_log: &[EventEntry], records: &mut Vec<RouteRecord>) -> Result<()> {
// Rewind state by processing events in the reverse order.
//
@@ -446,7 +446,7 @@ impl RouteManagerInternal {
//
for record in (*routes).iter() {
- if let Err(_) = Self::delete_from_routing_table(&record.registered_route) {
+ if Self::delete_from_routing_table(&record.registered_route).is_err() {
log::error!(
"Failed to delete route while clearing applied routes, {}",
record.registered_route
@@ -481,8 +481,7 @@ impl RouteManagerInternal {
{
let (_, callbacks) = &mut *callbacks.lock().unwrap();
for callback in callbacks.values() {
- let family =
- AddressFamily::try_from_af_family(u16::try_from(family).unwrap()).unwrap();
+ let family = AddressFamily::try_from_af_family(family).unwrap();
callback(event_type, family);
}
}
@@ -714,8 +713,8 @@ impl Adapters {
/// Create a new linked list of adapters from the windows API
fn new(family: ADDRESS_FAMILY, flags: GET_ADAPTERS_ADDRESSES_FLAGS) -> Result<Self> {
const MSDN_RECOMMENDED_STARTING_BUFFER_SIZE: usize = 1024 * 15;
- let mut buffer: Vec<u8> = Vec::with_capacity(MSDN_RECOMMENDED_STARTING_BUFFER_SIZE);
- buffer.resize(MSDN_RECOMMENDED_STARTING_BUFFER_SIZE, 0);
+
+ let mut buffer: Vec<u8> = vec![0; MSDN_RECOMMENDED_STARTING_BUFFER_SIZE];
let mut buffer_size = u32::try_from(buffer.len()).unwrap();
let mut buffer_pointer = buffer.as_mut_ptr();