Skip to content

Commit 322d0c4

Browse files
committed
Move part of the logic to write_byte_helper
1 parent c527499 commit 322d0c4

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
@@ -641,9 +641,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
641641
fd.pwrite(communicate, &bytes, offset, dest, this)
642642
}
643643
};
644-
645-
let result = this.try_unwrap_io_result(result?.map(|c| i64::try_from(c).unwrap()))?;
646-
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
644+
self.write_byte_helper(result, dest)?;
647645
Ok(())
648646
//Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
649647
}
@@ -680,4 +678,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
680678
}
681679
}
682680
}
681+
682+
fn write_byte_helper(
683+
&mut self,
684+
result: InterpResult<'tcx, io::Result<usize>>,
685+
dest: &MPlaceTy<'tcx>,
686+
) -> InterpResult<'tcx> {
687+
let this = self.eval_context_mut();
688+
let result = this.try_unwrap_io_result(result?.map(|c| i64::try_from(c).unwrap()))?;
689+
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
690+
Ok(())
691+
}
683692
}

0 commit comments

Comments
 (0)