Use `size_of` in preludes

This commit is contained in:
Ruihan Li 2025-11-24 19:56:39 +08:00 committed by Tate, Hongliang Tian
parent 76a37310af
commit 2892b8a977
2 changed files with 3 additions and 3 deletions

View File

@ -154,7 +154,7 @@ impl EvdevFile {
/// Processes events and writes them to the writer.
/// Returns the total number of bytes written, or EAGAIN if no events available.
fn process_events(&self, max_events: usize, writer: &mut VmWriter) -> Result<usize> {
const EVENT_SIZE: usize = core::mem::size_of::<EvdevEvent>();
const EVENT_SIZE: usize = size_of::<EvdevEvent>();
let mut consumer = self.consumer.lock();
let mut event_count = 0;
@ -210,7 +210,7 @@ impl InodeIo for EvdevFile {
status_flags: StatusFlags,
) -> Result<usize> {
let requested_bytes = writer.avail();
let max_events = requested_bytes / core::mem::size_of::<EvdevEvent>();
let max_events = requested_bytes / size_of::<EvdevEvent>();
if max_events == 0 {
return Ok(0);

View File

@ -51,7 +51,7 @@ pub(in crate::arch) unsafe fn init_on_ap() {
/// Sends a general inter-processor interrupt (IPI) to the specified CPU.
pub(crate) fn send_ipi(hw_cpu_id: HwCpuId, _guard: &dyn PinCurrentCpu) {
const XLEN: usize = core::mem::size_of::<usize>() * 8;
const XLEN: usize = usize::BITS as usize;
const XLEN_MASK: usize = XLEN - 1;
let hart_id = hw_cpu_id.0 as usize;