Skip to content

Commit 633430a

Browse files
committed
Replace write_scalar with write_int if possible
1 parent 17fe7f8 commit 633430a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/shims/unix/fd.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
591591
let Ok(offset) = u64::try_from(offset) else {
592592
let einval = this.eval_libc("EINVAL");
593593
this.set_last_error(einval)?;
594-
this.write_scalar(Scalar::from_target_isize(-1, this), dest)?;
594+
this.write_int(-1, dest)?;
595595
return Ok(());
596596
};
597597
fd.pread(communicate, &mut bytes, offset, buf, dest, this)?
@@ -636,8 +636,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
636636
let Ok(offset) = u64::try_from(offset) else {
637637
let einval = this.eval_libc("EINVAL");
638638
this.set_last_error(einval)?;
639-
let res = Scalar::from_target_isize(-1, this);
640-
this.write_scalar(res, dest)?;
639+
this.write_int(-1, dest)?;
641640
return Ok(());
642641
};
643642
fd.pwrite(communicate, &bytes, offset, dest, this)?
@@ -668,12 +667,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
668667
buf,
669668
bytes[..usize::try_from(read_bytes).unwrap()].iter().copied(),
670669
)?;
671-
this.write_scalar(Scalar::from_target_isize(read_bytes, this), dest)?;
670+
this.write_int(read_bytes, dest)?;
672671
return Ok(());
673672
}
674673
Err(e) => {
675674
this.set_last_error_from_io_error(e)?;
676-
this.write_scalar(Scalar::from_target_isize(-1, this), dest)?;
675+
this.write_int(-1, dest)?;
677676
return Ok(());
678677
}
679678
}
@@ -686,7 +685,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
686685
) -> InterpResult<'tcx> {
687686
let this = self.eval_context_mut();
688687
let result = this.try_unwrap_io_result(result?.map(|c| i64::try_from(c).unwrap()))?;
689-
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
688+
this.write_int(result, dest)?;
690689
Ok(())
691690
}
692691
}

0 commit comments

Comments
 (0)