Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aarkegz committed Dec 5, 2024
1 parent 7ec2845 commit 1823279
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion api/arceos_posix_api/src/imp/io_mpx/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub unsafe fn sys_epoll_wait(
return Ok(events_num as c_int);
}

if deadline.map_or(false, |ddl| wall_time() >= ddl) {
if deadline.is_some_and(|ddl| wall_time() >= ddl) {
debug!(" timeout!");
return Ok(0);
}
Expand Down
2 changes: 1 addition & 1 deletion api/arceos_posix_api/src/imp/io_mpx/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub unsafe fn sys_select(
return Ok(res);
}

if deadline.map_or(false, |ddl| wall_time() >= ddl) {
if deadline.is_some_and(|ddl| wall_time() >= ddl) {
debug!(" timeout!");
return Ok(0);
}
Expand Down
10 changes: 5 additions & 5 deletions modules/axsync/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<T: ?Sized> Mutex<T> {
}
}

impl<T: ?Sized + Default> Default for Mutex<T> {
impl<T: Default> Default for Mutex<T> {
#[inline(always)]
fn default() -> Self {
Self::new(Default::default())
Expand All @@ -167,7 +167,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
}
}

impl<'a, T: ?Sized> Deref for MutexGuard<'a, T> {
impl<T: ?Sized> Deref for MutexGuard<'_, T> {
type Target = T;
#[inline(always)]
fn deref(&self) -> &T {
Expand All @@ -176,21 +176,21 @@ impl<'a, T: ?Sized> Deref for MutexGuard<'a, T> {
}
}

impl<'a, T: ?Sized> DerefMut for MutexGuard<'a, T> {
impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut T {
// We know statically that only we are referencing data
unsafe { &mut *self.data }
}
}

impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
}

impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
impl<T: ?Sized> Drop for MutexGuard<'_, T> {
/// The dropping of the [`MutexGuard`] will release the lock it was created from.
fn drop(&mut self) {
unsafe { self.lock.force_unlock() }
Expand Down
9 changes: 5 additions & 4 deletions modules/axtask/src/run_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ percpu_static! {
/// initialized before being accessed to ensure safe usage.
static mut RUN_QUEUES: [MaybeUninit<&'static mut AxRunQueue>; axconfig::SMP] =
[ARRAY_REPEAT_VALUE; axconfig::SMP];
#[allow(clippy::declare_interior_mutable_const)] // It's ok because it's used only for initialization `RUN_QUEUES`.
const ARRAY_REPEAT_VALUE: MaybeUninit<&'static mut AxRunQueue> = MaybeUninit::uninit();

/// Returns a reference to the current run queue in [`CurrentRunQueueRef`].
Expand Down Expand Up @@ -200,7 +201,7 @@ pub(crate) struct AxRunQueueRef<'a, G: BaseGuard> {
_phantom: core::marker::PhantomData<G>,
}

impl<'a, G: BaseGuard> Drop for AxRunQueueRef<'a, G> {
impl<G: BaseGuard> Drop for AxRunQueueRef<'_, G> {
fn drop(&mut self) {
G::release(self.state);
}
Expand All @@ -218,14 +219,14 @@ pub(crate) struct CurrentRunQueueRef<'a, G: BaseGuard> {
_phantom: core::marker::PhantomData<G>,
}

impl<'a, G: BaseGuard> Drop for CurrentRunQueueRef<'a, G> {
impl<G: BaseGuard> Drop for CurrentRunQueueRef<'_, G> {
fn drop(&mut self) {
G::release(self.state);
}
}

/// Management operations for run queue, including adding tasks, unblocking tasks, etc.
impl<'a, G: BaseGuard> AxRunQueueRef<'a, G> {
impl<G: BaseGuard> AxRunQueueRef<'_, G> {
/// Adds a task to the scheduler.
///
/// This function is used to add a new task to the scheduler.
Expand Down Expand Up @@ -268,7 +269,7 @@ impl<'a, G: BaseGuard> AxRunQueueRef<'a, G> {
}

/// Core functions of run queue.
impl<'a, G: BaseGuard> CurrentRunQueueRef<'a, G> {
impl<G: BaseGuard> CurrentRunQueueRef<'_, G> {
#[cfg(feature = "irq")]
pub fn scheduler_timer_tick(&mut self) {
let curr = &self.current_task;
Expand Down
1 change: 1 addition & 0 deletions ulib/axlibc/src/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub unsafe extern "C" fn strerror(e: c_int) -> *mut c_char {
.map(|e| e.as_str())
.unwrap_or("Unknown error")
};
#[allow(static_mut_refs)]
unsafe {
strerror_buf[..err_str.len()].copy_from_slice(err_str.as_bytes());
strerror_buf.as_mut_ptr() as *mut c_char
Expand Down
2 changes: 1 addition & 1 deletion ulib/axstd/src/fs/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<'a> Iterator for ReadDir<'a> {
}
}

impl<'a> DirEntry<'a> {
impl DirEntry<'_> {
/// Returns the full path to the file that this entry represents.
///
/// The full path is created by joining the original path to `read_dir`
Expand Down
8 changes: 4 additions & 4 deletions ulib/axstd/src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<T: ?Sized + fmt::Debug> fmt::Debug for Mutex<T> {
}
}

impl<'a, T: ?Sized> Deref for MutexGuard<'a, T> {
impl<T: ?Sized> Deref for MutexGuard<'_, T> {
type Target = T;
#[inline(always)]
fn deref(&self) -> &T {
Expand All @@ -176,21 +176,21 @@ impl<'a, T: ?Sized> Deref for MutexGuard<'a, T> {
}
}

impl<'a, T: ?Sized> DerefMut for MutexGuard<'a, T> {
impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
#[inline(always)]
fn deref_mut(&mut self) -> &mut T {
// We know statically that only we are referencing data
unsafe { &mut *self.data }
}
}

impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
impl<T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
}

impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
impl<T: ?Sized> Drop for MutexGuard<'_, T> {
/// The dropping of the [`MutexGuard`] will release the lock it was created from.
fn drop(&mut self) {
unsafe { self.lock.force_unlock() }
Expand Down

0 comments on commit 1823279

Please sign in to comment.