Skip to content

Commit 27a7124

Browse files
committed
cp, uucore: remove unused returned u64
1 parent 50f8d0b commit 27a7124

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

src/uu/cp/src/platform/linux.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn check_dest_is_fifo(dest: &Path) -> bool {
214214
}
215215

216216
/// Copy the contents of a stream from `source` to `dest`.
217-
fn copy_stream<P>(source: P, dest: P) -> std::io::Result<u64>
217+
fn copy_stream<P>(source: P, dest: P) -> std::io::Result<()>
218218
where
219219
P: AsRef<Path>,
220220
{
@@ -250,10 +250,10 @@ where
250250
dst_file.set_len(0)?;
251251
}
252252

253-
let num_bytes_copied = buf_copy::copy_stream(&mut src_file, &mut dst_file)
253+
buf_copy::copy_stream(&mut src_file, &mut dst_file)
254254
.map_err(|e| std::io::Error::other(format!("{e}")))?;
255255

256-
Ok(num_bytes_copied)
256+
Ok(())
257257
}
258258

259259
/// Copies `source` to `dest` using copy-on-write if possible.

src/uucore/src/lib/features/buf_copy.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ mod tests {
7575
let thread = thread::spawn(move || {
7676
pipe_write.write_all(data).unwrap();
7777
});
78-
let result = copy_stream(&mut pipe_read, &mut dest_file).unwrap();
78+
copy_stream(&mut pipe_read, &mut dest_file).unwrap();
7979
thread.join().unwrap();
80-
assert_eq!(result, data.len() as u64);
8180

8281
// We would have been at the end already, so seek again to the start.
8382
dest_file.seek(SeekFrom::Start(0)).unwrap();
@@ -104,13 +103,12 @@ mod tests {
104103
src_file.sync_all().unwrap();
105104

106105
let mut src_file = File::open(&src_path).unwrap();
107-
let bytes_copied = copy_stream(&mut src_file, &mut dest_file).unwrap();
106+
copy_stream(&mut src_file, &mut dest_file).unwrap();
108107

109108
let mut dest_file = File::open(&dest_path).unwrap();
110109
let mut buf = Vec::new();
111110
dest_file.read_to_end(&mut buf).unwrap();
112111

113-
assert_eq!(bytes_copied as usize, data.len());
114112
assert_eq!(buf, data);
115113
}
116114
}

src/uucore/src/lib/features/buf_copy/linux.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ impl From<rustix::io::Errno> for Error {
4848
/// # Arguments
4949
/// * `source` - `Read` implementor to copy data from.
5050
/// * `dest` - `Write` implementor to copy data to.
51-
///
52-
/// # Returns
53-
///
54-
/// Result of operation and bytes successfully written (as a `u64`) when
55-
/// operation is successful.
56-
pub fn copy_stream<R, S>(src: &mut R, dest: &mut S) -> UResult<u64>
51+
pub fn copy_stream<R, S>(src: &mut R, dest: &mut S) -> UResult<()>
5752
where
5853
R: Read + AsFd + AsRawFd,
5954
S: Write + AsFd + AsRawFd,
@@ -62,19 +57,19 @@ where
6257
// for faster writing. If it works, we're done.
6358
let result = splice_write(src, &dest.as_fd())?;
6459
if !result.1 {
65-
return Ok(result.0);
60+
return Ok(());
6661
}
6762

6863
// If the splice() call failed, fall back on slower writing.
69-
let result = std::io::copy(src, dest)?;
64+
std::io::copy(src, dest)?;
7065

7166
// If the splice() call failed and there has been some data written to
7267
// stdout via while loop above AND there will be second splice() call
7368
// that will succeed, data pushed through splice will be output before
7469
// the data buffered in stdout.lock. Therefore additional explicit flush
7570
// is required here.
7671
dest.flush()?;
77-
Ok(result)
72+
Ok(())
7873
}
7974

8075
/// Write from source `handle` into destination `write_fd` using Linux-specific

src/uucore/src/lib/features/buf_copy/other.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@ use crate::error::UResult;
1717
/// # Arguments
1818
/// * `source` - `Read` implementor to copy data from.
1919
/// * `dest` - `Write` implementor to copy data to.
20-
///
21-
/// # Returns
22-
///
23-
/// Result of operation and bytes successfully written (as a `u64`) when
24-
/// operation is successful.
25-
pub fn copy_stream<R, S>(src: &mut R, dest: &mut S) -> UResult<u64>
20+
pub fn copy_stream<R, S>(src: &mut R, dest: &mut S) -> UResult<()>
2621
where
2722
R: Read,
2823
S: Write,
2924
{
30-
let result = std::io::copy(src, dest)?;
31-
Ok(result)
25+
std::io::copy(src, dest)?;
26+
Ok(())
3227
}

0 commit comments

Comments
 (0)