From 3095051512190ae8df8d3cdc04475c632b969260 Mon Sep 17 00:00:00 2001 From: Alfred Gutierrez Date: Thu, 5 Jan 2023 19:03:02 -0800 Subject: [PATCH] Fix clippy warnings (#88) * chore: fix clippy warnings * Update readme with clippy usage. * fix fmt warnings. --- README.md | 16 ++++++++++++++++ src/mp4box/emsg.rs | 2 +- src/mp4box/meta.rs | 5 +---- src/track.rs | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 175da37..82989c0 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,22 @@ With print statement output. cargo test -- --nocapture ``` +#### Run Cargo fmt +Run fmt to catch formatting errors. + +``` +rustup component add rustfmt +cargo fmt --all -- --check +``` + +#### Run Clippy +Run Clippy tests to catch common lints and mistakes. + +``` +rustup component add clippy +cargo clippy --no-deps -- -D warnings +``` + #### Run Benchmark Tests ``` cargo bench diff --git a/src/mp4box/emsg.rs b/src/mp4box/emsg.rs index 1ada228..f68ba3a 100644 --- a/src/mp4box/emsg.rs +++ b/src/mp4box/emsg.rs @@ -26,7 +26,7 @@ impl EmsgBox { 4 + // id Self::time_size(version) + (scheme_id_uri.len() + 1) as u64 + - (value.len() as u64 + 1) as u64 + (value.len() as u64 + 1) } fn time_size(version: u8) -> u64 { diff --git a/src/mp4box/meta.rs b/src/mp4box/meta.rs index 28ead47..49347a6 100644 --- a/src/mp4box/meta.rs +++ b/src/mp4box/meta.rs @@ -17,10 +17,7 @@ impl ReadBox<&mut R> for MetaBox { let (version, _) = read_box_header_ext(reader)?; if version != 0 { - return Err(Error::UnsupportedBoxVersion( - BoxType::UdtaBox, - version as u8, - )); + return Err(Error::UnsupportedBoxVersion(BoxType::UdtaBox, version)); } let mut ilst = None; diff --git a/src/track.rs b/src/track.rs index 24ef4d3..b4178c7 100644 --- a/src/track.rs +++ b/src/track.rs @@ -427,7 +427,7 @@ impl Mp4Track { fn sample_offset(&self, sample_id: u32) -> Result { if !self.trafs.is_empty() { if let Some((traf_idx, _sample_idx)) = self.find_traf_idx_and_sample_idx(sample_id) { - Ok(self.trafs[traf_idx].tfhd.base_data_offset as u64) + Ok(self.trafs[traf_idx].tfhd.base_data_offset) } else { Err(Error::BoxInTrafNotFound(self.track_id(), BoxType::TrafBox)) }