Merge pull request #411 from crawford/non_exhaustive

Various cleanup
This commit is contained in:
Dario Nieuwenhuis 2021-01-16 01:32:28 +01:00 committed by GitHub
commit db39ffd2ad
6 changed files with 10 additions and 18 deletions

View File

@ -1026,12 +1026,9 @@ impl<'b, 'c, 'e> InterfaceInner<'b, 'c, 'e> {
!self.has_multicast_group(ipv4_repr.dst_addr) {
// Ignore IP packets not directed at us, or broadcast, or any of the multicast groups.
// If AnyIP is enabled, also check if the packet is routed locally.
if !self.any_ip {
return Ok(None);
} else if match self.routes.lookup(&IpAddress::Ipv4(ipv4_repr.dst_addr), timestamp) {
Some(router_addr) => !self.has_ip_addr(router_addr),
None => true,
} {
if !self.any_ip ||
self.routes.lookup(&IpAddress::Ipv4(ipv4_repr.dst_addr), timestamp)
.map_or(true, |router_addr| !self.has_ip_addr(router_addr)) {
return Ok(None);
}
}
@ -1188,10 +1185,9 @@ impl<'b, 'c, 'e> InterfaceInner<'b, 'c, 'e> {
let ip_addr = ip_repr.src_addr.into();
match lladdr {
Some(lladdr) if lladdr.is_unicast() && target_addr.is_unicast() => {
if flags.contains(NdiscNeighborFlags::OVERRIDE) {
if flags.contains(NdiscNeighborFlags::OVERRIDE) ||
!self.neighbor_cache.lookup(&ip_addr, timestamp).found() {
self.neighbor_cache.fill(ip_addr, lladdr, timestamp)
} else if !self.neighbor_cache.lookup(&ip_addr, timestamp).found() {
self.neighbor_cache.fill(ip_addr, lladdr, timestamp)
}
},
_ => (),

View File

@ -87,9 +87,6 @@
feature = "socket-tcp")))]
compile_error!("at least one socket needs to be enabled"); */
// FIXME(dlrobertson): clippy fails with this lint
#![allow(clippy::if_same_then_else)]
#![allow(clippy::manual_non_exhaustive)]
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::redundant_field_names)]
#![allow(clippy::identity_op)]

View File

@ -158,6 +158,7 @@ impl Checksum {
/// A description of checksum behavior for every supported protocol.
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub struct ChecksumCapabilities {
pub ipv4: Checksum,
pub udp: Checksum,
@ -166,7 +167,6 @@ pub struct ChecksumCapabilities {
pub icmpv4: Checksum,
#[cfg(feature = "proto-ipv6")]
pub icmpv6: Checksum,
dummy: (),
}
impl ChecksumCapabilities {
@ -181,7 +181,6 @@ impl ChecksumCapabilities {
icmpv4: Checksum::None,
#[cfg(feature = "proto-ipv6")]
icmpv6: Checksum::None,
..Self::default()
}
}
}
@ -191,6 +190,7 @@ impl ChecksumCapabilities {
/// Higher-level protocols may achieve higher throughput or lower latency if they consider
/// the bandwidth or packet size limitations.
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub struct DeviceCapabilities {
/// Maximum transmission unit.
///
@ -214,10 +214,6 @@ pub struct DeviceCapabilities {
/// If the network device is capable of verifying or computing checksums for some protocols,
/// it can request that the stack not do so in software to improve performance.
pub checksum: ChecksumCapabilities,
/// Only present to prevent people from trying to initialize every field of DeviceLimits,
/// which would not let us add new fields in the future.
pub(crate) dummy: ()
}
/// An interface for sending and receiving raw network frames.

View File

@ -1905,6 +1905,7 @@ impl<'a> TcpSocket<'a> {
Ok(())
}
#[allow(clippy::if_same_then_else)]
pub(crate) fn poll_at(&self) -> PollAt {
// The logic here mirrors the beginning of dispatch() closely.
if !self.remote_endpoint.is_specified() {

View File

@ -86,6 +86,7 @@ impl<T: AsRef<[u8]>> Packet<T> {
///
/// [set_hardware_len]: #method.set_hardware_len
/// [set_protocol_len]: #method.set_protocol_len
#[allow(clippy::if_same_then_else)]
pub fn check_len(&self) -> Result<()> {
let len = self.buffer.as_ref().len();
if len < field::OPER.end {

View File

@ -271,6 +271,7 @@ impl<T: AsRef<[u8]>> Packet<T> {
///
/// [set_header_len]: #method.set_header_len
/// [set_total_len]: #method.set_total_len
#[allow(clippy::if_same_then_else)]
pub fn check_len(&self) -> Result<()> {
let len = self.buffer.as_ref().len();
if len < field::DST_ADDR.end {