From 59c30c32b42ae2b347297e013604cf2c42e6b160 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Tue, 26 Oct 2021 13:38:29 +0300 Subject: [PATCH] misc: format sources --- fs/memfs/src/tar.rs | 7 ++----- fs/vfs/src/file.rs | 2 +- kernel/src/arch/aarch64/boot/mod.rs | 5 ++++- kernel/src/arch/aarch64/irq/gic/mod.rs | 2 +- kernel/src/proc/mod.rs | 5 +---- kernel/src/proc/process.rs | 8 ++++++-- kernel/src/proc/sched.rs | 6 +++--- kernel/src/sync.rs | 11 ++++++----- kernel/src/syscall.rs | 6 +++++- libcommon/src/lib.rs | 3 +-- libusr/src/lib.rs | 7 ++----- 11 files changed, 32 insertions(+), 30 deletions(-) diff --git a/fs/memfs/src/tar.rs b/fs/memfs/src/tar.rs index 79419b2..0cd4450 100644 --- a/fs/memfs/src/tar.rs +++ b/fs/memfs/src/tar.rs @@ -1,5 +1,5 @@ -use vfs::VnodeKind; use error::Errno; +use vfs::VnodeKind; #[repr(packed)] #[allow(dead_code)] @@ -28,10 +28,7 @@ pub struct TarIterator { } impl TarIterator { - pub const fn new( - address: *const u8, - limit: *const u8, - ) -> Self { + pub const fn new(address: *const u8, limit: *const u8) -> Self { Self { address, limit, diff --git a/fs/vfs/src/file.rs b/fs/vfs/src/file.rs index ec54771..f4d8dad 100644 --- a/fs/vfs/src/file.rs +++ b/fs/vfs/src/file.rs @@ -80,8 +80,8 @@ impl File { mod tests { use super::*; use crate::{node::VnodeData, Filesystem, Vnode, VnodeImpl, VnodeKind, VnodeRef}; - use alloc::rc::Rc; use alloc::boxed::Box; + use alloc::rc::Rc; use core::ffi::c_void; pub struct DummyInode; diff --git a/kernel/src/arch/aarch64/boot/mod.rs b/kernel/src/arch/aarch64/boot/mod.rs index 8cd6127..c3d61e1 100644 --- a/kernel/src/arch/aarch64/boot/mod.rs +++ b/kernel/src/arch/aarch64/boot/mod.rs @@ -1,6 +1,9 @@ //! aarch64 common boot logic -use crate::arch::{aarch64::reg::{CPACR_EL1, CNTKCTL_EL1}, machine}; +use crate::arch::{ + aarch64::reg::{CNTKCTL_EL1, CPACR_EL1}, + machine, +}; use crate::dev::{fdt::DeviceTree, irq::IntSource, Device}; //use crate::debug::Level; use crate::mem::{ diff --git a/kernel/src/arch/aarch64/irq/gic/mod.rs b/kernel/src/arch/aarch64/irq/gic/mod.rs index aa70f78..4346f8a 100644 --- a/kernel/src/arch/aarch64/irq/gic/mod.rs +++ b/kernel/src/arch/aarch64/irq/gic/mod.rs @@ -97,7 +97,7 @@ impl IntController for Gic { Some(handler) => { drop(table); handler.handle_irq().expect("irq handler failed") - }, + } } } diff --git a/kernel/src/proc/mod.rs b/kernel/src/proc/mod.rs index d551f11..165b2e3 100644 --- a/kernel/src/proc/mod.rs +++ b/kernel/src/proc/mod.rs @@ -2,10 +2,7 @@ use crate::mem; use crate::sync::IrqSafeSpinLock; -use alloc::{ - boxed::Box, - collections::{BTreeMap}, -}; +use alloc::{boxed::Box, collections::BTreeMap}; pub mod elf; pub mod process; diff --git a/kernel/src/proc/process.rs b/kernel/src/proc/process.rs index 7400e74..7021cd9 100644 --- a/kernel/src/proc/process.rs +++ b/kernel/src/proc/process.rs @@ -44,7 +44,7 @@ struct ProcessInner { space: Option<&'static mut Space>, state: State, id: Pid, - exit: Option + exit: Option, } /// Structure describing an operating system process @@ -224,7 +224,11 @@ impl Process { /// Waits for a process to finish and reaps it pub fn waitpid(pid: Pid) -> Result { loop { - let proc = PROCESSES.lock().get(&pid).cloned().ok_or(Errno::DoesNotExist)?; + let proc = PROCESSES + .lock() + .get(&pid) + .cloned() + .ok_or(Errno::DoesNotExist)?; if let Some(r) = proc.collect() { PROCESSES.lock().remove(&proc.id()); diff --git a/kernel/src/proc/sched.rs b/kernel/src/proc/sched.rs index 2700fba..afe2fb2 100644 --- a/kernel/src/proc/sched.rs +++ b/kernel/src/proc/sched.rs @@ -1,8 +1,8 @@ //! use crate::proc::{Pid, Process, ProcessRef, PROCESSES}; -use crate::util::InitOnce; use crate::sync::IrqSafeSpinLock; -use alloc::{rc::Rc, collections::VecDeque}; +use crate::util::InitOnce; +use alloc::{collections::VecDeque, rc::Rc}; struct SchedulerInner { queue: VecDeque, @@ -103,7 +103,7 @@ impl Scheduler { let lock = PROCESSES.lock(); ( lock.get(¤t).unwrap().clone(), - lock.get(&next).unwrap().clone() + lock.get(&next).unwrap().clone(), ) }; diff --git a/kernel/src/sync.rs b/kernel/src/sync.rs index 5a90d4c..49ae64d 100644 --- a/kernel/src/sync.rs +++ b/kernel/src/sync.rs @@ -1,14 +1,14 @@ //! Synchronization facilities module use crate::arch::platform::{irq_mask_save, irq_restore}; -use core::sync::atomic::{AtomicBool, Ordering}; use core::cell::UnsafeCell; use core::ops::{Deref, DerefMut}; +use core::sync::atomic::{AtomicBool, Ordering}; /// Lock structure ensuring IRQs are disabled when inner value is accessed pub struct IrqSafeSpinLock { value: UnsafeCell, - state: AtomicBool + state: AtomicBool, } /// Guard-structure wrapping a reference to value owned by [IrqSafeSpinLock]. @@ -24,13 +24,14 @@ impl IrqSafeSpinLock { pub const fn new(value: T) -> Self { Self { value: UnsafeCell::new(value), - state: AtomicBool::new(false) + state: AtomicBool::new(false), } } #[inline(always)] fn try_lock(&self) -> Result { - self.state.compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed) + self.state + .compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed) } #[inline(always)] @@ -50,7 +51,7 @@ impl IrqSafeSpinLock { IrqSafeSpinLockGuard { lock: self, - irq_state + irq_state, } } } diff --git a/kernel/src/syscall.rs b/kernel/src/syscall.rs index 7710812..d3b00cf 100644 --- a/kernel/src/syscall.rs +++ b/kernel/src/syscall.rs @@ -15,7 +15,11 @@ fn translate(virt: usize) -> Option { fn validate_user_ptr(base: usize, len: usize) -> Result<(), Errno> { if base > mem::KERNEL_OFFSET || base + len > mem::KERNEL_OFFSET { - warnln!("User region refers to kernel memory: base={:#x}, len={:#x}", base, len); + warnln!( + "User region refers to kernel memory: base={:#x}, len={:#x}", + base, + len + ); return Err(Errno::InvalidArgument); } diff --git a/libcommon/src/lib.rs b/libcommon/src/lib.rs index eb871e5..8757a18 100644 --- a/libcommon/src/lib.rs +++ b/libcommon/src/lib.rs @@ -38,5 +38,4 @@ pub fn path_component_right(path: &str) -> (&str, &str) { } #[cfg(test)] -mod tests { -} +mod tests {} diff --git a/libusr/src/lib.rs b/libusr/src/lib.rs index 5ae4587..5e9648e 100644 --- a/libusr/src/lib.rs +++ b/libusr/src/lib.rs @@ -1,14 +1,11 @@ -#![feature( - asm, - alloc_error_handler, -)] +#![feature(asm, alloc_error_handler)] #![no_std] use core::panic::PanicInfo; -mod sys; pub mod mem; pub mod os; +mod sys; #[link_section = ".text._start"] #[no_mangle]