Skip to content

Commit 82b7fac

Browse files
committed
Replace write_scalar with write_int if possible
1 parent 517e22f commit 82b7fac

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
@@ -590,7 +590,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
590590
let Ok(offset) = u64::try_from(offset) else {
591591
let einval = this.eval_libc("EINVAL");
592592
this.set_last_error(einval)?;
593-
this.write_scalar(Scalar::from_target_isize(-1, this), dest)?;
593+
this.write_int(-1, dest)?;
594594
return Ok(());
595595
};
596596
fd.pread(communicate, &mut bytes, offset, buf, dest, this)?
@@ -635,8 +635,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
635635
let Ok(offset) = u64::try_from(offset) else {
636636
let einval = this.eval_libc("EINVAL");
637637
this.set_last_error(einval)?;
638-
let res = Scalar::from_target_isize(-1, this);
639-
this.write_scalar(res, dest)?;
638+
this.write_int(-1, dest)?;
640639
return Ok(());
641640
};
642641
fd.pwrite(communicate, &bytes, offset, dest, this)?
@@ -667,12 +666,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
667666
buf,
668667
bytes[..usize::try_from(read_bytes).unwrap()].iter().copied(),
669668
)?;
670-
this.write_scalar(Scalar::from_target_isize(read_bytes, this), dest)?;
669+
this.write_int(read_bytes, dest)?;
671670
return Ok(());
672671
}
673672
Err(e) => {
674673
this.set_last_error_from_io_error(e)?;
675-
this.write_scalar(Scalar::from_target_isize(-1, this), dest)?;
674+
this.write_int(-1, dest)?;
676675
return Ok(());
677676
}
678677
}
@@ -685,7 +684,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
685684
) -> InterpResult<'tcx> {
686685
let this = self.eval_context_mut();
687686
let result = this.try_unwrap_io_result(result?.map(|c| i64::try_from(c).unwrap()))?;
688-
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
687+
this.write_int(result, dest)?;
689688
Ok(())
690689
}
691690
}

0 commit comments

Comments
 (0)