remove some now-unnecessary parameters from check_bytes

This commit is contained in:
Ralf Jung 2022-07-26 21:49:34 -04:00
parent da13935ecc
commit 2e52fe01cf
3 changed files with 7 additions and 31 deletions

View file

@ -962,15 +962,10 @@ impl<'tcx, 'a, Prov: Provenance, Extra> AllocRef<'a, 'tcx, Prov, Extra> {
} }
/// `range` is relative to this allocation reference, not the base of the allocation. /// `range` is relative to this allocation reference, not the base of the allocation.
pub fn check_bytes( pub fn check_bytes(&self, range: AllocRange) -> InterpResult<'tcx> {
&self,
range: AllocRange,
allow_uninit: bool,
allow_ptr: bool,
) -> InterpResult<'tcx> {
Ok(self Ok(self
.alloc .alloc
.check_bytes(&self.tcx, self.range.subrange(range), allow_uninit, allow_ptr) .check_bytes(&self.tcx, self.range.subrange(range))
.map_err(|e| e.to_interp_error(self.alloc_id))?) .map_err(|e| e.to_interp_error(self.alloc_id))?)
} }

View file

@ -893,11 +893,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
// We also accept uninit, for consistency with the slow path. // We also accept uninit, for consistency with the slow path.
let alloc = self.ecx.get_ptr_alloc(mplace.ptr, size, mplace.align)?.expect("we already excluded size 0"); let alloc = self.ecx.get_ptr_alloc(mplace.ptr, size, mplace.align)?.expect("we already excluded size 0");
match alloc.check_bytes( match alloc.check_bytes(alloc_range(Size::ZERO, size)) {
alloc_range(Size::ZERO, size),
/*allow_uninit*/ false,
/*allow_ptr*/ false,
) {
// In the happy case, we needn't check anything else. // In the happy case, we needn't check anything else.
Ok(()) => {} Ok(()) => {}
// Some error happened, try to provide a more detailed description. // Some error happened, try to provide a more detailed description.

View file

@ -415,25 +415,10 @@ impl<Prov: Provenance, Extra> Allocation<Prov, Extra> {
/// Reading and writing. /// Reading and writing.
impl<Prov: Provenance, Extra> Allocation<Prov, Extra> { impl<Prov: Provenance, Extra> Allocation<Prov, Extra> {
/// Validates that `ptr.offset` and `ptr.offset + size` do not point to the middle of a /// Validates that this memory range is initiailized and contains no relocations.
/// relocation. If `allow_uninit`/`allow_ptr` is `false`, also enforces that the memory in the pub fn check_bytes(&self, cx: &impl HasDataLayout, range: AllocRange) -> AllocResult {
/// given range contains no uninitialized bytes/relocations. // This implicitly does all the checking we are asking for.
pub fn check_bytes( self.get_bytes(cx, range)?;
&self,
cx: &impl HasDataLayout,
range: AllocRange,
allow_uninit: bool,
allow_ptr: bool,
) -> AllocResult {
// Check bounds and relocations on the edges.
self.get_bytes_with_uninit_and_ptr(cx, range)?;
// Check uninit and ptr.
if !allow_uninit {
self.check_init(range)?;
}
if !allow_ptr {
self.check_relocations(cx, range)?;
}
Ok(()) Ok(())
} }