Skip to content

Commit d10746e

Browse files
committed
fix: resolve fmt and clippy warnings
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 7f1cc6f commit d10746e

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

host/src/lib.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,10 +1635,7 @@ fn handle_net_poll(
16351635
.get("fds")
16361636
.and_then(|v| v.as_array())
16371637
.ok_or_else(|| anyhow!("net_poll: missing 'fds' array"))?;
1638-
let timeout_ms = args
1639-
.get("timeout_ms")
1640-
.and_then(|v| v.as_i64())
1641-
.unwrap_or(0) as libc::c_int;
1638+
let timeout_ms = args.get("timeout_ms").and_then(|v| v.as_i64()).unwrap_or(0) as libc::c_int;
16421639

16431640
let tbl = table.lock().unwrap();
16441641
let mut pollfds: Vec<libc::pollfd> = Vec::new();
@@ -1649,10 +1646,7 @@ fn handle_net_poll(
16491646
.get("fd")
16501647
.and_then(|v| v.as_u64())
16511648
.ok_or_else(|| anyhow!("net_poll: entry missing 'fd'"))?;
1652-
let events = entry
1653-
.get("events")
1654-
.and_then(|v| v.as_i64())
1655-
.unwrap_or(0) as i16;
1649+
let events = entry.get("events").and_then(|v| v.as_i64()).unwrap_or(0) as i16;
16561650
if let Ok(sock) = tbl.get_socket(fd) {
16571651
pollfds.push(libc::pollfd {
16581652
fd: sock.as_raw_fd(),
@@ -1716,7 +1710,7 @@ fn hl_sleep_poll_sockets(
17161710
return Ok(json!({}));
17171711
}
17181712

1719-
let timeout_ms = ((ns / 1_000_000) as libc::c_int).max(1).min(30_000);
1713+
let timeout_ms = ((ns / 1_000_000) as libc::c_int).clamp(1, 30_000);
17201714
let ret = unsafe {
17211715
libc::poll(
17221716
pollfds.as_mut_ptr(),

0 commit comments

Comments
 (0)