mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
sys_util: write_zeros: Make clippy clean
favor `if let` over `match` for destructing a single value. Signed-off-by: Dylan Reid <dgreid@chromium.org> Change-Id: I0c09d7ffc380e84d7413d6fed338d65a60563a8f Reviewed-on: https://chromium-review.googlesource.com/1510069 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
6a6a36022b
commit
31c79375da
1 changed files with 6 additions and 7 deletions
|
@ -32,14 +32,13 @@ impl<T: PunchHole + Seek + Write> WriteZeroes for T {
|
||||||
fn write_zeroes(&mut self, length: usize) -> io::Result<usize> {
|
fn write_zeroes(&mut self, length: usize) -> io::Result<usize> {
|
||||||
// Try to punch a hole first.
|
// Try to punch a hole first.
|
||||||
let offset = self.seek(SeekFrom::Current(0))?;
|
let offset = self.seek(SeekFrom::Current(0))?;
|
||||||
match self.punch_hole(offset, length as u64) {
|
if let Ok(()) = self.punch_hole(offset, length as u64) {
|
||||||
Ok(()) => {
|
|
||||||
// Advance the seek cursor as if we had done a real write().
|
// Advance the seek cursor as if we had done a real write().
|
||||||
self.seek(SeekFrom::Current(length as i64))?;
|
self.seek(SeekFrom::Current(length as i64))?;
|
||||||
return Ok(length);
|
return Ok(length);
|
||||||
}
|
}
|
||||||
Err(_) => {} // fall back to write()
|
|
||||||
}
|
// fall back to write()
|
||||||
|
|
||||||
// punch_hole() failed; fall back to writing a buffer of zeroes
|
// punch_hole() failed; fall back to writing a buffer of zeroes
|
||||||
// until we have written up to length.
|
// until we have written up to length.
|
||||||
|
|
Loading…
Reference in a new issue