refactor: fix clippy warnings
This commit is contained in:
parent
992f66b5a0
commit
ac84a7e027
@ -1,4 +1,5 @@
|
||||
#![no_std]
|
||||
#![allow(clippy::new_without_default)]
|
||||
#![feature(
|
||||
maybe_uninit_slice,
|
||||
step_trait,
|
||||
|
@ -114,7 +114,7 @@ impl File {
|
||||
config: TerminalOptions,
|
||||
size: TerminalSize,
|
||||
) -> Result<(Arc<Self>, Arc<Self>), Error> {
|
||||
let (master, slave) = PseudoTerminal::new(config, size)?;
|
||||
let (master, slave) = PseudoTerminal::create(config, size)?;
|
||||
let master = Arc::new(master);
|
||||
let slave = Arc::new(slave);
|
||||
let (master_node, slave_node) = Node::pseudo_terminal_nodes(master.clone(), slave.clone());
|
||||
|
@ -110,19 +110,19 @@ where
|
||||
R: ValueReadFn<T> + 'static,
|
||||
{
|
||||
/// Creates a new [ReadOnlyFnValueNode] with given read function
|
||||
pub fn new(read: R) -> NodeRef {
|
||||
Node::regular(
|
||||
Self::new_impl(read),
|
||||
NodeFlags::IN_MEMORY_PROPS | NodeFlags::IN_MEMORY_SIZE,
|
||||
)
|
||||
}
|
||||
|
||||
const fn new_impl(read: R) -> Self {
|
||||
pub const fn new(read: R) -> Self {
|
||||
Self {
|
||||
read,
|
||||
_pd: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_node(read: R) -> NodeRef {
|
||||
Node::regular(
|
||||
Self::new(read),
|
||||
NodeFlags::IN_MEMORY_PROPS | NodeFlags::IN_MEMORY_SIZE,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R> CommonImpl for ReadOnlyFnValueNode<T, R>
|
||||
@ -211,20 +211,20 @@ where
|
||||
W: ValueWriteFn<T> + 'static,
|
||||
{
|
||||
/// Creates a new [FnValueNode] with given read and write functions
|
||||
pub fn new(read: R, write: W) -> NodeRef {
|
||||
Node::regular(
|
||||
Self::new_impl(read, write),
|
||||
NodeFlags::IN_MEMORY_PROPS | NodeFlags::IN_MEMORY_SIZE,
|
||||
)
|
||||
}
|
||||
|
||||
const fn new_impl(read: R, write: W) -> Self {
|
||||
pub fn new(read: R, write: W) -> Self {
|
||||
Self {
|
||||
read,
|
||||
write,
|
||||
_pd: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_node(read: R, write: W) -> NodeRef {
|
||||
Node::regular(
|
||||
Self::new(read, write),
|
||||
NodeFlags::IN_MEMORY_PROPS | NodeFlags::IN_MEMORY_SIZE,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R, W> CommonImpl for FnValueNode<T, R, W>
|
||||
@ -314,8 +314,8 @@ where
|
||||
R: ReadFn + 'static,
|
||||
{
|
||||
/// Creates a new [ReadOnlyFnNode] with given read function
|
||||
pub fn new(read: R) -> NodeRef {
|
||||
Node::regular(Self { read }, NodeFlags::IN_MEMORY_PROPS)
|
||||
pub fn new(read: R) -> Self {
|
||||
Self { read }
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,12 +389,8 @@ where
|
||||
F: ReadLinkFn + 'static,
|
||||
{
|
||||
/// Creates a new [FnSymlink] node
|
||||
pub fn new(read: F) -> NodeRef {
|
||||
let data = Self { read };
|
||||
Node::symlink(
|
||||
data,
|
||||
NodeFlags::IN_MEMORY_SIZE | NodeFlags::IN_MEMORY_PROPS | NodeFlags::NO_LINK_CACHE,
|
||||
)
|
||||
pub fn new(read: F) -> Self {
|
||||
Self { read }
|
||||
}
|
||||
}
|
||||
|
||||
@ -413,7 +409,16 @@ pub fn const_value_node<T>(value: T) -> NodeRef
|
||||
where
|
||||
T: ToString + Clone + Send + Sync + 'static,
|
||||
{
|
||||
ReadOnlyFnValueNode::new(move || Ok(value.clone()))
|
||||
ReadOnlyFnValueNode::new_node(move || Ok(value.clone()))
|
||||
}
|
||||
|
||||
pub fn read_write_node<T, R, W>(read: R, write: W) -> NodeRef
|
||||
where
|
||||
T: ToString + FromStr + Send + Sync + 'static,
|
||||
R: ValueReadFn<T> + 'static,
|
||||
W: ValueWriteFn<T> + 'static,
|
||||
{
|
||||
FnValueNode::new_node(read, write)
|
||||
}
|
||||
|
||||
/// Creates a read-write value node with given `value`
|
||||
@ -424,7 +429,7 @@ where
|
||||
let rd_state = Arc::new(IrqSafeSpinlock::new(value));
|
||||
let wr_state = rd_state.clone();
|
||||
|
||||
FnValueNode::new(
|
||||
FnValueNode::new_node(
|
||||
move || Ok(rd_state.lock().clone()),
|
||||
move |t| {
|
||||
*wr_state.lock() = t;
|
||||
@ -435,7 +440,7 @@ where
|
||||
|
||||
/// Creates a read-only node with given read function
|
||||
pub fn read_fn_node<R: ReadFn + 'static>(read: R) -> NodeRef {
|
||||
ReadOnlyFnNode::new(read)
|
||||
Node::regular(ReadOnlyFnNode::new(read), NodeFlags::IN_MEMORY_PROPS)
|
||||
}
|
||||
|
||||
/// Creates an in-memory directory from the iterator
|
||||
@ -451,15 +456,23 @@ pub fn mdir<S: Into<String>, I: IntoIterator<Item = (S, NodeRef)>>(it: I) -> Nod
|
||||
}
|
||||
|
||||
/// Creates a static symlink pointing to given node
|
||||
pub fn f_symlink(target: NodeRef) -> NodeRef {
|
||||
pub fn fixed_symlink(target: NodeRef) -> NodeRef {
|
||||
Node::symlink(FixedSymlink { target }, NodeFlags::IN_MEMORY_PROPS)
|
||||
}
|
||||
|
||||
pub fn fn_symlink<R: ReadLinkFn + 'static>(read: R) -> NodeRef {
|
||||
let data = FnSymlink::new(read);
|
||||
Node::symlink(
|
||||
data,
|
||||
NodeFlags::IN_MEMORY_SIZE | NodeFlags::IN_MEMORY_PROPS | NodeFlags::NO_LINK_CACHE,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use yggdrasil_abi::io::OpenOptions;
|
||||
|
||||
use crate::{
|
||||
use crate::vfs::{
|
||||
node::{
|
||||
impls::{const_value_node, value_node},
|
||||
AccessToken,
|
||||
|
@ -174,7 +174,7 @@ impl PtySlaveToMasterHalf {
|
||||
|
||||
impl PseudoTerminal {
|
||||
/// Creates a pair of PTY slave/master devices
|
||||
pub fn new(
|
||||
pub fn create(
|
||||
config: TerminalOptions,
|
||||
size: TerminalSize,
|
||||
) -> Result<(PseudoTerminalMaster, PseudoTerminalSlave), Error> {
|
||||
@ -223,7 +223,9 @@ impl PseudoTerminal {
|
||||
}
|
||||
|
||||
return;
|
||||
} else if byte == b'\n' {
|
||||
}
|
||||
|
||||
if byte == b'\n' {
|
||||
// TODO NL_TO_CRNL
|
||||
if config.is_echo_newline() {
|
||||
self.slave_to_master.handle_input(byte, &config.output);
|
||||
|
@ -8,7 +8,7 @@ use aarch64_cpu::{
|
||||
use kernel_arch::{absolute_address, Architecture, ArchitectureImpl};
|
||||
use kernel_arch_aarch64::CPU_COUNT;
|
||||
use kernel_fs::devfs;
|
||||
use libk::runtime;
|
||||
use libk::task::runtime;
|
||||
use libk_mm::{
|
||||
address::{IntoRaw, PhysicalAddress, Virtualize},
|
||||
phys,
|
||||
|
@ -15,11 +15,10 @@ use abi::{
|
||||
};
|
||||
use kernel_arch::{task::TaskFrame, Architecture, ArchitectureImpl};
|
||||
use kernel_arch_aarch64::context::ExceptionFrame;
|
||||
use libk::device::external_interrupt_controller;
|
||||
use libk_thread::thread::Thread;
|
||||
use libk::{device::external_interrupt_controller, task::thread::Thread};
|
||||
use tock_registers::interfaces::{Readable, Writeable};
|
||||
|
||||
use crate::{debug::LogLevel, syscall::raw_syscall_handler, task::process::ProcessManagerImpl};
|
||||
use crate::{debug::LogLevel, syscall::raw_syscall_handler};
|
||||
|
||||
/// Initializes the exception/interrupt vectors. May be called repeatedly (though that makes no
|
||||
/// sense).
|
||||
@ -109,7 +108,7 @@ extern "C" fn __aa64_el0_sync_handler(frame: *mut ExceptionFrame) {
|
||||
|
||||
unsafe {
|
||||
let thread = Thread::current();
|
||||
thread.handle_pending_signals::<ProcessManagerImpl, _>(frame);
|
||||
thread.handle_pending_signals(frame);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +121,7 @@ extern "C" fn __aa64_el0_irq_handler(frame: *mut ExceptionFrame) {
|
||||
|
||||
unsafe {
|
||||
let thread = Thread::current();
|
||||
thread.handle_pending_signals::<ProcessManagerImpl, _>(frame);
|
||||
thread.handle_pending_signals(frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ use device_api::{
|
||||
};
|
||||
use device_tree::{device_tree_driver, dt::DevTreeIndexPropExt};
|
||||
use kernel_arch_aarch64::{GicInterface, CPU_COUNT};
|
||||
use libk::{arch::Cpu, cpu_index, device::register_external_interrupt_controller};
|
||||
use libk::{arch::Cpu, device::register_external_interrupt_controller, task::cpu_index};
|
||||
use libk_mm::{
|
||||
address::{FromRaw, IntoRaw, PhysicalAddress},
|
||||
device::{DeviceMemoryIo, RawDeviceMemoryMapping},
|
||||
|
@ -15,7 +15,7 @@ use kernel_arch::task::Scheduler;
|
||||
use libk::{
|
||||
arch::Cpu,
|
||||
device::{external_interrupt_controller, register_monotonic_timestamp_provider},
|
||||
runtime,
|
||||
task::runtime,
|
||||
};
|
||||
use tock_registers::interfaces::{ReadWriteable, Readable, Writeable};
|
||||
|
||||
|
@ -9,7 +9,11 @@ use device_api::{
|
||||
use device_tree::{device_tree_driver, dt::DevTreeIndexPropExt};
|
||||
use futures_util::task::{Context, Poll};
|
||||
use kernel_fs::devfs::{self, CharDeviceType};
|
||||
use libk::{block, device::external_interrupt_controller};
|
||||
use libk::{
|
||||
block,
|
||||
device::external_interrupt_controller,
|
||||
vfs::{CharDevice, FileReadiness},
|
||||
};
|
||||
use libk_mm::{
|
||||
address::{FromRaw, PhysicalAddress},
|
||||
device::DeviceMemoryIo,
|
||||
@ -20,7 +24,6 @@ use tock_registers::{
|
||||
register_bitfields, register_structs,
|
||||
registers::{ReadOnly, ReadWrite, WriteOnly},
|
||||
};
|
||||
use vfs::{CharDevice, FileReadiness};
|
||||
|
||||
use crate::{
|
||||
debug::{self, DebugSink, LogLevel},
|
||||
|
@ -32,15 +32,15 @@ pub fn init() {
|
||||
let d_mem_phys = mdir([
|
||||
(
|
||||
"total_pages",
|
||||
ReadOnlyFnValueNode::new(|| Ok(phys::stats().total_usable_pages)),
|
||||
ReadOnlyFnValueNode::new_node(|| Ok(phys::stats().total_usable_pages)),
|
||||
),
|
||||
(
|
||||
"free_pages",
|
||||
ReadOnlyFnValueNode::new(|| Ok(phys::stats().free_pages)),
|
||||
ReadOnlyFnValueNode::new_node(|| Ok(phys::stats().free_pages)),
|
||||
),
|
||||
(
|
||||
"allocated_pages",
|
||||
ReadOnlyFnValueNode::new(|| Ok(phys::stats().allocated_pages)),
|
||||
ReadOnlyFnValueNode::new_node(|| Ok(phys::stats().allocated_pages)),
|
||||
),
|
||||
]);
|
||||
let d_mem = mdir([("phys", d_mem_phys)]);
|
||||
|
@ -5,7 +5,8 @@ use alloc::borrow::ToOwned;
|
||||
use kernel_fs::devfs;
|
||||
use libk::task::process::Process;
|
||||
use libk::task::{runtime, thread::Thread};
|
||||
use libk::vfs::{impls::FnSymlink, IoContext, NodeRef};
|
||||
use libk::vfs::impls::fn_symlink;
|
||||
use libk::vfs::{IoContext, NodeRef};
|
||||
use memfs::MemoryFilesystem;
|
||||
|
||||
use crate::{
|
||||
@ -32,7 +33,7 @@ pub fn kinit() -> Result<(), Error> {
|
||||
|
||||
devfs::root().add_child(
|
||||
"tty",
|
||||
FnSymlink::new(|| {
|
||||
fn_symlink(|| {
|
||||
let thread = Thread::current();
|
||||
let process = thread.process();
|
||||
|
||||
|
@ -29,7 +29,7 @@ fn main() -> ExitCode {
|
||||
|
||||
if args.len() == 0 {
|
||||
if let Err(error) = cat_file(&mut stdout, "-") {
|
||||
eprintln!("{}: {}", "<stdin>", error);
|
||||
eprintln!("<stdin>: {}", error);
|
||||
exit = ExitCode::FAILURE;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user