Resolve lints in the TTY module

This commit is contained in:
Ruihan Li 2025-04-19 22:05:53 +08:00 committed by Jianfeng Jiang
parent 7de9666e65
commit 5e13e0c325
4 changed files with 5 additions and 24 deletions

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
#![expect(unused_variables)]
use crate::{ use crate::{
events::IoEvents, events::IoEvents,
fs::{ fs::{
@ -41,17 +39,17 @@ impl Device for TtyDevice {
} }
impl Pollable for TtyDevice { impl Pollable for TtyDevice {
fn poll(&self, mask: IoEvents, poller: Option<&mut PollHandle>) -> IoEvents { fn poll(&self, _mask: IoEvents, _poller: Option<&mut PollHandle>) -> IoEvents {
IoEvents::empty() IoEvents::empty()
} }
} }
impl FileIo for TtyDevice { impl FileIo for TtyDevice {
fn read(&self, writer: &mut VmWriter) -> Result<usize> { fn read(&self, _writer: &mut VmWriter) -> Result<usize> {
return_errno_with_message!(Errno::EINVAL, "cannot read tty device"); return_errno_with_message!(Errno::EINVAL, "cannot read tty device");
} }
fn write(&self, reader: &mut VmReader) -> Result<usize> { fn write(&self, _reader: &mut VmReader) -> Result<usize> {
return_errno_with_message!(Errno::EINVAL, "cannot write tty device"); return_errno_with_message!(Errno::EINVAL, "cannot write tty device");
} }
} }

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
use ostd::mm::{Infallible, VmReader}; use ostd::mm::{Infallible, VmReader};
use spin::Once; use spin::Once;
@ -86,11 +84,6 @@ fn console_input_callback(mut reader: VmReader<Infallible>) {
} }
} }
fn serial_input_callback(item: u8) {
let tty_driver = get_tty_driver();
tty_driver.push_char(item);
}
fn get_tty_driver() -> &'static TtyDriver { fn get_tty_driver() -> &'static TtyDriver {
TTY_DRIVER.get().unwrap() TTY_DRIVER.get().unwrap()
} }

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
#![expect(unused_variables)]
use alloc::format; use alloc::format;
use ostd::{ use ostd::{
@ -235,7 +233,7 @@ impl LineDiscipline {
let ctrl_char = format!("^{}", get_printable_char(ch)); let ctrl_char = format!("^{}", get_printable_char(ch));
echo_callback(&ctrl_char); echo_callback(&ctrl_char);
} }
item => {} _ => {}
} }
} }
@ -254,8 +252,6 @@ impl LineDiscipline {
(vmin, vtime) (vmin, vtime)
}; };
let read_len = { let read_len = {
let len = self.read_buffer.lock().len();
let max_read_len = len.min(dst.len());
if vmin == 0 && vtime == 0 { if vmin == 0 && vtime == 0 {
// poll read // poll read
self.poll_read(dst) self.poll_read(dst)
@ -402,11 +398,6 @@ fn get_printable_char(ctrl_char: u8) -> char {
char::from_u32((ctrl_char + b'A' - 1) as u32).unwrap() char::from_u32((ctrl_char + b'A' - 1) as u32).unwrap()
} }
enum PolleeType {
Add,
Del,
}
struct LineDisciplineWorkPara { struct LineDisciplineWorkPara {
kernel_signal: Option<KernelSignal>, kernel_signal: Option<KernelSignal>,
} }

View File

@ -1,7 +1,5 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
use ostd::early_print; use ostd::early_print;
use spin::Once; use spin::Once;
@ -39,6 +37,7 @@ pub(super) fn init() {
pub struct Tty { pub struct Tty {
/// tty_name /// tty_name
#[expect(unused)]
name: CString, name: CString,
/// line discipline /// line discipline
ldisc: Arc<LineDiscipline>, ldisc: Arc<LineDiscipline>,