From b7876b5c11e78831da40a37bd8ed8bdd960e8e03 Mon Sep 17 00:00:00 2001 From: Grzegorz Blach Date: Sun, 10 Nov 2024 17:29:06 +0100 Subject: [PATCH] Fix clippy warnings --- src/imge.rs | 14 +++++++------- src/mainloop.rs | 16 +++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/imge.rs b/src/imge.rs index 53eb623..fdb1334 100644 --- a/src/imge.rs +++ b/src/imge.rs @@ -166,8 +166,8 @@ pub fn copy(src: &Path, dest: &Path, from_drive: bool, image_mime_type: Mime, .custom_flags(libc::O_DSYNC).open(&dest.path)?; let (a, ae) = match from_drive { - false => libarchive_open_for_reading(&src)?, - true => libarchive_open_for_writing(&dest, image_mime_type.clone())?, + false => libarchive_open_for_reading(src)?, + true => libarchive_open_for_writing(dest, image_mime_type.clone())?, }; let mut buffer = [0; BLOCK_SIZE]; @@ -218,8 +218,8 @@ pub fn verify(src: &Path, dest: &Path, from_drive: bool, .custom_flags(libc::O_DIRECT).open(&dest.path)?; let (a, _ae) = match from_drive { - false => libarchive_open_for_reading(&src)?, - true => libarchive_open_for_reading(&dest)?, + false => libarchive_open_for_reading(src)?, + true => libarchive_open_for_reading(dest)?, }; @@ -228,7 +228,7 @@ pub fn verify(src: &Path, dest: &Path, from_drive: bool, let destbuffer_ptr = unsafe { alloc(Layout::from_size_align(BLOCK_SIZE, BLOCK_SIZE).unwrap()) }; - let mut destbuffer = unsafe { + let destbuffer = unsafe { std::slice::from_raw_parts_mut(destbuffer_ptr, BLOCK_SIZE) }; @@ -246,13 +246,13 @@ pub fn verify(src: &Path, dest: &Path, from_drive: bool, } match from_drive { - false => destfile.read(&mut destbuffer)? as isize, + false => destfile.read(destbuffer)? as isize, true => unsafe { archive_read_data(a, destbuffer_ptr as *mut c_void, BLOCK_SIZE) }, }; - if &srcbuffer[..len as usize] != &destbuffer[..len as usize] { + if srcbuffer[..len as usize] != destbuffer[..len as usize] { return Err(io::Error::other("Verification failed")); } diff --git a/src/mainloop.rs b/src/mainloop.rs index fd37bf1..d82d2a2 100644 --- a/src/mainloop.rs +++ b/src/mainloop.rs @@ -534,9 +534,10 @@ impl Mainloop { let image_mime_type = self.image_mime_type.clone(); let error = self.error.clone(); - let mut progress = imge::Progress::default(); - progress.size = src.size.unwrap_or_default(); - let progress = Arc::new(Mutex::new(progress)); + let progress = Arc::new(Mutex::new(imge::Progress { + size: src.size.unwrap_or_default(), + ..Default::default() + })); self.progress = Some(progress.clone()); self.modal = Modal::Copying; @@ -556,10 +557,11 @@ impl Mainloop { let error = self.error.clone(); let copying_progress = self.progress.as_ref().unwrap().lock().unwrap(); - let mut progress = imge::Progress::default(); - progress.size = src.size.unwrap_or(copying_progress.done); - progress.secs = copying_progress.secs; - let progress = Arc::new(Mutex::new(progress)); + let progress = Arc::new(Mutex::new(imge::Progress { + size: src.size.unwrap_or(copying_progress.done), + secs: copying_progress.secs, + ..Default::default() + })); drop(copying_progress); self.progress = Some(progress.clone());