Skip to content

Commit 113c9cd

Browse files
oech3cakebaker
authored andcommitted
head: deduplicate flush() workaround
1 parent e3b680d commit 113c9cd

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/uu/head/src/head.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,9 @@ fn wrap_in_stdout_error(err: io::Error) -> io::Error {
168168

169169
// zero-copy fast-path
170170
#[cfg(any(target_os = "linux", target_os = "android"))]
171-
fn print_n_bytes(input: impl Read + AsFd, n: u64) -> io::Result<u64> {
172-
let mut out = io::stdout();
173-
let res = uucore::pipes::send_n_bytes(input, &out, n).map_err(wrap_in_stdout_error);
174-
// flush prevents ignoring I/O error
175-
out.flush().map_err(wrap_in_stdout_error)?;
176-
res
171+
fn print_n_bytes(input: impl AsFd, n: u64) -> io::Result<u64> {
172+
let out = io::stdout();
173+
uucore::pipes::send_n_bytes(input, &out, n).map_err(wrap_in_stdout_error)
177174
}
178175

179176
#[cfg(not(any(target_os = "linux", target_os = "android")))]

0 commit comments

Comments
 (0)