Skip to content

Commit

Permalink
fix clippy fmt warning
Browse files Browse the repository at this point in the history
Signed-off-by: guoweikang <[email protected]>
  • Loading branch information
guoweikang committed Oct 16, 2024
1 parent f273247 commit fa69f9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
3 changes: 1 addition & 2 deletions modules/axsync/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ mod tests {
println!("Mutex test OK");
}


fn assert_mem_content<T>(val: &T, content: &[usize]) {
let val_ptr = val as *const T as *const usize;
let size = core::mem::size_of::<T>() / core::mem::size_of::<usize>();
Expand All @@ -265,7 +264,7 @@ mod tests {
fn mutex_test_for_posix() {
// Test mutex size is equal api/arceos_posix_api/build.rs
let mutex_tuple = axsync::Mutex::new(());
let content: [usize;2] = [0, 0];
let content: [usize; 2] = [0, 0];
assert_mem_content(&mutex_tuple, &content);
}
}
6 changes: 5 additions & 1 deletion modules/axtask/src/run_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ impl<'a, G: BaseGuard> AxRunQueueRef<'a, G> {
/// 2. The caller must ensure that the current task is in the running state.
/// 3. The caller must ensure that the current task is not the idle task.
/// 4. The lock of the wait queue will be released explicitly after current task is pushed into it.
pub fn blocked_resched(&mut self, mut wq_guard: WaitQueueGuard, curr_waiter: Arc<WaitTaskNode>) {
pub fn blocked_resched(
&mut self,
mut wq_guard: WaitQueueGuard,
curr_waiter: Arc<WaitTaskNode>,
) {
let curr = crate::current();
assert!(curr.is_running());
assert!(!curr.is_idle());
Expand Down
2 changes: 1 addition & 1 deletion modules/axtask/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::sync::atomic::{AtomicI32, AtomicU64, AtomicU8, Ordering};
use core::{alloc::Layout, cell::UnsafeCell, fmt, ptr::NonNull};

#[cfg(any(feature = "smp", feature = "preempt"))]
use core::sync::atomic::{AtomicBool};
use core::sync::atomic::AtomicBool;

#[cfg(feature = "smp")]
use alloc::sync::Weak;
Expand Down
11 changes: 4 additions & 7 deletions modules/axtask/src/wait_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use linked_list::{def_node, List};
use alloc::sync::Arc;
use linked_list::{def_node, List};

use crate::AxTaskRef;

Expand All @@ -14,9 +14,7 @@ pub struct WaitTaskList {
impl WaitTaskList {
/// Creates a new empty [WaitList].
pub const fn new() -> Self {
Self {
list: List::new(),
}
Self { list: List::new() }
}

/// add wait to list back
Expand All @@ -38,7 +36,7 @@ impl WaitTaskList {
if Arc::ptr_eq(node.inner(), task) {
break cursor.remove_current();
}
},
}
None => break None,
}
cursor.move_next();
Expand All @@ -53,7 +51,6 @@ impl WaitTaskList {
/// Callers must ensure that `data` is either on this list or in no list. It being on another
/// list leads to memory unsafety.
pub fn remove(&mut self, node: &Node) -> Option<Node> {
unsafe { self.list.remove(node)}
unsafe { self.list.remove(node) }
}
}

16 changes: 8 additions & 8 deletions modules/axtask/src/wait_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use alloc::sync::Arc;
use kernel_guard::{NoOp, NoPreemptIrqSave};
use kspin::{SpinNoIrq, SpinNoIrqGuard};

use crate::{current_run_queue, select_run_queue, AxTaskRef};
use crate::wait_list::{WaitTaskList, WaitTaskNode};
use crate::{current_run_queue, select_run_queue, AxTaskRef};

#[cfg(feature = "irq")]
use crate::CurrentTask;

macro_rules! declare_current_waiter {
($name: ident) => {
let $name = Arc::new(WaitTaskNode::new($crate::current().as_task_ref().clone()));
};
($name: ident) => {
let $name = Arc::new(WaitTaskNode::new($crate::current().as_task_ref().clone()));
};
}

/// A queue to store sleeping tasks.
Expand Down Expand Up @@ -71,7 +71,7 @@ impl WaitQueue {
declare_current_waiter!(waiter);
let mut rq = current_run_queue::<NoPreemptIrqSave>();
rq.blocked_resched(self.queue.lock(), waiter.clone());
// It can only be notified, it should not be in the list
// It can only be notified, it should not be in the list
assert!(self.queue.lock().remove(&waiter).is_none());
}

Expand All @@ -97,7 +97,7 @@ impl WaitQueue {
rq.blocked_resched(wq, waiter.clone());
}

// It can only be notified, it should not be in the list
// It can only be notified, it should not be in the list
assert!(self.queue.lock().remove(&waiter).is_none());
}

Expand Down Expand Up @@ -158,7 +158,7 @@ impl WaitQueue {
timeout = false;
break;
}
// It can only be notified, it should not be in the list
// It can only be notified, it should not be in the list
// FUTURE: Replace it with debug_assert
assert!(wq.remove(&waiter).is_none());
rq.blocked_resched(wq, waiter.clone());
Expand Down Expand Up @@ -199,7 +199,7 @@ impl WaitQueue {
/// If `resched` is true, the current task will be preempted when the
/// preemption is enabled.
pub fn notify_task(&mut self, resched: bool, task: &AxTaskRef) -> bool {
let mut wq = self.queue.lock();
let mut wq = self.queue.lock();
if let Some(waiter) = wq.remove_task(task) {
unblock_one_task(waiter.inner().clone(), resched);
true
Expand Down

0 comments on commit fa69f9f

Please sign in to comment.