From 37d554d31d52bfade51478fb790d406266094f58 Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Thu, 22 Jan 2026 18:07:51 -0800 Subject: [PATCH 1/2] enforce semicolon_if_nothing_returned and uninlined_format_args --- src/arch/arm64/boot/memory.rs | 2 +- src/arch/arm64/boot/secondary.rs | 6 +++--- src/arch/arm64/memory/mod.rs | 2 +- src/arch/arm64/memory/uaccess.rs | 6 +++--- src/arch/arm64/proc/idle.rs | 2 +- src/console/mod.rs | 2 +- src/drivers/fdt_prober.rs | 7 ++----- src/drivers/fs/dev.rs | 2 +- src/drivers/fs/proc.rs | 2 +- src/drivers/init.rs | 2 +- src/drivers/interrupts/arm_gic_v2.rs | 3 +-- src/drivers/interrupts/arm_gic_v3.rs | 14 +++++--------- src/drivers/timer/mod.rs | 4 ++-- src/drivers/uart/mod.rs | 4 ++-- src/main.rs | 10 ++++++---- src/memory/uaccess.rs | 2 +- src/process/fd_table/select.rs | 2 +- src/process/mod.rs | 2 +- src/process/ptrace.rs | 10 +++++----- src/process/thread_group.rs | 2 +- src/process/thread_group/rsrc_lim.rs | 2 +- src/process/thread_group/signal.rs | 2 +- src/process/thread_group/signal/sigaction.rs | 4 ++-- src/sched/runqueue.rs | 2 +- src/sched/uspc_ret.rs | 2 +- 25 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/arch/arm64/boot/memory.rs b/src/arch/arm64/boot/memory.rs index e34dfff4..0ea0a69b 100644 --- a/src/arch/arm64/boot/memory.rs +++ b/src/arch/arm64/boot/memory.rs @@ -175,7 +175,7 @@ pub fn setup_stack_and_heap(pgtbl_base: TPA>) -> Result Result<(PA, PA)> { .ok_or(KernelError::Other("Idmap not set"))?, start_fn: VA::from_value(arch_init_secondary as *const () as usize), exception_ret: VA::from_value(&exception_return as *const _ as usize), - }) + }); }; Ok((entry_fn, ctx)) @@ -186,7 +186,7 @@ fn cpu_node_iter() -> impl Iterator> { pub fn boot_secondaries() { for cpu_node in cpu_node_iter() { if let Err(e) = do_boot_secondary(cpu_node) { - log::warn!("Failed to boot secondary: {}", e); + log::warn!("Failed to boot secondary: {e}"); } } } @@ -204,7 +204,7 @@ pub fn save_idmap(addr: PA) { pub fn secondary_booted() { let id = ArchImpl::id(); - info!("CPU {} online.", id); + info!("CPU {id} online."); SECONDARY_BOOT_FLAG.store(true, Ordering::Release); } diff --git a/src/arch/arm64/memory/mod.rs b/src/arch/arm64/memory/mod.rs index 89d165ba..eb5773f6 100644 --- a/src/arch/arm64/memory/mod.rs +++ b/src/arch/arm64/memory/mod.rs @@ -42,7 +42,7 @@ unsafe impl GlobalAlloc for SpinlockHeap { unsafe { self.0 .lock_save_irq() - .deallocate(NonNull::new_unchecked(ptr), layout) + .deallocate(NonNull::new_unchecked(ptr), layout); } } } diff --git a/src/arch/arm64/memory/uaccess.rs b/src/arch/arm64/memory/uaccess.rs index 8f38d3fb..207098d6 100644 --- a/src/arch/arm64/memory/uaccess.rs +++ b/src/arch/arm64/memory/uaccess.rs @@ -103,7 +103,7 @@ fn do_copy_from_user( lateout("x3") work_vtable, // Clobbers out("lr") _, out("x4") _ - ) + ); } ( @@ -205,7 +205,7 @@ impl Future for Arm64CopyStrnFromUser { lateout("x3") work_vtable, // Clobbers out("lr") _, out("x4") _ - ) + ); } ( @@ -266,7 +266,7 @@ impl Future for Arm64CopyToUser { lateout("x3") work_vtable, // Clobbers out("lr") _, out("x4") _ - ) + ); } ( UAccessResult::from(status), diff --git a/src/arch/arm64/proc/idle.rs b/src/arch/arm64/proc/idle.rs index 7d80fb25..f2ae0cb3 100644 --- a/src/arch/arm64/proc/idle.rs +++ b/src/arch/arm64/proc/idle.rs @@ -37,7 +37,7 @@ pub fn create_idle_task() -> OwnedTask { .cast::() .as_ptr_mut(), code_sz, - ) + ); }; let mut addr_space = ::ProcessAddressSpace::new().unwrap(); diff --git a/src/console/mod.rs b/src/console/mod.rs index a653f0d3..42d22f97 100644 --- a/src/console/mod.rs +++ b/src/console/mod.rs @@ -71,7 +71,7 @@ pub fn set_active_console( let buf_contents = unsafe { (*addr_of_mut!(EARLY_BOOT_BUFFER)).data() }; if let Ok(s) = str::from_utf8(buf_contents) { - let _ = console.write_fmt(format_args!("{}", s)); + let _ = console.write_fmt(format_args!("{s}")); } } diff --git a/src/drivers/fdt_prober.rs b/src/drivers/fdt_prober.rs index 0666ef82..d46f7bb8 100644 --- a/src/drivers/fdt_prober.rs +++ b/src/drivers/fdt_prober.rs @@ -78,7 +78,7 @@ pub fn probe_for_fdt_devices() { } Err(e) => { // A fatal error occurred during probe. - error!("Fatal error while probing device \"{}\": {}", desc, e); + error!("Fatal error while probing device \"{desc}\": {e}"); } } } @@ -89,10 +89,7 @@ pub fn probe_for_fdt_devices() { // If we made no progress in a full pass, we are done (or have an unresolvable dependency). if !progress_made && !to_probe.is_empty() { for desc in &to_probe { - warn!( - "Could not probe device \"{}\" due to missing dependencies.", - desc - ); + warn!("Could not probe device \"{desc}\" due to missing dependencies."); } break; } diff --git a/src/drivers/fs/dev.rs b/src/drivers/fs/dev.rs index 1fb003fb..7449ee05 100644 --- a/src/drivers/fs/dev.rs +++ b/src/drivers/fs/dev.rs @@ -145,7 +145,7 @@ impl Inode for DevFsINode { async fn getattr(&self) -> Result { let mut attr = self.attr.lock_save_irq().clone(); if let InodeKind::CharDevice { device_id } = self.kind { - attr.file_type = FileType::CharDevice(device_id) + attr.file_type = FileType::CharDevice(device_id); } Ok(attr) } diff --git a/src/drivers/fs/proc.rs b/src/drivers/fs/proc.rs index 04c04b63..43908ea3 100644 --- a/src/drivers/fs/proc.rs +++ b/src/drivers/fs/proc.rs @@ -350,7 +350,7 @@ Threads:\t{tasks}\n", let mut output = String::new(); output.push_str(&format!("{} ", task.process.tgid.0)); // pid output.push_str(&format!("({}) ", name.as_str())); // comm - output.push_str(&format!("{} ", state)); // state + output.push_str(&format!("{state} ")); // state output.push_str(&format!("{} ", 0)); // ppid output.push_str(&format!("{} ", 0)); // pgrp output.push_str(&format!("{} ", task.process.sid.lock_save_irq().value())); // session diff --git a/src/drivers/init.rs b/src/drivers/init.rs index dcc63e7f..20497b26 100644 --- a/src/drivers/init.rs +++ b/src/drivers/init.rs @@ -86,7 +86,7 @@ pub unsafe fn run_initcalls() { let init_func = &*current; // Call each driver's init function if let Err(e) = init_func(&mut bus, &mut dm) { - error!("A driver failed to initialize: {}", e); + error!("A driver failed to initialize: {e}"); } current = current.add(1); diff --git a/src/drivers/interrupts/arm_gic_v2.rs b/src/drivers/interrupts/arm_gic_v2.rs index cc292848..44bf1a6a 100644 --- a/src/drivers/interrupts/arm_gic_v2.rs +++ b/src/drivers/interrupts/arm_gic_v2.rs @@ -357,8 +357,7 @@ pub fn gic_v2_probe(_dm: &mut DriverManager, d: DeviceDescriptor) -> Result LevelHigh, // GICv3 simplified trigger types for SPIs. Level-low and falling-edge are less common. _ => { - warn!("Unsupported GIC interrupt trigger flag: {}", flags); + warn!("Unsupported GIC interrupt trigger flag: {flags}"); LevelHigh // Default to a safe value } }; @@ -488,8 +485,7 @@ pub fn gic_v3_probe(_dm: &mut DriverManager, d: DeviceDescriptor) -> Result InterruptHandler for Uart { byte_buf .into_iter() .take(bytes_read) - .for_each(|b| handler.push_byte(b)) + .for_each(|b| handler.push_byte(b)); } } } @@ -215,7 +215,7 @@ impl UartCharDev { })); devfs().mknod( - format!("ttyS{}", minor), + format!("ttyS{minor}"), desc, FilePermissions::from_bits_retain(0o600), )?; diff --git a/src/main.rs b/src/main.rs index 93333420..0938e23f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ #![feature(used_with_arg)] #![feature(likely_unlikely)] #![feature(box_as_ptr)] +#![warn(clippy::semicolon_if_nothing_returned)] +#![warn(clippy::uninlined_format_args)] use alloc::{ boxed::Box, @@ -203,11 +205,11 @@ fn parse_args(args: &str) -> KOptions { kopts.automounts.push((PathBuf::from(path), fs.to_string())); } - Opt::Long(x) => warn!("Unknown option {}", x), - Opt::Short(x) => warn!("Unknown option {}", x), + Opt::Long(x) => warn!("Unknown option {x}"), + Opt::Short(x) => warn!("Unknown option {x}"), }, Ok(None) => return kopts, - Err(e) => error!("Could not parse option: {}, ignoring.", e), + Err(e) => error!("Could not parse option: {e}, ignoring."), } } } @@ -221,5 +223,5 @@ pub fn kmain(args: String, ctx_frame: *mut UserCtx) { spawn_kernel_work(launch_init(kopts)); - dispatch_userspace_task(ctx_frame) + dispatch_userspace_task(ctx_frame); } diff --git a/src/memory/uaccess.rs b/src/memory/uaccess.rs index 6eaaef08..b09aef91 100644 --- a/src/memory/uaccess.rs +++ b/src/memory/uaccess.rs @@ -47,7 +47,7 @@ pub async fn copy_from_user(src: TUA) -> Result { uninit.as_mut_ptr() as *mut _ as *mut _, core::mem::size_of::(), ) - .await? + .await?; }; // SAFETY: If the future completed successfully, then the copy from diff --git a/src/process/fd_table/select.rs b/src/process/fd_table/select.rs index 520c32f8..66faf347 100644 --- a/src/process/fd_table/select.rs +++ b/src/process/fd_table/select.rs @@ -53,7 +53,7 @@ impl FdSet { fn set_fd(&mut self, fd: Fd) { let fd = fd.as_raw(); - self.set[fd as usize / 64] |= 1 << (fd % 64) + self.set[fd as usize / 64] |= 1 << (fd % 64); } } diff --git a/src/process/mod.rs b/src/process/mod.rs index 83bcefbb..9c604536 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -142,7 +142,7 @@ impl Display for TaskState { TaskState::Sleeping => "S", TaskState::Finished => "Z", }; - write!(f, "{}", state_str) + write!(f, "{state_str}") } } diff --git a/src/process/ptrace.rs b/src/process/ptrace.rs index ad0e26da..609f0cd9 100644 --- a/src/process/ptrace.rs +++ b/src/process/ptrace.rs @@ -110,7 +110,7 @@ impl PTrace { self.state = Some(PTraceState::TracePointHit { reg_set: regs.into(), hit_point: point, - }) + }); } should_stop @@ -202,7 +202,7 @@ impl PTrace { self.state = Some(PTraceState::SignalTrap { reg_set: regs.into(), signal, - }) + }); } should_stop @@ -359,13 +359,13 @@ pub async fn sys_ptrace(op: i32, pid: u64, addr: UA, data: UA) -> Result PTraceOptions::PTRACE_O_TRACESYSGOOD => ptrace.sysgood = true, PTraceOptions::PTRACE_O_EXITKILL => todo!(), PTraceOptions::PTRACE_O_TRACECLONE => { - ptrace.break_points.insert(TracePoint::Clone) + ptrace.break_points.insert(TracePoint::Clone); } PTraceOptions::PTRACE_O_TRACEEXIT => { - ptrace.break_points.insert(TracePoint::Exit) + ptrace.break_points.insert(TracePoint::Exit); } PTraceOptions::PTRACE_O_TRACEFORK | PTraceOptions::PTRACE_O_TRACEVFORK => { - ptrace.break_points.insert(TracePoint::Fork) + ptrace.break_points.insert(TracePoint::Fork); } PTraceOptions::PTRACE_O_TRACEEXEC => { ptrace.break_points.insert(TracePoint::Exec); diff --git a/src/process/thread_group.rs b/src/process/thread_group.rs index 88dd0e45..83ee1479 100644 --- a/src/process/thread_group.rs +++ b/src/process/thread_group.rs @@ -116,7 +116,7 @@ impl ThreadGroup { // Skip the TGID. if v == self.tgid.value() { - v = self.next_tid.fetch_add(1, Ordering::Relaxed) + v = self.next_tid.fetch_add(1, Ordering::Relaxed); } Tid(v) diff --git a/src/process/thread_group/rsrc_lim.rs b/src/process/thread_group/rsrc_lim.rs index 93be1481..c15ff964 100644 --- a/src/process/thread_group/rsrc_lim.rs +++ b/src/process/thread_group/rsrc_lim.rs @@ -216,7 +216,7 @@ pub async fn sys_prlimit64( }; if !old_rlim.is_null() { - copy_to_user(old_rlim, old_lim).await? + copy_to_user(old_rlim, old_lim).await?; } Ok(0) diff --git a/src/process/thread_group/signal.rs b/src/process/thread_group/signal.rs index 57ceb921..22fb5929 100644 --- a/src/process/thread_group/signal.rs +++ b/src/process/thread_group/signal.rs @@ -216,7 +216,7 @@ impl AltSigStack { } pub fn restore_alt_stack(&mut self, old_ptr: UA) { - self.ptr = old_ptr + self.ptr = old_ptr; } pub fn in_use(&self) -> bool { diff --git a/src/process/thread_group/signal/sigaction.rs b/src/process/thread_group/signal/sigaction.rs index 1dbeba2a..7e9adff8 100644 --- a/src/process/thread_group/signal/sigaction.rs +++ b/src/process/thread_group/signal/sigaction.rs @@ -94,13 +94,13 @@ pub async fn sys_rt_sigaction( sigsetsize: usize, ) -> Result { if sigsetsize != size_of::() { - Err(KernelError::InvalidValue)? + return Err(KernelError::InvalidValue)?; } let sig: SigId = sig.try_into()?; if sig == SigId::SIGKILL || sig == SigId::SIGSTOP { - Err(KernelError::InvalidValue)? + return Err(KernelError::InvalidValue); } let new_act = if !act.is_null() { diff --git a/src/sched/runqueue.rs b/src/sched/runqueue.rs index ef79a587..c3431c73 100644 --- a/src/sched/runqueue.rs +++ b/src/sched/runqueue.rs @@ -51,7 +51,7 @@ impl RunQueue { let mut new_task = match self.queue.remove(&next_task) { Some(t) => t, None => { - warn!("Task {:?} not found for switch.", next_task); + warn!("Task {next_task:?} not found for switch."); return SwitchResult::AlreadyRunning; } }; diff --git a/src/sched/uspc_ret.rs b/src/sched/uspc_ret.rs index 1a7424be..47503ec0 100644 --- a/src/sched/uspc_ret.rs +++ b/src/sched/uspc_ret.rs @@ -201,7 +201,7 @@ pub fn dispatch_userspace_task(ctx: *mut UserCtx) { match *task_state { // Task is runnable or running, put it to sleep. TaskState::Running | TaskState::Runnable => { - *task_state = TaskState::Sleeping + *task_state = TaskState::Sleeping; } // If we were woken between the future returning // `Poll::Pending` and acquiring the lock above, From 4f721ad87a1beec440eda02c8003cda3f2d4fe51 Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Thu, 22 Jan 2026 18:30:20 -0800 Subject: [PATCH 2/2] fix typos --- libkernel/src/error.rs | 8 ++++---- libkernel/src/fs/filesystems/fat32/bpb.rs | 2 +- libkernel/src/fs/filesystems/fat32/reader.rs | 2 +- libkernel/src/fs/path.rs | 2 +- libkernel/src/lib.rs | 2 +- libkernel/src/memory/page.rs | 4 ++-- libkernel/src/memory/page_alloc.rs | 2 +- libkernel/src/memory/proc_vm/vmarea.rs | 6 +++--- libkernel/src/sync/condvar.rs | 2 +- libkernel/src/sync/per_cpu.rs | 5 +++-- src/arch/arm64/boot/mod.rs | 2 +- src/arch/arm64/memory/fault.rs | 2 +- src/arch/arm64/memory/fixmap.rs | 4 ++-- src/drivers/interrupts/arm_gic_v3.rs | 2 +- src/drivers/timer/armv8_arch.rs | 2 +- src/drivers/timer/mod.rs | 8 ++++---- src/drivers/uart/imx_lp.rs | 2 +- src/drivers/uart/pl011.rs | 2 +- src/fs/syscalls/at/chown.rs | 2 +- src/fs/syscalls/chown.rs | 2 +- src/interrupts/cpu_messenger.rs | 2 +- src/interrupts/mod.rs | 4 ++-- src/kernel/kpipe.rs | 4 ++-- src/memory/fault.rs | 8 ++++---- src/process/clone.rs | 8 ++++---- src/process/exec.rs | 6 +++--- src/process/exit.rs | 2 +- src/process/fd_table.rs | 2 +- src/process/mod.rs | 4 ++-- src/process/thread_group.rs | 2 +- src/process/thread_group/signal/ksigaction.rs | 2 +- 31 files changed, 54 insertions(+), 53 deletions(-) diff --git a/libkernel/src/error.rs b/libkernel/src/error.rs index 3bba9c01..c8ae7c38 100644 --- a/libkernel/src/error.rs +++ b/libkernel/src/error.rs @@ -15,7 +15,7 @@ pub enum ProbeError { NoInterrupts, #[error("No parent interrupt controller in FDT")] - NoParentIntterupt, + NoParentInterrupt, #[error("The specified interrupt parent isn't an interrupt controller")] NotInterruptController, @@ -57,7 +57,7 @@ pub enum IoError { #[error("The requested I/O operation was out of bounds for the block device")] OutOfBounds, - #[error("Courruption found in the filesystem metadata")] + #[error("Corruption found in the filesystem metadata")] MetadataCorruption, } @@ -114,7 +114,7 @@ pub enum ExecError { #[error("Invalid Script Format")] InvalidScriptFormat, - #[error("Invalid Porgram Header Format")] + #[error("Invalid Program Header Format")] InvalidPHdrFormat, } @@ -156,7 +156,7 @@ pub enum KernelError { #[error("Not a tty")] NotATty, - #[error("Fault errror during syscall")] + #[error("Fault error during syscall")] Fault, #[error("Not an open file descriptor")] diff --git a/libkernel/src/fs/filesystems/fat32/bpb.rs b/libkernel/src/fs/filesystems/fat32/bpb.rs index b0420aee..1b2d88d2 100644 --- a/libkernel/src/fs/filesystems/fat32/bpb.rs +++ b/libkernel/src/fs/filesystems/fat32/bpb.rs @@ -134,7 +134,7 @@ impl BiosParameterBlock { pub fn cluster_to_sectors(&self, cluster: Cluster) -> Result> { if cluster.0 < 2 { - warn!("Cannot conver sentinel cluster number"); + warn!("Cannot convert sentinel cluster number"); Err(FsError::InvalidFs.into()) } else { let root_sector = Sector( diff --git a/libkernel/src/fs/filesystems/fat32/reader.rs b/libkernel/src/fs/filesystems/fat32/reader.rs index 36ac007d..bb080b57 100644 --- a/libkernel/src/fs/filesystems/fat32/reader.rs +++ b/libkernel/src/fs/filesystems/fat32/reader.rs @@ -97,7 +97,7 @@ impl Fat32Reader { } } - // The bounds checks on `effective_buf` throughout the loops ensure that + // The bounds check on `effective_buf` throughout the loops ensure that // the final `read_sector` call will be passed a smaller slice, // correctly reading only the remaining bytes and handling the tail // misalignment automagically. See `self.fs.read_sector`. diff --git a/libkernel/src/fs/path.rs b/libkernel/src/fs/path.rs index 8f3a5d87..3fee96dd 100644 --- a/libkernel/src/fs/path.rs +++ b/libkernel/src/fs/path.rs @@ -144,7 +144,7 @@ impl Path { /// ``` pub fn strip_prefix(&self, base: &Path) -> Option<&Path> { if self.inner.starts_with(&base.inner) { - // If the prefixes are the same and they have the same length, the + // If the prefixes are the same, and they have the same length, the // whole string is the prefix. if base.inner.len() == self.inner.len() { return Some(Path::new("")); diff --git a/libkernel/src/lib.rs b/libkernel/src/lib.rs index 73f1f009..7ca3c70b 100644 --- a/libkernel/src/lib.rs +++ b/libkernel/src/lib.rs @@ -81,7 +81,7 @@ pub trait UserAddressSpace: Send + Sync { /// space are flushed. fn activate(&self); - /// Decativate this address space for the current CPU. + /// Deactivate this address space for the current CPU. /// /// This should be called to leave the CPU without any current process /// state. Used on process termination code-paths. diff --git a/libkernel/src/memory/page.rs b/libkernel/src/memory/page.rs index 06ca713c..5c7b595f 100644 --- a/libkernel/src/memory/page.rs +++ b/libkernel/src/memory/page.rs @@ -49,7 +49,7 @@ impl PageFrame { } } -/// A conveniance wrapper for dealing with single-page allocaitons. +/// A convenience wrapper for dealing with single-page allocations. pub struct ClaimedPage, T: AddressTranslator<()>>( PageAllocation<'static, A>, PhantomData, @@ -82,7 +82,7 @@ impl, T: AddressTranslator<()>> ClaimedPage Self { Self( unsafe { diff --git a/libkernel/src/memory/page_alloc.rs b/libkernel/src/memory/page_alloc.rs index f60035da..1444ce43 100644 --- a/libkernel/src/memory/page_alloc.rs +++ b/libkernel/src/memory/page_alloc.rs @@ -685,7 +685,7 @@ pub mod tests { fixture.assert_free_list_counts(&expected_counts); } - /// Tests the allocation of a multi-page block and verifies head/tail metadata. + /// Tests the allocation of a multipage block and verifies head/tail metadata. #[test] fn alloc_multi_page_block() { let fixture = TestFixture::new(&[(0, (1 << (MAX_ORDER + PAGE_SHIFT)) * 2)], &[]); diff --git a/libkernel/src/memory/proc_vm/vmarea.rs b/libkernel/src/memory/proc_vm/vmarea.rs index 928608f3..b9d3981d 100644 --- a/libkernel/src/memory/proc_vm/vmarea.rs +++ b/libkernel/src/memory/proc_vm/vmarea.rs @@ -56,14 +56,14 @@ impl VMAPermissions { } } -/// Describes the kind of access that occured during a page fault. +/// Describes the kind of access that occurred during a page fault. #[derive(Clone, Copy, PartialEq, Eq)] pub enum AccessKind { /// The CPU attempted to read the faulting address. Read, /// The CPU attempted to write to the faulting address. Write, - /// The CPU attempted to execute the instruciton at the faulting address. + /// The CPU attempted to execute the instruction at the faulting address. Execute, } @@ -199,7 +199,7 @@ impl VMArea { /// memory permissions. /// /// Note: If a program header's VA isn't page-aligned this function will - /// align it down and addjust the offset and size accordingly. + /// align it down and adjust the offset and size accordingly. /// /// # Arguments /// * `f`: A handle to the ELF file's inode. diff --git a/libkernel/src/sync/condvar.rs b/libkernel/src/sync/condvar.rs index 49bf59db..92818921 100644 --- a/libkernel/src/sync/condvar.rs +++ b/libkernel/src/sync/condvar.rs @@ -64,7 +64,7 @@ impl CondVar { /// # Arguments /// * `predicate`: A closure that checks the condition in the underlying /// state. It should return `None` to continue waiting, or `Some(T)` to - /// stop waitng and yield T to the caller. + /// stop waiting and yield T to the caller. #[must_use = "futures do nothing unless you `.await` or poll them"] pub fn wait_until(&self, predicate: F) -> impl Future + use where diff --git a/libkernel/src/sync/per_cpu.rs b/libkernel/src/sync/per_cpu.rs index 780c3354..424d0ef4 100644 --- a/libkernel/src/sync/per_cpu.rs +++ b/libkernel/src/sync/per_cpu.rs @@ -38,7 +38,7 @@ impl IrqGuard { impl Drop for IrqGuard { fn drop(&mut self) { - // Enaure we drop the refcell guard prior to restoring interrupts. + // Ensure we drop the refcell guard prior to restoring interrupts. unsafe { ManuallyDrop::drop(&mut self.guard) }; CPU::restore_interrupt_state(self.flags); @@ -132,7 +132,8 @@ impl PerCpu { /// Returns a reference to the underlying datakj for the current CPU. /// - /// # Panics Panics if the `PerCpu` variable has not been initialized. + /// # Panics + /// Panics if the `PerCpu` variable has not been initialized. fn get_cell(&self) -> &RefCell { let id = CPU::id(); let base_ptr = self.ptr.load(Ordering::Acquire); diff --git a/src/arch/arm64/boot/mod.rs b/src/arch/arm64/boot/mod.rs index 3a120316..56938825 100644 --- a/src/arch/arm64/boot/mod.rs +++ b/src/arch/arm64/boot/mod.rs @@ -43,7 +43,7 @@ pub(super) mod secondary; global_asm!(include_str!("start.s")); -/// Stage 1 Initialize of the system architechture. +/// Stage 1 Initialize of the system architecture. /// /// This function is called by the main primary CPU with the other CPUs parked. /// All interrupts should be disabled, the ID map setup in TTBR0 and the highmem diff --git a/src/arch/arm64/memory/fault.rs b/src/arch/arm64/memory/fault.rs index b27044b2..b462502d 100644 --- a/src/arch/arm64/memory/fault.rs +++ b/src/arch/arm64/memory/fault.rs @@ -70,7 +70,7 @@ fn handle_uacess_abort(exception: Exception, info: AbortIss, state: &mut Excepti match run_mem_fault_handler(exception, info) { // We mapped in a page, the uacess handler can proceed. Ok(FaultResolution::Resolved) => (), - // If the fault coldn't be resolved, signal to the uacess fixup that + // If the fault couldn't be resolved, signal to the uacess fixup that // the abort failed. Ok(FaultResolution::Denied) => { state.x[0] = UAccessResult::AbortDenied as _; diff --git a/src/arch/arm64/memory/fixmap.rs b/src/arch/arm64/memory/fixmap.rs index e907d9c8..d3980e02 100644 --- a/src/arch/arm64/memory/fixmap.rs +++ b/src/arch/arm64/memory/fixmap.rs @@ -134,7 +134,7 @@ impl Fixmap { let mut phys_region = PhysMemoryRegion::new(fdt_ptr.to_untyped(), sz); let mut va = FIXMAP_BASE; - let invaldator = AllEl1TlbInvalidator::new(); + let invalidator = AllEl1TlbInvalidator::new(); while phys_region.size() > 0 { L3Table::from_ptr(TVA::from_ptr_mut(&mut self.l3[0] as *mut _)).set_desc( @@ -144,7 +144,7 @@ impl Fixmap { MemoryType::Normal, PtePermissions::ro(false), ), - &invaldator, + &invalidator, ); phys_region = phys_region.add_pages(1); diff --git a/src/drivers/interrupts/arm_gic_v3.rs b/src/drivers/interrupts/arm_gic_v3.rs index ce57e736..2d5aadfe 100644 --- a/src/drivers/interrupts/arm_gic_v3.rs +++ b/src/drivers/interrupts/arm_gic_v3.rs @@ -269,7 +269,7 @@ impl ArmGicV3 { // This is a simplified search. A full implementation should parse the // GICR's TYPER to find the correct redistributor for a given MPIDR. For // systems where cores and redistributors are mapped linearly (like QEMU - // virt) this should be fine, but we do an assert just to be ensure. + // virt) this should be fine, but we do an assert just to ensure. let core_id = (mpidr & 0xFF) + ((mpidr >> 8) & 0xFF) * 4; // Simple linear core ID let rdist_offset = core_id as usize * self.rdist_stride; let rdist_addr = self.rdist_base.value() + rdist_offset; diff --git a/src/drivers/timer/armv8_arch.rs b/src/drivers/timer/armv8_arch.rs index 8324f283..2cafa0a2 100644 --- a/src/drivers/timer/armv8_arch.rs +++ b/src/drivers/timer/armv8_arch.rs @@ -55,7 +55,7 @@ fn armv8_timer_probe(dm: &mut DriverManager, d: DeviceDescriptor) -> Result { use libkernel::error::ProbeError::*; - let interrupt_node = fdt_node.interrupt_parent().ok_or(NoParentIntterupt)?.node; + let interrupt_node = fdt_node.interrupt_parent().ok_or(NoParentInterrupt)?.node; let interrupt_manager = dm .find_by_name(interrupt_node.name) diff --git a/src/drivers/timer/mod.rs b/src/drivers/timer/mod.rs index d5354b9f..81e0f487 100644 --- a/src/drivers/timer/mod.rs +++ b/src/drivers/timer/mod.rs @@ -192,7 +192,7 @@ impl SysTimer { pub fn schedule_preempt(&self, when: Instant) { let mut wake_q = WAKEUP_Q.borrow_mut(); - // Insert the pre-emption event. + // Insert the preemption event. wake_q.push(WakeupEvent { when, what: WakeupKind::Preempt, @@ -205,7 +205,7 @@ impl SysTimer { } /// Arms the hardware timer on the current CPU so that the next scheduled - /// `WakeupEvent` (or the fallback pre-emption tick) will fire. + /// `WakeupEvent` (or the fallback preemption tick) will fire. /// Secondary CPUs should call this right after they have enabled their /// interrupt controller so that they start receiving timer interrupts. pub fn kick_current_cpu(&self) { @@ -235,7 +235,7 @@ pub fn now() -> Option { } /// Puts the current task to sleep for `duration`. If no timer driver has yet -/// been loaded, the funtion returns without sleeping. +/// been loaded, the function returns without sleeping. pub async fn sleep(duration: Duration) { // A sleep of zero duration returns now. if duration.is_zero() { @@ -255,7 +255,7 @@ pub fn kick_current_cpu() { } } -/// Arms a pre-emption timer for the running task on this CPU. +/// Arms a preemption timer for the running task on this CPU. /// Called by the scheduler every time it issues a new eligible virtual deadline. pub fn schedule_preempt(when: Instant) { if let Some(timer) = SYS_TIMER.get() { diff --git a/src/drivers/uart/imx_lp.rs b/src/drivers/uart/imx_lp.rs index f1f5ffea..2026fdc0 100644 --- a/src/drivers/uart/imx_lp.rs +++ b/src/drivers/uart/imx_lp.rs @@ -159,7 +159,7 @@ pub fn imx8ulp_lpuart_probe( .next() .ok_or(NoInterrupts)?; - let interrupt_node = fdt_node.interrupt_parent().ok_or(NoParentIntterupt)?.node; + let interrupt_node = fdt_node.interrupt_parent().ok_or(NoParentInterrupt)?.node; let interrupt_manager = dm .find_by_name(interrupt_node.name) diff --git a/src/drivers/uart/pl011.rs b/src/drivers/uart/pl011.rs index 658595ea..f95d000d 100644 --- a/src/drivers/uart/pl011.rs +++ b/src/drivers/uart/pl011.rs @@ -103,7 +103,7 @@ pub fn pl011_probe(dm: &mut DriverManager, d: DeviceDescriptor) -> Result Result { } if group != -1 { let gid = Gid::new(group as _); - // doesnt seem like theres real groups so this is as good as it gets + // doesn't seem like there's real groups so this is as good as it gets if creds.uid() != attr.uid || creds.gid() != gid { creds.caps().check_capable(CapabilitiesFlags::CAP_CHOWN)?; } diff --git a/src/interrupts/cpu_messenger.rs b/src/interrupts/cpu_messenger.rs index cb938ed0..a507ec31 100644 --- a/src/interrupts/cpu_messenger.rs +++ b/src/interrupts/cpu_messenger.rs @@ -61,7 +61,7 @@ const MESSENGER_IRQ_DESC: InterruptDescriptor = InterruptDescriptor::Ipi(0); pub fn cpu_messenger_init(num_cpus: usize) { let cpu_messenger = get_interrupt_root() - .expect("Interrupt root should be avilable") + .expect("Interrupt root should be available") .claim_interrupt( InterruptConfig { descriptor: MESSENGER_IRQ_DESC, diff --git a/src/interrupts/mod.rs b/src/interrupts/mod.rs index 261084fc..8e672f2a 100644 --- a/src/interrupts/mod.rs +++ b/src/interrupts/mod.rs @@ -54,8 +54,8 @@ pub trait InterruptController: Send + Sync { fn raise_ipi(&mut self, target_cpu_id: usize); /// Enable the interrupt controller for this core. This is the entry point - /// for secondaries only, the primary CPU should have initalized via the - /// creation of the interupt controller object. + /// for secondaries only, the primary CPU should have initialized via the + /// creation of the interrupt controller object. fn enable_core(&mut self, cpu_id: usize); fn parse_fdt_interrupt_regs( diff --git a/src/kernel/kpipe.rs b/src/kernel/kpipe.rs index 07154ed4..84c1acf9 100644 --- a/src/kernel/kpipe.rs +++ b/src/kernel/kpipe.rs @@ -61,7 +61,7 @@ impl KPipe { /// /// This function will fill the kbuf as much as possible and return the /// number of bytes written. If the buffer is full when called, this - /// function will block until space becomes avilable. + /// function will block until space becomes available. pub async fn copy_from_user(&self, src: UA, count: usize) -> Result { let mut temp_buf = [0u8; USER_COPY_CHUNK_SIZE]; let chunk_buf = &mut temp_buf[..min(count, USER_COPY_CHUNK_SIZE)]; @@ -75,7 +75,7 @@ impl KPipe { /// /// This function will drain as much of the buffer as possible and return /// the number of bytes written. If the buffer is empty when called, this - /// function will block until data becomes avilable. + /// function will block until data becomes available. pub async fn copy_to_user(&self, dst: UA, count: usize) -> Result { let mut temp_buf = [0u8; USER_COPY_CHUNK_SIZE]; let chunk_buf = &mut temp_buf[..min(count, USER_COPY_CHUNK_SIZE)]; diff --git a/src/memory/fault.rs b/src/memory/fault.rs index ce350fc6..e7ae8639 100644 --- a/src/memory/fault.rs +++ b/src/memory/fault.rs @@ -84,7 +84,7 @@ pub fn handle_demand_fault( PtePermissions::from(vma.permissions()), ) { Ok(_) => { - // We mapped our page, leak it for reclimation by the + // We mapped our page, leak it for reclamation by the // address-space tear-down code. new_page.leak(); @@ -93,7 +93,7 @@ pub fn handle_demand_fault( Err(KernelError::MappingError(MapError::AlreadyMapped)) => { // Another CPU mapped the page for us, since we've validated the // VMA is still valid and the same mapping code has been - // executed, it's guarenteed that the correct page will have + // executed, it's guaranteed that the correct page will have // been mapped by the other CPU. // // Do not leak the page, since it's not going to be used. @@ -124,7 +124,7 @@ pub fn handle_demand_fault( } /// Handle a page fault when a page is present, but the access kind differ from -/// permissble accessees defined in the PTE, a 'protection' fault. +/// permissible accesses defined in the PTE, a 'protection' fault. pub fn handle_protection_fault( vm: &mut ProcVM, faulting_addr: VA, @@ -161,7 +161,7 @@ pub fn handle_protection_fault( } else { let mut new_page = ClaimedPage::alloc_zeroed()?; - // Oterwise, copy data from the new page, map it and decrement + // Otherwise, copy data from the new page, map it and decrement // the refcount on the shared page. let src_page = unsafe { ClaimedPage::from_pfn(pg_info.pfn) }; diff --git a/src/process/clone.rs b/src/process/clone.rs index 821714ba..16846844 100644 --- a/src/process/clone.rs +++ b/src/process/clone.rs @@ -64,11 +64,11 @@ pub async fn sys_clone( let mut user_ctx = *current_task.ctx.user(); - // TODO: Make this arch indepdenant. The child returns '0' on clone. + // TODO: Make this arch independent. The child returns '0' on clone. user_ctx.x[0] = 0; if flags.contains(CloneFlags::CLONE_SETTLS) { - // TODO: Make this arch indepdenant. + // TODO: Make this arch independent. user_ctx.tpid_el0 = tls as _; } @@ -81,13 +81,13 @@ pub async fn sys_clone( user_ctx.sp_el0 = newsp.value() as _; ( - // A new task whtin this thread group. + // A new task within this thread group. current_task.process.clone(), current_task.process.next_tid(), ) } else { let tgid_parent = if flags.contains(CloneFlags::CLONE_PARENT) { - // Use the parnent's parent as the new parent. + // Use the parent's parent as the new parent. current_task .process .parent diff --git a/src/process/exec.rs b/src/process/exec.rs index 4c1dab4e..7596bf41 100644 --- a/src/process/exec.rs +++ b/src/process/exec.rs @@ -120,7 +120,7 @@ async fn exec_elf(inode: Arc, argv: Vec, envp: Vec) - } } - // Setup a program bias for PIE. + // Set up a program bias for PIE. let main_bias = if elf.e_type.get(endian) == ET_DYN { Some(PROG_BIAS) } else { @@ -136,7 +136,7 @@ async fn exec_elf(inode: Arc, argv: Vec, envp: Vec) - let mut vmas = Vec::new(); - // Process the binary progream headers. + // Process the binary program headers. if let Some(hdr_addr) = process_prog_headers(hdrs, &mut vmas, main_bias, inode.clone(), endian) { auxv.push(AT_PHDR); @@ -177,7 +177,7 @@ async fn exec_elf(inode: Arc, argv: Vec, envp: Vec) - // We don't have to worry about actually calling for a full context switch // here. Parts of the old process that are replaced will go out of scope and - // be cleaned up (open files, etc); We don't need to preseve any extra + // be cleaned up (open files, etc.); We don't need to preserve any extra // state. Simply activate the new process's address space. vm.mm_mut().address_space_mut().activate(); diff --git a/src/process/exit.rs b/src/process/exit.rs index 0831fd78..e767f928 100644 --- a/src/process/exit.rs +++ b/src/process/exit.rs @@ -49,7 +49,7 @@ pub fn do_exit_group(exit_code: ChildState) { // Don't signal ourselves if other_thread.tid != task.tid { // TODO: Send an IPI/Signal to halt execution now. For now, just - // wait for the scheduler to never schdule any of it's tasks + // wait for the scheduler to never schedule any of it's tasks // again. *other_thread.state.lock_save_irq() = TaskState::Finished; } diff --git a/src/process/fd_table.rs b/src/process/fd_table.rs index 392a9396..a8234962 100644 --- a/src/process/fd_table.rs +++ b/src/process/fd_table.rs @@ -25,7 +25,7 @@ impl Fd { } impl From for Fd { - // Conveience implemtnation for syscalls. + // Convenience implementation for syscalls. fn from(value: u64) -> Self { Self(value.cast_signed() as _) } diff --git a/src/process/mod.rs b/src/process/mod.rs index 9c604536..966a8f61 100644 --- a/src/process/mod.rs +++ b/src/process/mod.rs @@ -200,13 +200,13 @@ impl Task { self.tid } - /// Return a new desctiptor that uniquely represents this task in the + /// Return a new descriptor that uniquely represents this task in the /// system. pub fn descriptor(&self) -> TaskDescriptor { TaskDescriptor::from_tgid_tid(self.process.tgid, self.tid) } - /// Get a page from the task's address space, in an atomic fasion - i.e. + /// Get a page from the task's address space, in an atomic fashion - i.e. /// with the process address space locked. /// /// Handle any faults such that the page will be resident in memory and return diff --git a/src/process/thread_group.rs b/src/process/thread_group.rs index 83ee1479..ed140cf1 100644 --- a/src/process/thread_group.rs +++ b/src/process/thread_group.rs @@ -109,7 +109,7 @@ pub struct ThreadGroup { unsafe impl Send for ThreadGroup {} impl ThreadGroup { - // Return the next avilable thread id. Will never return a thread who's ID + // Return the next available thread id. Will never return a thread whose ID // == TGID, since that is defined as the main, root thread. pub fn next_tid(&self) -> Tid { let mut v = self.next_tid.fetch_add(1, Ordering::Relaxed); diff --git a/src/process/thread_group/signal/ksigaction.rs b/src/process/thread_group/signal/ksigaction.rs index b970cd0e..0888a8a1 100644 --- a/src/process/thread_group/signal/ksigaction.rs +++ b/src/process/thread_group/signal/ksigaction.rs @@ -23,7 +23,7 @@ pub enum KSignalAction { impl KSignalAction { /// Returns the default action for a given signal. /// - /// For signals who's default is to be ignored, `None` is returned. + /// For signals whose default is to be ignored, `None` is returned. pub const fn default_action(signal: SigId) -> Option { match signal { SigId::SIGABRT => Some(Self::Core),