From 3b271eb039d22a4b31caed29a2aac0a9ac604902 Mon Sep 17 00:00:00 2001 From: Nicolas Koch Date: Mon, 28 May 2018 17:19:42 +0200 Subject: Use FIXME instead of TODO; Move bytes_to_copy calculation inside if branch --- src/libstd/sys/unix/fs.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 6624c48cbe0..56075c5e8d0 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -821,13 +821,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed); let mut written = 0u64; while written < len { - // TODO should ideally use TryFrom - let bytes_to_copy = if len - written > usize::max_value() as u64 { - usize::max_value() - } else { - (len - written) as usize - }; let copy_result = if has_copy_file_range { + // FIXME: should ideally use TryFrom + let bytes_to_copy = if len - written > usize::max_value() as u64 { + usize::max_value() + } else { + (len - written) as usize + }; + let copy_result = unsafe { // We actually don't have to adjust the offsets, // because copy_file_range adjusts the file offset automatically -- cgit 1.4.1-3-g733a5