Skip to content

Commit 162d82f

Browse files
roypatbonzini
authored andcommitted
Drop assert from read/write_volatile in GuestMemory
The comment on the assertion was wrong, as we are not even doing anything unsafe in the first place. Additionally, the `offset` variable is unused by these functions, so the assertion is at best a sanity check that the `try_access` implementation is correct, although I don't particularly see the value of that. Remove the assertion to prevent confusion. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent 5a3a0bf commit 162d82f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/guest_memory.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,7 @@ pub trait GuestMemory {
681681
where
682682
F: ReadVolatile,
683683
{
684-
self.try_access(count, addr, |offset, len, caddr, region| -> Result<usize> {
685-
// Check if something bad happened before doing unsafe things.
686-
assert!(offset <= count);
687-
684+
self.try_access(count, addr, |_, len, caddr, region| -> Result<usize> {
688685
let mut vslice = region.get_slice(caddr, len)?;
689686

690687
src.read_volatile(&mut vslice)
@@ -704,10 +701,7 @@ pub trait GuestMemory {
704701
where
705702
F: WriteVolatile,
706703
{
707-
self.try_access(count, addr, |offset, len, caddr, region| -> Result<usize> {
708-
// Check if something bad happened before doing unsafe things.
709-
assert!(offset <= count);
710-
704+
self.try_access(count, addr, |_, len, caddr, region| -> Result<usize> {
711705
let vslice = region.get_slice(caddr, len)?;
712706

713707
// For a non-RAM region, reading could have side effects, so we

0 commit comments

Comments
 (0)