Skip to content

Commit bc850ee

Browse files
committed
tee: remove dummy definition & unused return
1 parent 0366d3c commit bc850ee

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

src/uu/tee/src/tee.rs

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl MultiWriter {
163163
match input.read(&mut buffer) {
164164
Ok(0) => return Ok(()), // end of file
165165
Ok(received) => {
166-
self.write_all(&buffer[..received])?;
166+
self.write_flush(&buffer[..received])?;
167167
}
168168
Err(e) if e.kind() != ErrorKind::Interrupted => return Err(e),
169169
_ => {}
@@ -175,7 +175,7 @@ impl MultiWriter {
175175
match input.read(&mut buffer) {
176176
Ok(0) => return Ok(()), // end of file
177177
Ok(received) => {
178-
self.write_all(&buffer[..received])?;
178+
self.write_flush(&buffer[..received])?;
179179
}
180180
Err(e) if e.kind() != ErrorKind::Interrupted => return Err(e),
181181
_ => {}
@@ -194,33 +194,8 @@ impl MultiWriter {
194194
fn error_occurred(&self) -> bool {
195195
self.ignored_errors != 0
196196
}
197-
}
198-
199-
fn process_error(
200-
mode: Option<OutputErrorMode>,
201-
e: Error,
202-
writer: &NamedWriter,
203-
ignored_errors: &mut usize,
204-
) -> Result<()> {
205-
let ignore_pipe = matches!(
206-
mode,
207-
None | Some(OutputErrorMode::WarnNoPipe) | Some(OutputErrorMode::ExitNoPipe)
208-
);
209-
210-
if ignore_pipe && e.kind() == ErrorKind::BrokenPipe {
211-
return Ok(());
212-
}
213-
let _ = writeln!(stderr(), "{}: {e}", writer.name.maybe_quote());
214-
if let Some(OutputErrorMode::Exit | OutputErrorMode::ExitNoPipe) = mode {
215-
Err(e)
216-
} else {
217-
*ignored_errors += 1;
218-
Ok(())
219-
}
220-
}
221197

222-
impl Write for MultiWriter {
223-
fn write(&mut self, buf: &[u8]) -> Result<usize> {
198+
fn write_flush(&mut self, buf: &[u8]) -> Result<()> {
224199
let mut aborted = None;
225200
let mut errors = 0;
226201
let mode = self.output_error_mode;
@@ -247,13 +222,32 @@ impl Write for MultiWriter {
247222
// `copy`
248223
Err(Error::from(ErrorKind::Other))
249224
} else {
250-
Ok(buf.len())
225+
Ok(())
251226
},
252227
Err,
253228
)
254229
}
230+
}
255231

256-
fn flush(&mut self) -> Result<()> {
232+
fn process_error(
233+
mode: Option<OutputErrorMode>,
234+
e: Error,
235+
writer: &NamedWriter,
236+
ignored_errors: &mut usize,
237+
) -> Result<()> {
238+
let ignore_pipe = matches!(
239+
mode,
240+
None | Some(OutputErrorMode::WarnNoPipe) | Some(OutputErrorMode::ExitNoPipe)
241+
);
242+
243+
if ignore_pipe && e.kind() == ErrorKind::BrokenPipe {
244+
return Ok(());
245+
}
246+
let _ = writeln!(stderr(), "{}: {e}", writer.name.maybe_quote());
247+
if let Some(OutputErrorMode::Exit | OutputErrorMode::ExitNoPipe) = mode {
248+
Err(e)
249+
} else {
250+
*ignored_errors += 1;
257251
Ok(())
258252
}
259253
}

0 commit comments

Comments
 (0)