diff --git a/api/arceos_posix_api/src/imp/fs.rs b/api/arceos_posix_api/src/imp/fs.rs index 9c88081c38..0e877e6081 100644 --- a/api/arceos_posix_api/src/imp/fs.rs +++ b/api/arceos_posix_api/src/imp/fs.rs @@ -183,6 +183,7 @@ pub unsafe fn sys_lstat(path: *const c_char, buf: *mut ctypes::stat) -> ctypes:: } /// Get the path of the current directory. +#[allow(clippy::unnecessary_cast)] // `c_char` is either `i8` or `u8` pub fn sys_getcwd(buf: *mut c_char, size: usize) -> *mut c_char { debug!("sys_getcwd <= {:#x} {}", buf as usize, size); syscall_body!(sys_getcwd, { diff --git a/examples/shell/src/main.rs b/examples/shell/src/main.rs index 301033c4fd..56e999bc99 100644 --- a/examples/shell/src/main.rs +++ b/examples/shell/src/main.rs @@ -11,8 +11,8 @@ fn path_to_str(path: &impl AsRef) -> &str { } #[cfg(feature = "axstd")] -fn path_to_str(path: &std::string::String) -> &str { - path.as_str() +fn path_to_str(path: &str) -> &str { + path } mod cmd; diff --git a/modules/axhal/src/cpu.rs b/modules/axhal/src/cpu.rs index 14feeaa39f..ae35d3654b 100644 --- a/modules/axhal/src/cpu.rs +++ b/modules/axhal/src/cpu.rs @@ -57,21 +57,19 @@ pub fn current_task_ptr() -> *const T { /// The given `ptr` must be pointed to a valid task structure. #[inline] pub unsafe fn set_current_task_ptr(ptr: *const T) { - unsafe { - #[cfg(target_arch = "x86_64")] - { - CURRENT_TASK_PTR.write_current_raw(ptr as usize) - } - #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] - { - let _guard = kernel_guard::IrqSave::new(); - CURRENT_TASK_PTR.write_current_raw(ptr as usize) - } - #[cfg(target_arch = "aarch64")] - { - use tock_registers::interfaces::Writeable; - aarch64_cpu::registers::SP_EL0.set(ptr as u64) - } + #[cfg(target_arch = "x86_64")] + { + unsafe { CURRENT_TASK_PTR.write_current_raw(ptr as usize) } + } + #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] + { + let _guard = kernel_guard::IrqSave::new(); + unsafe { CURRENT_TASK_PTR.write_current_raw(ptr as usize) } + } + #[cfg(target_arch = "aarch64")] + { + use tock_registers::interfaces::Writeable; + aarch64_cpu::registers::SP_EL0.set(ptr as u64) } } diff --git a/ulib/axlibc/src/strftime.rs b/ulib/axlibc/src/strftime.rs index 59d6199811..ffdc8c5cdb 100644 --- a/ulib/axlibc/src/strftime.rs +++ b/ulib/axlibc/src/strftime.rs @@ -97,6 +97,14 @@ impl Write for CountingWriter { } } +#[inline] +fn c_char_as_u8(c: c_char) -> u8 { + #[allow(clippy::unnecessary_cast)] + { + c as u8 + } +} + unsafe fn strftime_inner( w: W, format: *const c_char, @@ -164,20 +172,20 @@ unsafe fn strftime_inner( ]; while *format != 0 { - if *format as u8 != b'%' { - w!(byte * format as u8); + if c_char_as_u8(*format) != b'%' { + w!(byte c_char_as_u8(*format)); format = format.offset(1); continue; } format = format.offset(1); - if *format as u8 == b'E' || *format as u8 == b'O' { + if c_char_as_u8(*format) == b'E' || c_char_as_u8(*format) == b'O' { // Ignore because these do nothing without locale format = format.offset(1); } - match *format as u8 { + match c_char_as_u8(*format) { b'%' => w!(byte b'%'), b'n' => w!(byte b'\n'), b't' => w!(byte b'\t'), @@ -239,6 +247,7 @@ unsafe fn strftime_inner( /// Convert date and time to a string. #[unsafe(no_mangle)] +#[allow(clippy::unnecessary_cast)] // casting c_char to u8, c_char is either i8 or u8 pub unsafe extern "C" fn strftime( buf: *mut c_char, size: ctypes::size_t,