修复内核的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

@ -1,6 +1,10 @@
use core::{fmt::Debug, sync::atomic::Ordering};
use alloc::{string::String, sync::Arc, vec::Vec};
use alloc::{
string::{String, ToString},
sync::Arc,
vec::Vec,
};
use hashbrown::HashMap;
use system_error::SystemError;
@ -109,6 +113,7 @@ pub struct TtyDriver {
}
impl TtyDriver {
#[allow(clippy::too_many_arguments)]
pub fn new(
count: u32,
node_name: &'static str,
@ -142,7 +147,7 @@ impl TtyDriver {
.flags
.contains(TtyDriverFlag::TTY_DRIVER_UNNUMBERED_NODE)
{
return format!("{}", self.name);
return self.name.to_string();
} else {
return format!("{}{}", self.name, index + self.name_base);
}
@ -165,10 +170,7 @@ impl TtyDriver {
#[inline]
fn lockup_tty(&self, index: usize) -> Option<Arc<TtyCore>> {
let device_guard = self.ttys.lock();
return match device_guard.get(&index) {
Some(tty) => Some(tty.clone()),
None => None,
};
return device_guard.get(&index).cloned();
}
fn standard_install(&self, tty_core: Arc<TtyCore>) -> Result<(), SystemError> {
@ -178,7 +180,7 @@ impl TtyDriver {
if !self.flags.contains(TtyDriverFlag::TTY_DRIVER_RESET_TERMIOS) {
// 先查看是否有已经保存的termios
if let Some(t) = self.saved_termios.get(tty_index) {
let mut termios = t.clone();
let mut termios = *t;
termios.line = self.init_termios.line;
tty.set_termios(termios);
}
@ -195,8 +197,7 @@ impl TtyDriver {
fn driver_install_tty(driver: Arc<TtyDriver>, tty: Arc<TtyCore>) -> Result<(), SystemError> {
let res = tty.install(driver.clone(), tty.clone());
if res.is_err() {
let err = res.unwrap_err();
if let Err(err) = res {
if err == SystemError::ENOSYS {
return driver.standard_install(tty);
} else {
@ -236,10 +237,8 @@ impl TtyDriver {
// TODO: 暂时这么写因为还没写TtyPort
if tty.core().port().is_none() {
kwarn!("{} port is None", tty.core().name());
} else {
if tty.core().port().unwrap().state() == TtyPortState::KOPENED {
return Err(SystemError::EBUSY);
}
} else if tty.core().port().unwrap().state() == TtyPortState::KOPENED {
return Err(SystemError::EBUSY);
}
tty.reopen()?;