diff options
| author | Nicolas Koch <nioko1337@gmail.com> | 2018-05-16 10:27:14 +0200 |
|---|---|---|
| committer | Nicolas Koch <nioko1337@gmail.com> | 2018-05-16 10:27:14 +0200 |
| commit | f4c2825c8f80eae6ef18eb3fa30464a18a588e0f (patch) | |
| tree | 67d192f5c8606c7baa2111b259a05746efda5a42 /src/libstd/sys | |
| parent | b605923cc83a444f6be52542b891d31b00c87662 (diff) | |
| download | rust-f4c2825c8f80eae6ef18eb3fa30464a18a588e0f.tar.gz rust-f4c2825c8f80eae6ef18eb3fa30464a18a588e0f.zip | |
Adjust len in every iteration
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 0649a147ea3..c9d187f2ff2 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -815,6 +815,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { 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 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> { ptr::null_mut(), writer.as_raw_fd(), ptr::null_mut(), - len as usize, + bytes_to_copy as usize, 0) ) }; |
