Skip to content

Commit 05944dc

Browse files
committed
make clippy happy
1 parent 9ab1f8b commit 05944dc

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

crates/shadowsocks-service/src/local/dns/upstream.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#[cfg(unix)]
44
use std::path::Path;
55
use std::{
6+
cmp::Ordering,
67
io::{self, ErrorKind},
78
net::SocketAddr,
89
sync::Arc,
@@ -170,20 +171,16 @@ impl DnsClient {
170171
libc::MSG_PEEK | libc::MSG_DONTWAIT,
171172
);
172173

173-
if ret == 0 {
174+
match ret.cmp(&0) {
174175
// EOF, connection lost
175-
false
176-
} else if ret > 0 {
176+
Ordering::Equal => false,
177177
// Data in buffer
178-
true
179-
} else {
180-
let err = io::Error::last_os_error();
181-
if err.kind() == ErrorKind::WouldBlock {
178+
Ordering::Greater => true,
179+
Ordering::Less => {
180+
let err = io::Error::last_os_error();
182181
// EAGAIN, EWOULDBLOCK
183182
// Still connected.
184-
true
185-
} else {
186-
false
183+
err.kind() == ErrorKind::WouldBlock
187184
}
188185
}
189186
}
@@ -208,20 +205,16 @@ impl DnsClient {
208205
MSG_PEEK,
209206
);
210207

211-
if ret == 0 {
208+
match ret.cmp(&0) {
212209
// EOF, connection lost
213-
false
214-
} else if ret > 0 {
210+
Ordering::Equal => false,
215211
// Data in buffer
216-
true
217-
} else {
218-
let err = io::Error::last_os_error();
219-
if err.kind() == ErrorKind::WouldBlock {
212+
Ordering::Greater => true,
213+
Ordering::Less => {
214+
let err = io::Error::last_os_error();
220215
// I have to trust the `s` have already set to non-blocking mode
221216
// Becuase windows doesn't have MSG_DONTWAIT
222-
true
223-
} else {
224-
false
217+
err.kind() == ErrorKind::WouldBlock
225218
}
226219
}
227220
}

0 commit comments

Comments
 (0)