@@ -622,7 +622,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
622
622
this. write_scalar ( Scalar :: from_target_isize ( res, this) , dest) ?;
623
623
return Ok ( ( ) ) ;
624
624
} ;
625
- write_byte_helper ( offset, fd, bytes, communicate, dest, this ) ?;
625
+ self . write_byte_helper ( offset, fd, bytes, communicate, dest) ?;
626
626
Ok ( ( ) )
627
627
}
628
628
@@ -658,32 +658,34 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
658
658
}
659
659
}
660
660
}
661
- }
662
661
663
- fn write_byte_helper < ' tcx > (
664
- offset : Option < i128 > ,
665
- fd : FileDescriptionRef ,
666
- bytes : Vec < u8 > ,
667
- communicate : bool ,
668
- dest : & MPlaceTy < ' tcx > ,
669
- ecx : & mut MiriInterpCx < ' tcx > ,
670
- ) -> InterpResult < ' tcx > {
671
- let result = match offset {
672
- None => fd. write ( & fd, communicate, & bytes, ecx) ,
673
- Some ( offset) => {
674
- let Ok ( offset) = u64:: try_from ( offset) else {
675
- let einval = ecx. eval_libc ( "EINVAL" ) ;
676
- ecx. set_last_error ( einval) ?;
677
- let res = Scalar :: from_target_isize ( -1 , ecx) ;
678
- ecx. write_scalar ( res, dest) ?;
679
- return Ok ( ( ) ) ;
680
- } ;
681
- fd. pwrite ( communicate, & bytes, offset, ecx)
682
- }
683
- } ;
684
- // Write the result to the dest place.
685
- let result = result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
686
- let res = Scalar :: from_target_isize ( ecx. try_unwrap_io_result ( result) ?, ecx) ;
687
- ecx. write_scalar ( res, dest) ?;
688
- return Ok ( ( ) ) ;
662
+ fn write_byte_helper (
663
+ & mut self ,
664
+ offset : Option < i128 > ,
665
+ fd : FileDescriptionRef ,
666
+ bytes : Vec < u8 > ,
667
+ communicate : bool ,
668
+ dest : & MPlaceTy < ' tcx > ,
669
+ ) -> InterpResult < ' tcx > {
670
+ let this = self . eval_context_mut ( ) ;
671
+
672
+ let result = match offset {
673
+ None => fd. write ( & fd, communicate, & bytes, this) ,
674
+ Some ( offset) => {
675
+ let Ok ( offset) = u64:: try_from ( offset) else {
676
+ let einval = this. eval_libc ( "EINVAL" ) ;
677
+ this. set_last_error ( einval) ?;
678
+ let res = Scalar :: from_target_isize ( -1 , this) ;
679
+ this. write_scalar ( res, dest) ?;
680
+ return Ok ( ( ) ) ;
681
+ } ;
682
+ fd. pwrite ( communicate, & bytes, offset, this)
683
+ }
684
+ } ;
685
+ // Write the result to the dest place.
686
+ let result = result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
687
+ let res = Scalar :: from_target_isize ( this. try_unwrap_io_result ( result) ?, this) ;
688
+ this. write_scalar ( res, dest) ?;
689
+ return Ok ( ( ) ) ;
690
+ }
689
691
}
0 commit comments