Skip to content

Commit

Permalink
Remove cast in common/src/load_kernel.rs:412
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed Feb 2, 2025
1 parent 7323271 commit 42f095f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions common/src/load_kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ where
let end_inclusive_copy_address = cmp::min(end_inclusive_addr, page_end_inclusive);

// These are the offsets into the frame we want to copy from.
let start_offset_in_frame = (start_copy_address - page_start) as usize;
let end_inclusive_offset_in_frame = (end_inclusive_copy_address - page_start) as usize;
let start_offset_in_frame = start_copy_address - page_start;
let end_inclusive_offset_in_frame = end_inclusive_copy_address - page_start;

// Calculate how many bytes we want to copy from this frame.
let copy_len = end_inclusive_offset_in_frame - start_offset_in_frame + 1;

// Calculate the physical addresses.
let start_phys_addr = phys_addr.start_address() + start_offset_in_frame as u64;
let start_phys_addr = phys_addr.start_address() + start_offset_in_frame;

// These are the offsets from the start address. These correspond
// to the destination indices in `buf`.
Expand All @@ -429,11 +429,11 @@ where
// SAFETY: We know that this memory is valid because we got it
// as a result from a translation. There are not other
// references to it.
&mut *core::ptr::slice_from_raw_parts_mut(dest_ptr, copy_len)
&mut *core::ptr::slice_from_raw_parts_mut(dest_ptr, copy_len as usize)
};

// Calculate the destination pointer.
let src = &buf[start_offset_in_buf..][..copy_len];
let src = &buf[start_offset_in_buf..][..copy_len as usize];

// Do the actual copy.
dest.copy_from_slice(src);
Expand Down

0 comments on commit 42f095f

Please sign in to comment.