Skip to content

Commit 023e746

Browse files
committed
simplify field writing further
1 parent c7e97e2 commit 023e746

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/shims/unix/fs.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
983983
MiriMemoryKind::Runtime.into(),
984984
AllocInit::Uninit,
985985
)?;
986-
let entry: Pointer = entry.into();
987-
let entry_place = &this.ptr_to_mplace(entry, dirent_layout);
986+
let entry = this.ptr_to_mplace(entry.into(), dirent_layout);
988987

989988
// If the host is a Unix system, fill in the inode number with its real value.
990989
// If not, use 0 as a fallback value.
@@ -1000,22 +999,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
1000999
if this.tcx.sess.target.os == "macos" { "d_seekoff" } else { "d_off" };
10011000
this.write_int_fields_named(
10021001
&[(ino_name, ino.into()), (off_name, 0), ("d_reclen", size.into())],
1003-
entry_place,
1002+
&entry,
10041003
)?;
10051004

1006-
if let Some(d_namlen) = this.try_project_field_named(entry_place, "d_namlen")? {
1005+
if let Some(d_namlen) = this.try_project_field_named(&entry, "d_namlen")? {
10071006
this.write_int(name_len.strict_sub(1), &d_namlen)?;
10081007
}
10091008

10101009
let file_type = this.file_type_to_d_type(dir_entry.file_type())?;
1011-
if let Some(d_type) = this.try_project_field_named(entry_place, "d_type")? {
1010+
if let Some(d_type) = this.try_project_field_named(&entry, "d_type")? {
10121011
this.write_int(file_type, &d_type)?;
10131012
}
10141013

1015-
let name_ptr = entry.wrapping_offset(Size::from_bytes(d_name_offset), this);
1014+
let name_ptr = entry.ptr().wrapping_offset(Size::from_bytes(d_name_offset), this);
10161015
this.write_bytes_ptr(name_ptr, name_bytes.iter().copied())?;
10171016

1018-
Some(entry)
1017+
Some(entry.ptr())
10191018
}
10201019
None => {
10211020
// end of stream: return NULL

0 commit comments

Comments
 (0)