From fcd751b88eb78452b395c772f208326fca9bb199 Mon Sep 17 00:00:00 2001 From: Josh Stoik Date: Thu, 5 Oct 2023 15:27:03 -0700 Subject: [PATCH] lints --- riprip_core/src/cdio.rs | 2 +- riprip_core/src/disc.rs | 2 +- riprip_core/src/drive.rs | 12 +----------- riprip_core/src/rip/data.rs | 2 +- riprip_core/src/rip/mod.rs | 6 +++--- riprip_core/src/rip/opts.rs | 4 +--- 6 files changed, 8 insertions(+), 20 deletions(-) diff --git a/riprip_core/src/cdio.rs b/riprip_core/src/cdio.rs index 3632915..2bcdb73 100644 --- a/riprip_core/src/cdio.rs +++ b/riprip_core/src/cdio.rs @@ -447,7 +447,7 @@ impl LibcdioInstance { while from < to && 0 < *todo { if killed.killed() { break; } if - ! SHITLIST.with(|q| q.borrow().contains(&from)) && + ! SHITLIST.with_borrow(|q| q.contains(&from)) && self.read_cd(buf, from, false, 0, CD_DATA_SIZE).is_ok() { *todo -= 1; } from += 1; diff --git a/riprip_core/src/disc.rs b/riprip_core/src/disc.rs index 9e5fc1c..1f7b699 100644 --- a/riprip_core/src/disc.rs +++ b/riprip_core/src/disc.rs @@ -321,7 +321,7 @@ impl Disc { } // An extra line break for separation. - let _res = writeln!(&mut handle).and_then(|_| handle.flush()); + let _res = writeln!(&mut handle).and_then(|()| handle.flush()); } Ok(()) diff --git a/riprip_core/src/drive.rs b/riprip_core/src/drive.rs index e10f024..9d76666 100644 --- a/riprip_core/src/drive.rs +++ b/riprip_core/src/drive.rs @@ -204,19 +204,9 @@ impl ReadOffset { /// # Sectors (Absolute). /// /// Return the minimum containing sector amount. - /// - /// TODO: use div_ceil as soon as that is stabilized! pub const fn sectors_abs(self) -> u16 { if self.0 == 0 { return 0; } - - let samples_abs = self.samples_abs(); - - // Floor. - let div = samples_abs.wrapping_div(SAMPLES_PER_SECTOR); - - // Add one if there's a remainder. - if 0 == samples_abs % SAMPLES_PER_SECTOR { div } - else { div + 1 } + self.samples_abs().div_ceil(SAMPLES_PER_SECTOR) } } diff --git a/riprip_core/src/rip/data.rs b/riprip_core/src/rip/data.rs index 7bd7443..67d8d98 100644 --- a/riprip_core/src/rip/data.rs +++ b/riprip_core/src/rip/data.rs @@ -271,7 +271,7 @@ impl RipState { // The first twelve bytes are reserved for some magic header bits // and a CRC32 hash of the toc, track, and data. buf.write_all(MAGIC.as_slice()) - .and_then(|_| buf.write_all(self.quick_hash().to_le_bytes().as_slice())) + .and_then(|()| buf.write_all(self.quick_hash().to_le_bytes().as_slice())) .map_err(|_| RipRipError::StateSave(idx))?; // Everything else is the sample data… diff --git a/riprip_core/src/rip/mod.rs b/riprip_core/src/rip/mod.rs index 7f0e131..833fc6c 100644 --- a/riprip_core/src/rip/mod.rs +++ b/riprip_core/src/rip/mod.rs @@ -158,7 +158,7 @@ impl<'a> Ripper<'a> { state_path(toc, entry.track).map_or(false, |s| s.is_file()) { state.replace(entry.track, &self.opts)?; - if entry.preverify(&mut state, &self.opts)? { + if entry.preverify(&state, &self.opts)? { share.progress.push_msg(happy_track_msg(entry.track), true); progress.increment_n(entry.sectors * u32::from(self.opts.passes())); } @@ -534,7 +534,7 @@ impl RipEntry { /// skip any further work on it. /// /// This will return `true` if verified. - fn verify(&mut self, state: &mut RipState, opts: &RipOptions, progress: &Progless) + fn verify(&mut self, state: &RipState, opts: &RipOptions, progress: &Progless) -> bool { set_progress_title(progress, self.track.number(), "Verifying the rip…"); @@ -567,7 +567,7 @@ impl RipEntry { /// /// If the track is confirmed it will be exported here and now; an error /// will be returned in the unlikely event that fails. - fn preverify(&mut self, state: &mut RipState, opts: &RipOptions) + fn preverify(&mut self, state: &RipState, opts: &RipOptions) -> Result { if ! state.is_new() { (self.ar, self.ctdb) = verify_track(self.track, state); diff --git a/riprip_core/src/rip/opts.rs b/riprip_core/src/rip/opts.rs index 634d1ff..75017cb 100644 --- a/riprip_core/src/rip/opts.rs +++ b/riprip_core/src/rip/opts.rs @@ -381,11 +381,9 @@ impl RipOptions { /// # Cache Sectors. /// /// Return the cache size in sectors, rounded up. - /// - /// TODO: use `div_ceil` once it becomes available. pub const fn cache_sectors(&self) -> u32 { if let Some(c) = self.cache { - (c.get() as u32 * 1024).wrapping_div(CD_DATA_SIZE as u32) + 1 + (c.get() as u32 * 1024).div_ceil(CD_DATA_SIZE as u32) } else { 0 } }