Fix new clippy lints due to MSRV update.

This commit is contained in:
Dario Nieuwenhuis 2024-09-20 21:08:15 +02:00
parent 997ce67d3c
commit 11b6385c77
9 changed files with 14 additions and 13 deletions

View File

@ -3,7 +3,6 @@
#![allow(clippy::collapsible_if)]
#[cfg(feature = "std")]
#[allow(dead_code)]
mod utils;
use core::str;

View File

@ -137,7 +137,7 @@ impl<K> PacketAssembler<K> {
/// # Errors
///
/// - Returns [`Error::PacketAssemblerBufferTooSmall`] when trying to add data into the buffer at a non-existing
/// place.
/// place.
pub(crate) fn add(&mut self, data: &[u8], offset: usize) -> Result<(), AssemblerError> {
#[cfg(not(feature = "alloc"))]
if self.buffer.len() < offset + data.len() {

View File

@ -1183,8 +1183,8 @@ impl InterfaceInner {
};
// Emit function for the IP header and payload.
let emit_ip = |repr: &IpRepr, mut tx_buffer: &mut [u8]| {
repr.emit(&mut tx_buffer, &self.caps.checksum);
let emit_ip = |repr: &IpRepr, tx_buffer: &mut [u8]| {
repr.emit(&mut *tx_buffer, &self.caps.checksum);
let payload = &mut tx_buffer[repr.header_len()..];
packet.emit_payload(repr, payload, &caps)

View File

@ -557,7 +557,8 @@ impl InterfaceInner {
/// - total size: the size of a compressed IPv6 packet
/// - compressed header size: the size of the compressed headers
/// - uncompressed header size: the size of the headers that are not compressed
/// They are returned as a tuple in the same order.
///
/// They are returned as a tuple in the same order.
fn compressed_packet_size(
packet: &PacketV6,
ieee_repr: &Ieee802154Repr,

View File

@ -87,6 +87,7 @@ compile_error!("at least one socket needs to be enabled"); */
#![allow(clippy::option_map_unit_fn)]
#![allow(clippy::unit_arg)]
#![allow(clippy::new_without_default)]
#![allow(unstable_name_collisions)]
#[cfg(feature = "alloc")]
extern crate alloc;

View File

@ -315,10 +315,10 @@ impl<'a, Tx: phy::TxToken> phy::TxToken for TxToken<'a, Tx> {
return f(&mut self.junk[..len]);
}
self.token.consume(len, |mut buf| {
self.token.consume(len, |buf| {
if self.state.maybe(self.config.corrupt_pct) {
net_trace!("tx: corrupting a packet");
self.state.corrupt(&mut buf)
self.state.corrupt(&mut *buf);
}
f(buf)
})

View File

@ -586,6 +586,7 @@ impl<'a> Socket<'a> {
/// * Small embedded processors (such as Cortex-M0, Cortex-M1, and Cortex-M3) do not have an FPU, and floating point operations consume significant amounts of CPU time and Flash space.
/// * Interrupt handlers should almost always avoid floating-point operations.
/// * Kernel-mode code on desktop processors usually avoids FPU operations to reduce the penalty of saving and restoring FPU registers.
///
/// In all these cases, `CongestionControl::Reno` is a better choice of congestion control algorithm.
pub fn set_congestion_control(&mut self, congestion_control: CongestionControl) {
use congestion::*;
@ -1967,7 +1968,7 @@ impl<'a> Socket<'a> {
"received duplicate ACK for seq {} (duplicate nr {}{})",
ack_number,
self.local_rx_dup_acks,
if self.local_rx_dup_acks == u8::max_value() {
if self.local_rx_dup_acks == u8::MAX {
"+"
} else {
""
@ -2569,7 +2570,6 @@ impl<'a> fmt::Write for Socket<'a> {
mod test {
use super::*;
use crate::wire::IpRepr;
use core::i32;
use std::ops::{Deref, DerefMut};
use std::vec::Vec;
@ -6126,7 +6126,7 @@ mod test {
});
// A lot of retransmits happen here
s.local_rx_dup_acks = u8::max_value() - 1;
s.local_rx_dup_acks = u8::MAX - 1;
// Send 3 more ACKs, which could overflow local_rx_dup_acks,
// but intended behaviour is that we saturate the bounds
@ -6148,7 +6148,7 @@ mod test {
});
assert_eq!(
s.local_rx_dup_acks,
u8::max_value(),
u8::MAX,
"duplicate ACK count should not overflow but saturate"
);
}

View File

@ -443,7 +443,7 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
pub fn set_hardware_type(&mut self, value: Hardware) {
let data = self.buffer.as_mut();
let number: u16 = value.into();
assert!(number <= u16::from(u8::max_value())); // TODO: Replace with TryFrom when it's stable
assert!(number <= u16::from(u8::MAX)); // TODO: Replace with TryFrom when it's stable
data[field::HTYPE] = number as u8;
}

View File

@ -1,5 +1,5 @@
use byteorder::{ByteOrder, NetworkEndian};
use core::{cmp, fmt, i32, ops};
use core::{cmp, fmt, ops};
use super::{Error, Result};
use crate::phy::ChecksumCapabilities;