Skip to content

Commit 043843c

Browse files
committed
Move part of the logic to write_byte_helper
1 parent 4f3c1bb commit 043843c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/shims/unix/fd.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
640640
fd.pwrite(communicate, &bytes, offset, dest, this)
641641
}
642642
};
643-
644-
let result = this.try_unwrap_io_result(result?.map(|c| i64::try_from(c).unwrap()))?;
645-
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
643+
self.write_byte_helper(result, dest)?;
646644
Ok(())
647645
//Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
648646
}
@@ -679,4 +677,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
679677
}
680678
}
681679
}
680+
681+
fn write_byte_helper(
682+
&mut self,
683+
result: InterpResult<'tcx, io::Result<usize>>,
684+
dest: &MPlaceTy<'tcx>,
685+
) -> InterpResult<'tcx> {
686+
let this = self.eval_context_mut();
687+
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)?;
689+
Ok(())
690+
}
682691
}

0 commit comments

Comments
 (0)