修复内核的clippy检查报错 (#637)

修复内核的clippy检查报错
---------

Co-authored-by: Samuel Dai <947309196@qq.com>
Co-authored-by: Donkey Kane <109840258+xiaolin2004@users.noreply.github.com>
Co-authored-by: themildwind <107623059+themildwind@users.noreply.github.com>
Co-authored-by: GnoCiYeH <heyicong@dragonos.org>
Co-authored-by: MemoryShore <105195940+MemoryShore@users.noreply.github.com>
Co-authored-by: 曾俊 <110876916+ZZJJWarth@users.noreply.github.com>
Co-authored-by: sun5etop <146408999+sun5etop@users.noreply.github.com>
Co-authored-by: hmt <114841534+1037827920@users.noreply.github.com>
Co-authored-by: laokengwt <143977175+laokengwt@users.noreply.github.com>
Co-authored-by: TTaq <103996388+TTaq@users.noreply.github.com>
Co-authored-by: Jomo <2512364506@qq.com>
Co-authored-by: Samuel Dai <samuka007@qq.com>
Co-authored-by: sspphh <112558065+sspphh@users.noreply.github.com>
This commit is contained in:
LoGin
2024-03-22 23:26:39 +08:00
committed by GitHub
parent 4695947e1b
commit b5b571e026
175 changed files with 1820 additions and 2155 deletions

View File

@ -34,6 +34,8 @@ pub struct E1000ETxToken {
pub struct E1000EDriver {
pub inner: Arc<SpinLock<E1000EDevice>>,
}
unsafe impl Send for E1000EDriver {}
unsafe impl Sync for E1000EDriver {}
/// @brief 网卡驱动的包裹器,这是为了获取网卡驱动的可变引用而设计的。
/// 参阅virtio_net.rs
@ -54,6 +56,7 @@ impl DerefMut for E1000EDriverWrapper {
}
impl E1000EDriverWrapper {
#[allow(clippy::mut_from_ref)]
fn force_get_mut(&self) -> &mut E1000EDriver {
unsafe { &mut *self.0.get() }
}
@ -76,7 +79,7 @@ impl phy::RxToken for E1000ERxToken {
where
F: FnOnce(&mut [u8]) -> R,
{
let result = f(&mut self.0.as_mut_slice());
let result = f(self.0.as_mut_slice());
self.0.free_buffer();
return result;
}
@ -97,6 +100,7 @@ impl phy::TxToken for E1000ETxToken {
}
impl E1000EDriver {
#[allow(clippy::arc_with_non_send_sync)]
pub fn new(device: E1000EDevice) -> Self {
let mut iface_config = smoltcp::iface::Config::new();
@ -253,11 +257,11 @@ impl NetDriver for E1000EInterface {
self.iface.lock().update_ip_addrs(|addrs| {
let dest = addrs.iter_mut().next();
if let None = dest {
addrs.push(ip_addrs[0]).expect("Push ipCidr failed: full");
} else {
let dest = dest.unwrap();
if let Some(dest) = dest {
*dest = ip_addrs[0];
} else {
addrs.push(ip_addrs[0]).expect("Push ipCidr failed: full");
}
});
return Ok(());