Use FIXME instead of TODO; Move bytes_to_copy calculation inside if

branch
This commit is contained in:
Nicolas Koch
2018-05-28 17:19:42 +02:00
parent 3f392abdfb
commit 3b271eb039

View File

@@ -821,13 +821,14 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed); let has_copy_file_range = HAS_COPY_FILE_RANGE.load(Ordering::Relaxed);
let mut written = 0u64; let mut written = 0u64;
while written < len { while written < len {
// TODO should ideally use TryFrom 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 { let bytes_to_copy = if len - written > usize::max_value() as u64 {
usize::max_value() usize::max_value()
} else { } else {
(len - written) as usize (len - written) as usize
}; };
let copy_result = if has_copy_file_range {
let copy_result = unsafe { let copy_result = unsafe {
// We actually don't have to adjust the offsets, // We actually don't have to adjust the offsets,
// because copy_file_range adjusts the file offset automatically // because copy_file_range adjusts the file offset automatically