diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc7a673..2bac311 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,16 +29,21 @@ jobs: with: arch: aarch64 - name: Check rust version - run: rustc --version --verbose + run: rustc --version --verbose - name: Clippy for the default target + continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} run: make clippy - name: Clippy for x86_64 + continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} run: make clippy ARCH=x86_64 - name: Clippy for riscv64 + continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} run: make clippy ARCH=riscv64 - name: Clippy for aarch64 + continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} run: make clippy ARCH=aarch64 - name: Check code format + continue-on-error: ${{ matrix.rust-toolchain == 'nightly' }} run: cargo fmt --all -- --check build-apps-for-unikernel: diff --git a/api/linux_syscall_api/src/syscall_task/imp/schedule.rs b/api/linux_syscall_api/src/syscall_task/imp/schedule.rs index 5b5be87..60fa7f3 100644 --- a/api/linux_syscall_api/src/syscall_task/imp/schedule.rs +++ b/api/linux_syscall_api/src/syscall_task/imp/schedule.rs @@ -230,7 +230,10 @@ pub fn syscall_sched_getscheduler_max(args: [usize; 6]) -> SyscallResult { let policy: usize = args[0]; match SchedPolicy::from(policy) { SchedPolicy::SCHED_FIFO | SchedPolicy::SCHED_RR => Ok(MAX_RT_PRIO as isize), - SchedPolicy::SCHED_OTHER | SchedPolicy::SCHED_DEADLINE | SchedPolicy::SCHED_BATCH | SchedPolicy::SCHED_IDLE => Ok(0), + SchedPolicy::SCHED_OTHER + | SchedPolicy::SCHED_DEADLINE + | SchedPolicy::SCHED_BATCH + | SchedPolicy::SCHED_IDLE => Ok(0), _ => Err(SyscallError::EINVAL), } } @@ -241,7 +244,10 @@ pub fn syscall_sched_getscheduler_min(args: [usize; 6]) -> SyscallResult { let policy: usize = args[0]; match SchedPolicy::from(policy) { SchedPolicy::SCHED_FIFO | SchedPolicy::SCHED_RR => Ok(1), - SchedPolicy::SCHED_OTHER | SchedPolicy::SCHED_DEADLINE | SchedPolicy::SCHED_BATCH | SchedPolicy::SCHED_IDLE => Ok(0), + SchedPolicy::SCHED_OTHER + | SchedPolicy::SCHED_DEADLINE + | SchedPolicy::SCHED_BATCH + | SchedPolicy::SCHED_IDLE => Ok(0), _ => Err(SyscallError::EINVAL), } -} \ No newline at end of file +} diff --git a/modules/axfs/src/dev.rs b/modules/axfs/src/dev.rs index 5977e04..825be7f 100644 --- a/modules/axfs/src/dev.rs +++ b/modules/axfs/src/dev.rs @@ -119,4 +119,3 @@ impl Disk { Ok(buf.len()) } } - diff --git a/modules/axhal/src/platform/aarch64_common/mem.rs b/modules/axhal/src/platform/aarch64_common/mem.rs index 4f733dd..6f269f6 100644 --- a/modules/axhal/src/platform/aarch64_common/mem.rs +++ b/modules/axhal/src/platform/aarch64_common/mem.rs @@ -11,9 +11,9 @@ use either::{Either, Left, Right}; /// Returns platform-specific memory regions. pub(crate) fn platform_regions() -> impl Iterator { // Feature, should registerd by user, should'n use hard coding - let iterator: Either<_, _> = if of::machin_name().is_some_and(|name| { - name.contains("raspi") || name.contains("phytiumpi") - }) { + let iterator: Either<_, _> = if of::machin_name() + .is_some_and(|name| name.contains("raspi") || name.contains("phytiumpi")) + { Left( core::iter::once(MemRegion { paddr: 0x0.into(), diff --git a/modules/axnet/src/lib.rs b/modules/axnet/src/lib.rs index b027459..691e49f 100644 --- a/modules/axnet/src/lib.rs +++ b/modules/axnet/src/lib.rs @@ -38,7 +38,9 @@ pub use self::net_impl::{ }; pub use self::net_impl::{bench_receive, bench_transmit}; pub use smoltcp::time::Duration; -pub use smoltcp::wire::{IpAddress as IpAddr, IpEndpoint as SocketAddr, Ipv4Address as Ipv4Addr, Ipv6Address as Ipv6Addr}; +pub use smoltcp::wire::{ + IpAddress as IpAddr, IpEndpoint as SocketAddr, Ipv4Address as Ipv4Addr, Ipv6Address as Ipv6Addr, +}; use axdriver::{prelude::*, AxDeviceContainer}; diff --git a/modules/axprocess/src/stdio.rs b/modules/axprocess/src/stdio.rs index e5f9cc3..c624478 100644 --- a/modules/axprocess/src/stdio.rs +++ b/modules/axprocess/src/stdio.rs @@ -56,8 +56,7 @@ fn stdin_read(buf: &mut [u8]) -> AxResult { buf.as_mut_ptr().write_volatile(ch); } Ok(1) - } - else { + } else { // user appilcation let mut line = String::new(); loop { @@ -77,7 +76,7 @@ fn stdin_read(buf: &mut [u8]) -> AxResult { } } _ => { - // echo + // echo putchar(c); line.push(c as char); } diff --git a/modules/axsync/src/completion.rs b/modules/axsync/src/completion.rs index eb4d522..44fd7d1 100644 --- a/modules/axsync/src/completion.rs +++ b/modules/axsync/src/completion.rs @@ -1,4 +1,4 @@ -//! completion +//! completion //! If you have one or more threads that must wait for some kernel activity //! to have reached a point or a specific state, completions can provide a //! race-free solution to this problem. Semantically they are somewhat like a @@ -10,18 +10,18 @@ //! you probably want to look into using one of the wait_for_completion*() //! calls and complete() instead. //! -//! Completions are built on top of the waitqueue and wakeup infrastructure of +//! Completions are built on top of the waitqueue and wakeup infrastructure of //! scheduler(axtask). The event the threads on the waitqueue are waiting for //! is reduced to a simple flag in 'struct completion', appropriately called "done". //! use alloc::sync::Arc; -use axtask::{WaitTaskList, WaitTaskNode}; -use spinlock::SpinNoIrq; use axtask::schedule; #[cfg(feature = "irq")] use axtask::schedule_timeout; +use axtask::{WaitTaskList, WaitTaskNode}; #[cfg(feature = "irq")] use core::time::Duration; +use spinlock::SpinNoIrq; use axtask::declare_wait; @@ -43,10 +43,10 @@ impl Inner { /// Cpmpletion struct, it protect by done pub struct Completion { - inner: SpinNoIrq + inner: SpinNoIrq, } -// SAFETY: have it's own SpinNoIrq protect +// SAFETY: have it's own SpinNoIrq protect unsafe impl Sync for Completion {} unsafe impl Send for Completion {} @@ -64,13 +64,13 @@ impl Completion { pub fn reinit(&self) { self.inner.lock().done = 0; } - + /// waits for completion of a task pub fn wait_for_completion(&self) { declare_wait!(waiter); loop { let mut inner = self.inner.lock(); - assert!(inner.done >=0); + assert!(inner.done >= 0); if inner.done == 0 { inner.queue.prepare_to_wait(waiter.clone()); drop(inner); @@ -83,13 +83,13 @@ impl Completion { } #[cfg(feature = "irq")] - /// waits for completion of a task (w/timeout secs) + /// waits for completion of a task (w/timeout secs) pub fn wait_for_completion_timeout(&self, secs: u64) -> bool { declare_wait!(waiter); let deadline = axhal::time::current_time() + Duration::from_secs(secs); let timeout = loop { let mut inner = self.inner.lock(); - assert!(inner.done >=0); + assert!(inner.done >= 0); if inner.done == 0 { inner.queue.prepare_to_wait(waiter.clone()); drop(inner); @@ -108,7 +108,7 @@ impl Completion { /// signals a single thread waiting on this completion pub fn complete(&self) { let mut inner = self.inner.lock(); - inner.done+=1; + inner.done += 1; inner.queue.notify_one(); } diff --git a/modules/axtask/src/api_s.rs b/modules/axtask/src/api_s.rs index 28e2754..52eef26 100644 --- a/modules/axtask/src/api_s.rs +++ b/modules/axtask/src/api_s.rs @@ -27,19 +27,20 @@ extern "C" { } pub fn global_unique_ts() -> (usize, usize) { - let boot_stack = unsafe { - current_boot_stack() as usize - }; + let boot_stack = unsafe { current_boot_stack() as usize }; (boot_stack, boot_stack + axconfig::TASK_STACK_SIZE) } pub fn dump_curr_backtrace() { //Init Unwind instance from current context - use axbacktrace::{dump_backtrace, Unwind, UnwindIf, StackInfo}; + use axbacktrace::{dump_backtrace, StackInfo, Unwind, UnwindIf}; let stack = global_unique_ts(); let stack_info = StackInfo::new(stack.0, stack.1); - axlog::info!("dump task stack range: {:#016x}: {:#016x}", - stack.0, stack.1); + axlog::info!( + "dump task stack range: {:#016x}: {:#016x}", + stack.0, + stack.1 + ); let mut unwind = Unwind::new_from_cur_ctx(stack_info); // dump current task trace dump_backtrace(&mut unwind); diff --git a/modules/axtask/src/timers.rs b/modules/axtask/src/timers.rs index d4c2ea8..3a9ba24 100644 --- a/modules/axtask/src/timers.rs +++ b/modules/axtask/src/timers.rs @@ -4,7 +4,7 @@ use lazy_init::LazyInit; use spinlock::SpinNoIrq; use timer_list::{TimeValue, TimerEvent, TimerList}; -use crate::{AxTaskRef,TaskState}; +use crate::{AxTaskRef, TaskState}; // TODO: per-CPU static TIMER_LIST: LazyInit>> = LazyInit::new(); diff --git a/ulib/axstarry/src/file.rs b/ulib/axstarry/src/file.rs index 3e543cd..c056f6f 100644 --- a/ulib/axstarry/src/file.rs +++ b/ulib/axstarry/src/file.rs @@ -1,6 +1,6 @@ //! Init some files and links in the filesystem for the apps -use alloc::{format, vec::*, string::ToString}; +use alloc::{format, string::ToString, vec::*}; use linux_syscall_api::{create_link, new_file, FileFlags, FilePath}; fn meminfo() -> &'static str {