Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gblach committed Nov 10, 2024
1 parent e7942eb commit b7876b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/imge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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)?,
};


Expand All @@ -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)
};

Expand All @@ -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"));
}

Expand Down
16 changes: 9 additions & 7 deletions src/mainloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down

0 comments on commit b7876b5

Please sign in to comment.