summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Koch <nioko1337@gmail.com>2018-05-28 17:19:42 +0200
committerNicolas Koch <nioko1337@gmail.com>2018-05-28 17:19:42 +0200
commit3b271eb039d22a4b31caed29a2aac0a9ac604902 (patch)
treeb5d17dff44e66c5f4316eba33cd4f9ca19d8a7e4
parentImplement suggestions from the PR (diff)
downloadgrust-3b271eb039d22a4b31caed29a2aac0a9ac604902.tar.gz
grust-3b271eb039d22a4b31caed29a2aac0a9ac604902.tar.bz2
grust-3b271eb039d22a4b31caed29a2aac0a9ac604902.tar.xz
Use FIXME instead of TODO; Move bytes_to_copy calculation inside if
branch
-rw-r--r--src/libstd/sys/unix/fs.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 6624c48cbe..56075c5e8d 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<u64> {
821 let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed); 821 let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed);
822 let mut written = 0u64; 822 let mut written = 0u64;
823 while written < len { 823 while written < len {
824 // TODO should ideally use TryFrom
825 let bytes_to_copy = if len - written > usize::max_value() as u64 {
826 usize::max_value()
827 } else {
828 (len - written) as usize
829 };
830 let copy_result = if has_copy_file_range { 824 let copy_result = if has_copy_file_range {
825 // FIXME: should ideally use TryFrom
826 let bytes_to_copy = if len - written > usize::max_value() as u64 {
827 usize::max_value()
828 } else {
829 (len - written) as usize
830 };
831
831 let copy_result = unsafe { 832 let copy_result = unsafe {
832 // We actually don't have to adjust the offsets, 833 // We actually don't have to adjust the offsets,
833 // because copy_file_range adjusts the file offset automatically 834 // because copy_file_range adjusts the file offset automatically