]> git.lizzy.rs Git - rust.git/commitdiff
Adjust len in every iteration
authorNicolas Koch <nioko1337@gmail.com>
Wed, 16 May 2018 08:27:14 +0000 (10:27 +0200)
committerNicolas Koch <nioko1337@gmail.com>
Wed, 16 May 2018 08:27:14 +0000 (10:27 +0200)
src/libstd/sys/unix/fs.rs

index 0649a147ea3c1ace24e3d7c5e183c3a6884cc3f8..c9d187f2ff277f8b5f7868d81ce7261e59c70da9 100644 (file)
@@ -815,6 +815,7 @@ unsafe fn copy_file_range(
 
     let mut written = 0u64;
     while written < len {
+        let bytes_to_copy = len - written;
         let copy_result = unsafe {
             // We actually don't have to adjust the offsets,
             // because copy_file_range adjusts the file offset automatically
@@ -822,7 +823,7 @@ unsafe fn copy_file_range(
                                 ptr::null_mut(),
                                 writer.as_raw_fd(),
                                 ptr::null_mut(),
-                                len as usize,
+                                bytes_to_copy as usize,
                                 0)
                 )
         };