media-converter: Apply cargo clippy suggestions.

This commit is contained in:
Arkadiusz Hiler 2022-11-04 14:41:27 +02:00
parent e36a9ba96a
commit eca48bb93f
4 changed files with 18 additions and 22 deletions

View File

@ -300,7 +300,7 @@ static DUMPING_DISABLED: Lazy<bool> = Lazy::new(|| {
Err(_) => { return false; }, Err(_) => { return false; },
Ok(c) => c, Ok(c) => c,
}; };
return v != "0"; v != "0"
}); });
#[derive(Clone)] #[derive(Clone)]
@ -770,7 +770,7 @@ impl ElementImpl for AudioConv {
let new_state = AudioConvState::new().map_err(|err| { let new_state = AudioConvState::new().map_err(|err| {
err.log(); err.log();
return gst::StateChangeError; gst::StateChangeError
})?; })?;
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
@ -887,7 +887,7 @@ impl AudioConv {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
if let Some(state) = &mut *state { if let Some(state) = &mut *state {
let head = match NeedTranscodeHead::new_from_caps(&event_caps.caps()){ let head = match NeedTranscodeHead::new_from_caps(event_caps.caps()){
Ok(h) => h, Ok(h) => h,
Err(e) => { Err(e) => {
gst::error!(CAT, "Invalid WMA caps!"); gst::error!(CAT, "Invalid WMA caps!");

View File

@ -95,7 +95,7 @@ const _FOSSILIZE_COMPRESSION_DEFLATE: u32 = 2;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
NotImplemented, NotImplemented,
IOError(io::Error), IO(io::Error),
CorruptDatabase, CorruptDatabase,
DataTooLarge, DataTooLarge,
InvalidTag, InvalidTag,
@ -105,7 +105,7 @@ pub enum Error {
impl From<io::Error> for Error { impl From<io::Error> for Error {
fn from(e: io::Error) -> Error { fn from(e: io::Error) -> Error {
Error::IOError(e) Error::IO(e)
} }
} }
@ -240,9 +240,7 @@ impl StreamArchive {
let version = magic_and_version[15]; let version = magic_and_version[15];
if magic_and_version[0..12] != FOSSILIZE_MAGIC || if magic_and_version[0..12] != FOSSILIZE_MAGIC || !(FOSSILIZE_MIN_COMPAT_VERSION..=FOSSILIZE_VERSION).contains(&version) {
version < FOSSILIZE_MIN_COMPAT_VERSION ||
version > FOSSILIZE_VERSION {
return Err(Error::CorruptDatabase); return Err(Error::CorruptDatabase);
} }
@ -256,7 +254,7 @@ impl StreamArchive {
if fail.kind() == io::ErrorKind::UnexpectedEof { if fail.kind() == io::ErrorKind::UnexpectedEof {
break; break;
} }
return Err(Error::IOError(fail)); return Err(Error::IO(fail));
} }
let name = &name_and_header[0..PAYLOAD_NAME_LEN_BYTES]; let name = &name_and_header[0..PAYLOAD_NAME_LEN_BYTES];
@ -283,7 +281,7 @@ impl StreamArchive {
Err(e) => { Err(e) => {
/* truncated chunk is not fatal */ /* truncated chunk is not fatal */
if e.kind() != io::ErrorKind::UnexpectedEof { if e.kind() != io::ErrorKind::UnexpectedEof {
return Err(Error::IOError(e)); return Err(Error::IO(e));
} }
}, },
} }
@ -339,7 +337,7 @@ impl StreamArchive {
let to_copy = std::cmp::min(entry.payload_info.full_size as usize - offset as usize, buf.len()); let to_copy = std::cmp::min(entry.payload_info.full_size as usize - offset as usize, buf.len());
self.file.read_exact(&mut buf[0..to_copy]) self.file.read_exact(&mut buf[0..to_copy])
.map_err(Error::IOError)?; .map_err(Error::IO)?;
if entry.payload_info.crc != 0 { if entry.payload_info.crc != 0 {
if let CRCCheck::WithCRC = crc_opt { if let CRCCheck::WithCRC = crc_opt {
@ -434,20 +432,18 @@ impl StreamArchive {
} }
/* rewrites the database, discarding entries listed in 'to_discard' */ /* rewrites the database, discarding entries listed in 'to_discard' */
pub fn discard_entries(&mut self, to_discard: &Vec<(FossilizeTag, FossilizeHash)>) -> Result<(), Error> { pub fn discard_entries(&mut self, to_discard: &[(FossilizeTag, FossilizeHash)]) -> Result<(), Error> {
self.write_pos = self.file.seek(io::SeekFrom::Start(0))?; self.write_pos = self.file.seek(io::SeekFrom::Start(0))?;
for v in self.seen_blobs.iter_mut() { for v in self.seen_blobs.iter_mut() {
v.clear(); v.clear();
} }
let mut magic_and_version = [0 as u8; MAGIC_LEN_BYTES]; let mut magic_and_version = [0_u8; MAGIC_LEN_BYTES];
self.file.read_exact(&mut magic_and_version)?; self.file.read_exact(&mut magic_and_version)?;
let version = magic_and_version[15]; let version = magic_and_version[15];
if magic_and_version[0..12] != FOSSILIZE_MAGIC || if magic_and_version[0..12] != FOSSILIZE_MAGIC || !(FOSSILIZE_MIN_COMPAT_VERSION..=FOSSILIZE_VERSION).contains(&version) {
version < FOSSILIZE_MIN_COMPAT_VERSION ||
version > FOSSILIZE_VERSION {
return Err(Error::CorruptDatabase); return Err(Error::CorruptDatabase);
} }
@ -461,7 +457,7 @@ impl StreamArchive {
if fail.kind() == io::ErrorKind::UnexpectedEof { if fail.kind() == io::ErrorKind::UnexpectedEof {
break; break;
} }
return Err(Error::IOError(fail)); return Err(Error::IO(fail));
} }
let name = &name_and_header[0..PAYLOAD_NAME_LEN_BYTES]; let name = &name_and_header[0..PAYLOAD_NAME_LEN_BYTES];
@ -484,7 +480,7 @@ impl StreamArchive {
Err(e) => { Err(e) => {
/* truncated chunk is not fatal */ /* truncated chunk is not fatal */
if e.kind() != io::ErrorKind::UnexpectedEof { if e.kind() != io::ErrorKind::UnexpectedEof {
return Err(Error::IOError(e)); return Err(Error::IO(e));
} }
}, },
} }
@ -501,7 +497,7 @@ impl StreamArchive {
Err(e) => { Err(e) => {
/* truncated chunk is not fatal */ /* truncated chunk is not fatal */
if e.kind() != io::ErrorKind::UnexpectedEof { if e.kind() != io::ErrorKind::UnexpectedEof {
return Err(Error::IOError(e)); return Err(Error::IO(e));
} }
}, },
} }

View File

@ -97,7 +97,7 @@ macro_rules! box_array {
/* you MUST use this to consistently format the hash bytes into a string */ /* you MUST use this to consistently format the hash bytes into a string */
fn format_hash(hash: u128) -> String { fn format_hash(hash: u128) -> String {
return format!("{:032x}", hash); format!("{:032x}", hash)
} }
/* changing this will invalidate the cache. you MUST clear it. */ /* changing this will invalidate the cache. you MUST clear it. */
@ -144,7 +144,7 @@ fn discarding_disabled() -> bool {
Err(_) => { return false; }, Err(_) => { return false; },
Ok(c) => c, Ok(c) => c,
}; };
return v != "0"; v != "0"
} }
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {

View File

@ -499,7 +499,7 @@ impl ElementImpl for VideoConv {
let new_state = VideoConvState::new().map_err(|err| { let new_state = VideoConvState::new().map_err(|err| {
err.log(); err.log();
return gst::StateChangeError; gst::StateChangeError
})?; })?;
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();