*: Fix various clippy warnings (#2900)

This commit is contained in:
Hannes
2022-09-16 16:30:11 +02:00
committed by GitHub
parent 2c739e9bdb
commit c81b06a9b2
4 changed files with 13 additions and 30 deletions

View File

@@ -85,7 +85,7 @@ where
socket.bind(&SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 5353).into())?;
socket.set_multicast_loop_v4(true)?;
socket.set_multicast_ttl_v4(255)?;
socket.join_multicast_v4(&*crate::IPV4_MDNS_MULTICAST_ADDRESS, &addr)?;
socket.join_multicast_v4(&crate::IPV4_MDNS_MULTICAST_ADDRESS, &addr)?;
U::from_std(UdpSocket::from(socket))?
}
IpAddr::V6(_) => {
@@ -96,7 +96,7 @@ where
socket.bind(&SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 5353).into())?;
socket.set_multicast_loop_v6(true)?;
// TODO: find interface matching addr.
socket.join_multicast_v6(&*crate::IPV6_MDNS_MULTICAST_ADDRESS, 0)?;
socket.join_multicast_v6(&crate::IPV6_MDNS_MULTICAST_ADDRESS, 0)?;
U::from_std(UdpSocket::from(socket))?
}
};

View File

@@ -246,7 +246,7 @@ fn query_response_packet(id: u16, peer_id: &[u8], records: &[Vec<u8>], ttl: u32)
fn duration_to_secs(duration: Duration) -> u32 {
let secs = duration
.as_secs()
.saturating_add(if duration.subsec_nanos() > 0 { 1 } else { 0 });
.saturating_add(u64::from(duration.subsec_nanos() > 0));
cmp::min(secs, From::from(u32::max_value())) as u32
}