@@ -621,8 +621,21 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
621
621
this. write_scalar ( Scalar :: from_target_isize ( res, this) , dest) ?;
622
622
return Ok ( ( ) ) ;
623
623
} ;
624
- self . write_byte_helper ( offset, fd, bytes, communicate, dest) ?;
625
- Ok ( ( ) )
624
+
625
+ let result = match offset {
626
+ None => fd. write ( & fd, communicate, & bytes, this) ,
627
+ Some ( offset) => {
628
+ let Ok ( offset) = u64:: try_from ( offset) else {
629
+ let einval = this. eval_libc ( "EINVAL" ) ;
630
+ this. set_last_error ( einval) ?;
631
+ return Ok ( Scalar :: from_target_isize ( -1 , this) ) ;
632
+ } ;
633
+ fd. pwrite ( communicate, & bytes, offset, this)
634
+ }
635
+ } ;
636
+
637
+ let result = result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
638
+ Ok ( Scalar :: from_target_isize ( this. try_unwrap_io_result ( result) ?, this) )
626
639
}
627
640
628
641
/// This function write bytes to the user supplied buffer and write the total number of bytes
@@ -657,34 +670,4 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
657
670
}
658
671
}
659
672
}
660
-
661
- fn write_byte_helper (
662
- & mut self ,
663
- offset : Option < i128 > ,
664
- fd : FileDescriptionRef ,
665
- bytes : Vec < u8 > ,
666
- communicate : bool ,
667
- dest : & MPlaceTy < ' tcx > ,
668
- ) -> InterpResult < ' tcx > {
669
- let this = self . eval_context_mut ( ) ;
670
-
671
- let result = match offset {
672
- None => fd. write ( & fd, communicate, & bytes, this) ,
673
- Some ( offset) => {
674
- let Ok ( offset) = u64:: try_from ( offset) else {
675
- let einval = this. eval_libc ( "EINVAL" ) ;
676
- this. set_last_error ( einval) ?;
677
- let res = Scalar :: from_target_isize ( -1 , this) ;
678
- this. write_scalar ( res, dest) ?;
679
- return Ok ( ( ) ) ;
680
- } ;
681
- fd. pwrite ( communicate, & bytes, offset, this)
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 ( this. try_unwrap_io_result ( result) ?, this) ;
687
- this. write_scalar ( res, dest) ?;
688
- return Ok ( ( ) ) ;
689
- }
690
673
}
0 commit comments