Skip to content

Commit 18252c4

Browse files
committed
Try to fix more stuff
1 parent 5cdbeec commit 18252c4

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

netwatch/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ tokio = { version = "1", features = [
9494

9595
# wasm-in-browser test/dev dependencies
9696
[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dev-dependencies]
97+
derive_more = { version = "1.0.0", features = ["display"] }
9798
tracing-subscriber-wasm = "0.1.0"
9899
wasm-bindgen-test = "0.3"
99100

netwatch/src/interfaces/bsd.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ use std::{
88
sync::LazyLock,
99
};
1010

11-
use nested_enum_utils::common_fields;
12-
use snafu::{Backtrace, IntoError, OptionExt, Snafu};
13-
1411
use libc::{c_int, uintptr_t, AF_INET, AF_INET6, AF_LINK, AF_ROUTE, AF_UNSPEC, CTL_NET};
1512
#[cfg(any(target_os = "macos", target_os = "ios"))]
1613
use libc::{
1714
NET_RT_DUMP, RTAX_BRD, RTAX_DST, RTAX_GATEWAY, RTAX_MAX, RTAX_NETMASK, RTA_IFP, RTF_GATEWAY,
1815
};
16+
use nested_enum_utils::common_fields;
17+
use snafu::{Backtrace, IntoError, OptionExt, Snafu};
1918
use tracing::warn;
2019

2120
use super::DefaultRouteDetails;
@@ -409,7 +408,7 @@ impl WireFormat {
409408
continue;
410409
}
411410
name = std::str::from_utf8(&data[6..6 + i])
412-
.map_err(|_| RouteError::InvalidAddress)?
411+
.map_err(|_| InvalidAddressSnafu.build())?
413412
.to_string();
414413
break;
415414
}
@@ -447,9 +446,7 @@ struct RoutingStack {
447446

448447
/// Parses b as a routing information base and returns a list of routing messages.
449448
pub fn parse_rib(typ: RIBType, data: &[u8]) -> Result<Vec<WireMessage>, RouteError> {
450-
if !is_valid_rib_type(typ) {
451-
return Err(RouteError::InvalidRibType(typ));
452-
}
449+
snafu::ensure!(is_valid_rib_type(typ), InvalidRibTypeSnafu(typ));
453450

454451
let mut msgs = Vec::new();
455452
let mut nmsgs = 0;
@@ -796,9 +793,7 @@ where
796793
let a = parse_default_addr(b)?;
797794
addrs.push(a);
798795
let l = roundup(b[0] as usize);
799-
if b.len() < l {
800-
return Err(RouteError::MessageTooShort);
801-
}
796+
snafu::ensure!(b.len() >= l, MessageTooShortSnafu);
802797
b = &b[l..];
803798
}
804799
}
@@ -850,7 +845,7 @@ fn parse_inet_addr(af: i32, b: &[u8]) -> Result<Addr, RouteError> {
850845
zone,
851846
})
852847
}
853-
_ => Err(RouteError::InvalidAddress),
848+
_ => Err(InvalidAddressSnafu.build()),
854849
}
855850
}
856851

portmapper/src/pcp/protocol/response.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ pub enum DecodeError {
153153
}
154154

155155
impl PartialEq for DecodeError {
156+
#[allow(clippy::match_like_matches_macro)]
156157
fn eq(&self, other: &Self) -> bool {
157158
match (self, other) {
158159
(DecodeError::Malformed { .. }, DecodeError::Malformed { .. }) => true,

0 commit comments

Comments
 (0)