@@ -662,7 +662,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
662
662
let fd = this. read_scalar ( fd_op) ?. to_i32 ( ) ?;
663
663
664
664
if let Some ( file_descriptor) = this. machine . file_handler . handles . remove ( & fd) {
665
- let result = file_descriptor. close ( this. machine . communicate ) ?;
665
+ let result = file_descriptor. close ( this. machine . communicate ( ) ) ?;
666
666
this. try_unwrap_io_result ( result)
667
667
} else {
668
668
this. handle_not_found ( )
@@ -687,6 +687,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
687
687
// We cap the number of read bytes to the largest value that we are able to fit in both the
688
688
// host's and target's `isize`. This saves us from having to handle overflows later.
689
689
let count = count. min ( this. machine_isize_max ( ) as u64 ) . min ( isize:: MAX as u64 ) ;
690
+ let communicate = this. machine . communicate ( ) ;
690
691
691
692
if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
692
693
trace ! ( "read: FD mapped to {:?}" , file_descriptor) ;
@@ -696,9 +697,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
696
697
let mut bytes = vec ! [ 0 ; count as usize ] ;
697
698
// `File::read` never returns a value larger than `count`,
698
699
// so this cannot fail.
699
- let result = file_descriptor
700
- . read ( this. machine . communicate , & mut bytes) ?
701
- . map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
700
+ let result =
701
+ file_descriptor. read ( communicate, & mut bytes) ?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
702
702
703
703
match result {
704
704
Ok ( read_bytes) => {
@@ -733,12 +733,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
733
733
// We cap the number of written bytes to the largest value that we are able to fit in both the
734
734
// host's and target's `isize`. This saves us from having to handle overflows later.
735
735
let count = count. min ( this. machine_isize_max ( ) as u64 ) . min ( isize:: MAX as u64 ) ;
736
+ let communicate = this. machine . communicate ( ) ;
736
737
737
738
if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
738
739
let bytes = this. memory . read_bytes ( buf, Size :: from_bytes ( count) ) ?;
739
- let result = file_descriptor
740
- . write ( this. machine . communicate , & bytes) ?
741
- . map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
740
+ let result =
741
+ file_descriptor. write ( communicate, & bytes) ?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) ;
742
742
this. try_unwrap_io_result ( result)
743
743
} else {
744
744
this. handle_not_found ( )
@@ -771,9 +771,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
771
771
return Ok ( -1 ) ;
772
772
} ;
773
773
774
+ let communicate = this. machine . communicate ( ) ;
774
775
if let Some ( file_descriptor) = this. machine . file_handler . handles . get_mut ( & fd) {
775
776
let result = file_descriptor
776
- . seek ( this . machine . communicate , seek_from) ?
777
+ . seek ( communicate, seek_from) ?
777
778
. map ( |offset| i64:: try_from ( offset) . unwrap ( ) ) ;
778
779
this. try_unwrap_io_result ( result)
779
780
} else {
0 commit comments