remove some unnecessary to_owned
This commit is contained in:
parent
5dee646aea
commit
ed24426824
@ -173,9 +173,9 @@ fn write<'tcx>(
|
|||||||
dest: &MPlaceTy<'tcx>,
|
dest: &MPlaceTy<'tcx>,
|
||||||
ecx: &mut MiriInterpCx<'tcx>,
|
ecx: &mut MiriInterpCx<'tcx>,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||||
// We allow writing to stderr even with isolation enabled.
|
// We allow writing to stderr even with isolation enabled.
|
||||||
let result = Write::write(&mut { self }, &bytes);
|
let result = Write::write(&mut { self }, bytes);
|
||||||
// Stdout is buffered, flush to make sure it appears on the
|
// Stdout is buffered, flush to make sure it appears on the
|
||||||
// screen. This is the write() syscall of the interpreted
|
// screen. This is the write() syscall of the interpreted
|
||||||
// program, we want it to correspond to a write() syscall on
|
// program, we want it to correspond to a write() syscall on
|
||||||
@ -204,10 +204,10 @@ fn write<'tcx>(
|
|||||||
dest: &MPlaceTy<'tcx>,
|
dest: &MPlaceTy<'tcx>,
|
||||||
ecx: &mut MiriInterpCx<'tcx>,
|
ecx: &mut MiriInterpCx<'tcx>,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||||
// We allow writing to stderr even with isolation enabled.
|
// We allow writing to stderr even with isolation enabled.
|
||||||
// No need to flush, stderr is not buffered.
|
// No need to flush, stderr is not buffered.
|
||||||
let result = Write::write(&mut { self }, &bytes);
|
let result = Write::write(&mut { self }, bytes);
|
||||||
ecx.return_written_byte_count_or_error(result, dest)
|
ecx.return_written_byte_count_or_error(result, dest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ fn write<'tcx>(
|
|||||||
ecx: &mut MiriInterpCx<'tcx>,
|
ecx: &mut MiriInterpCx<'tcx>,
|
||||||
) -> InterpResult<'tcx> {
|
) -> InterpResult<'tcx> {
|
||||||
assert!(communicate_allowed, "isolation should have prevented even opening a file");
|
assert!(communicate_allowed, "isolation should have prevented even opening a file");
|
||||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||||
let result = (&mut &self.file).write(&bytes);
|
let result = (&mut &self.file).write(bytes);
|
||||||
ecx.return_written_byte_count_or_error(result, dest)
|
ecx.return_written_byte_count_or_error(result, dest)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,11 +102,11 @@ fn pwrite<'tcx>(
|
|||||||
// Correctness of this emulation relies on sequential nature of Miri execution.
|
// Correctness of this emulation relies on sequential nature of Miri execution.
|
||||||
// The closure is used to emulate `try` block, since we "bubble" `io::Error` using `?`.
|
// The closure is used to emulate `try` block, since we "bubble" `io::Error` using `?`.
|
||||||
let file = &mut &self.file;
|
let file = &mut &self.file;
|
||||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||||
let mut f = || {
|
let mut f = || {
|
||||||
let cursor_pos = file.stream_position()?;
|
let cursor_pos = file.stream_position()?;
|
||||||
file.seek(SeekFrom::Start(offset))?;
|
file.seek(SeekFrom::Start(offset))?;
|
||||||
let res = file.write(&bytes);
|
let res = file.write(bytes);
|
||||||
// Attempt to restore cursor position even if the write has failed
|
// Attempt to restore cursor position even if the write has failed
|
||||||
file.seek(SeekFrom::Start(cursor_pos))
|
file.seek(SeekFrom::Start(cursor_pos))
|
||||||
.expect("failed to restore file position, this shouldn't be possible");
|
.expect("failed to restore file position, this shouldn't be possible");
|
||||||
|
@ -245,7 +245,7 @@ fn write<'tcx>(
|
|||||||
}
|
}
|
||||||
// Do full write / partial write based on the space available.
|
// Do full write / partial write based on the space available.
|
||||||
let actual_write_size = len.min(available_space);
|
let actual_write_size = len.min(available_space);
|
||||||
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?.to_owned();
|
let bytes = ecx.read_bytes_ptr_strip_provenance(ptr, Size::from_bytes(len))?;
|
||||||
writebuf.buf.extend(&bytes[..actual_write_size]);
|
writebuf.buf.extend(&bytes[..actual_write_size]);
|
||||||
|
|
||||||
// Need to stop accessing peer_fd so that it can be notified.
|
// Need to stop accessing peer_fd so that it can be notified.
|
||||||
|
Loading…
Reference in New Issue
Block a user