Skip to content

Commit

Permalink
[chore] fix the format
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Dec 2, 2024
1 parent d130bec commit ef7279d
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 31 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 9 additions & 3 deletions api/linux_syscall_api/src/syscall_task/imp/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand All @@ -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),
}
}
}
1 change: 0 additions & 1 deletion modules/axfs/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,3 @@ impl Disk {
Ok(buf.len())
}
}

6 changes: 3 additions & 3 deletions modules/axhal/src/platform/aarch64_common/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use either::{Either, Left, Right};
/// Returns platform-specific memory regions.
pub(crate) fn platform_regions() -> impl Iterator<Item = MemRegion> {
// 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(),
Expand Down
4 changes: 3 additions & 1 deletion modules/axnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
5 changes: 2 additions & 3 deletions modules/axprocess/src/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ fn stdin_read(buf: &mut [u8]) -> AxResult<usize> {
buf.as_mut_ptr().write_volatile(ch);
}
Ok(1)
}
else {
} else {
// user appilcation
let mut line = String::new();
loop {
Expand All @@ -77,7 +76,7 @@ fn stdin_read(buf: &mut [u8]) -> AxResult<usize> {
}
}
_ => {
// echo
// echo
putchar(c);
line.push(c as char);
}
Expand Down
22 changes: 11 additions & 11 deletions modules/axsync/src/completion.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand All @@ -43,10 +43,10 @@ impl Inner {

/// Cpmpletion struct, it protect by done
pub struct Completion {
inner: SpinNoIrq<Inner>
inner: SpinNoIrq<Inner>,
}

// SAFETY: have it's own SpinNoIrq protect
// SAFETY: have it's own SpinNoIrq protect
unsafe impl Sync for Completion {}
unsafe impl Send for Completion {}

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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();
}

Expand Down
13 changes: 7 additions & 6 deletions modules/axtask/src/api_s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion modules/axtask/src/timers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SpinNoIrq<TimerList<TaskWakeupEvent>>> = LazyInit::new();
Expand Down
2 changes: 1 addition & 1 deletion ulib/axstarry/src/file.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit ef7279d

Please sign in to comment.