Skip to content

Commit

Permalink
chore(shadowsocks): clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Jun 16, 2024
1 parent 285a72d commit 5d965ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/shadowsocks/src/net/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,24 @@ static IP_STACK_CAPABILITIES: Lazy<IpStackCapabilities> = Lazy::new(|| {
};

// Check IPv4
if let Ok(_) = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)) {
if Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).is_ok() {
caps.support_ipv4 = true;
debug!("IpStackCapability support_ipv4=true");
}

// Check IPv6 (::1)
if let Ok(ipv6_socket) = Socket::new(Domain::IPV6, Type::STREAM, Some(Protocol::TCP)) {
if let Ok(..) = ipv6_socket.set_only_v6(true) {
if ipv6_socket.set_only_v6(true).is_ok() {
let local_host = SockAddr::from(SocketAddr::new(Ipv6Addr::LOCALHOST.into(), 0));
if let Ok(..) = ipv6_socket.bind(&local_host) {
if ipv6_socket.bind(&local_host).is_ok() {
caps.support_ipv6 = true;
debug!("IpStackCapability support_ipv6=true");
}
}
}

// Check IPv4-mapped-IPv6 (127.0.0.1)
if let Ok(..) = check_ipv4_mapped_ipv6_capability() {
if check_ipv4_mapped_ipv6_capability().is_ok() {
caps.support_ipv4_mapped_ipv6 = true;
debug!("IpStackCapability support_ipv4_mapped_ipv6=true");
}
Expand All @@ -192,7 +192,7 @@ fn check_ipv4_mapped_ipv6_capability() -> io::Result<()> {
return Err(io::Error::new(
ErrorKind::Other,
"local_addr shouldn't be an IPv4 address",
))
));
}
SocketAddr::V6(ref v6) => {
if let None = v6.ip().to_ipv4_mapped() {

Check warning on line 198 in crates/shadowsocks/src/net/sys/mod.rs

View workflow job for this annotation

GitHub Actions / clippy ubuntu-latest

redundant pattern matching, consider using `is_none()`

warning: redundant pattern matching, consider using `is_none()` --> crates/shadowsocks/src/net/sys/mod.rs:198:24 | 198 | if let None = v6.ip().to_ipv4_mapped() { | -------^^^^--------------------------- help: try: `if v6.ip().to_ipv4_mapped().is_none()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching = note: `#[warn(clippy::redundant_pattern_matching)]` on by default

Check warning on line 198 in crates/shadowsocks/src/net/sys/mod.rs

View workflow job for this annotation

GitHub Actions / clippy macos-latest

redundant pattern matching, consider using `is_none()`

warning: redundant pattern matching, consider using `is_none()` --> crates/shadowsocks/src/net/sys/mod.rs:198:24 | 198 | if let None = v6.ip().to_ipv4_mapped() { | -------^^^^--------------------------- help: try: `if v6.ip().to_ipv4_mapped().is_none()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching = note: `#[warn(clippy::redundant_pattern_matching)]` on by default
Expand Down

0 comments on commit 5d965ab

Please sign in to comment.