From 1e588063540eddd22a3e2edc59fd08abf575fbd1 Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Sun, 12 Mar 2023 01:00:32 +0100 Subject: [PATCH] Fix clippy (again) --- src/codec/packet/packet.rs | 6 +++--- src/codec/packet/side_data.rs | 5 ++++- src/codec/subtitle/mod.rs | 4 ++-- src/format/chapter/chapter.rs | 5 ++++- src/util/dictionary/owned.rs | 2 +- src/util/frame/audio.rs | 8 +++----- src/util/frame/mod.rs | 8 ++++---- src/util/frame/side_data.rs | 5 ++++- src/util/time.rs | 4 ++-- 9 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/codec/packet/packet.rs b/src/codec/packet/packet.rs index 0dd27f5..72a38ea 100644 --- a/src/codec/packet/packet.rs +++ b/src/codec/packet/packet.rs @@ -121,7 +121,7 @@ impl Packet { pub fn pts(&self) -> Option { match self.0.pts { AV_NOPTS_VALUE => None, - pts => Some(pts as i64), + pts => Some(pts), } } @@ -134,7 +134,7 @@ impl Packet { pub fn dts(&self) -> Option { match self.0.dts { AV_NOPTS_VALUE => None, - dts => Some(dts as i64), + dts => Some(dts), } } @@ -150,7 +150,7 @@ impl Packet { #[inline] pub fn duration(&self) -> i64 { - self.0.duration as i64 + self.0.duration } #[inline] diff --git a/src/codec/packet/side_data.rs b/src/codec/packet/side_data.rs index 13234d3..5c2f73d 100644 --- a/src/codec/packet/side_data.rs +++ b/src/codec/packet/side_data.rs @@ -189,6 +189,9 @@ impl<'a> SideData<'a> { } pub fn data(&self) -> &[u8] { - unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) } + #[allow(clippy::unnecessary_cast)] + unsafe { + slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) + } } } diff --git a/src/codec/subtitle/mod.rs b/src/codec/subtitle/mod.rs index f59da2d..8e2e2ec 100644 --- a/src/codec/subtitle/mod.rs +++ b/src/codec/subtitle/mod.rs @@ -73,7 +73,7 @@ impl Subtitle { } pub fn start(&self) -> u32 { - self.0.start_display_time as u32 + self.0.start_display_time } pub fn set_start(&mut self, value: u32) { @@ -81,7 +81,7 @@ impl Subtitle { } pub fn end(&self) -> u32 { - self.0.end_display_time as u32 + self.0.end_display_time } pub fn set_end(&mut self, value: u32) { diff --git a/src/format/chapter/chapter.rs b/src/format/chapter/chapter.rs index 603452b..c446545 100644 --- a/src/format/chapter/chapter.rs +++ b/src/format/chapter/chapter.rs @@ -26,7 +26,10 @@ impl<'a> Chapter<'a> { } pub fn id(&self) -> i64 { - unsafe { (*self.as_ptr()).id as i64 } + #[allow(clippy::unnecessary_cast)] + unsafe { + (*self.as_ptr()).id as i64 + } } pub fn time_base(&self) -> Rational { diff --git a/src/util/dictionary/owned.rs b/src/util/dictionary/owned.rs index 16f2ba0..0891320 100644 --- a/src/util/dictionary/owned.rs +++ b/src/util/dictionary/owned.rs @@ -81,7 +81,7 @@ impl<'a, 'b> FromIterator<&'b (String, String)> for Owned<'a> { fn from_iter>(iterator: T) -> Self { let mut result = Owned::new(); - for &(ref key, ref value) in iterator { + for (key, value) in iterator { result.set(key, value); } diff --git a/src/util/frame/audio.rs b/src/util/frame/audio.rs index 9c9a671..a04dec7 100644 --- a/src/util/frame/audio.rs +++ b/src/util/frame/audio.rs @@ -68,9 +68,7 @@ impl Audio { #[inline] pub fn set_channel_layout(&mut self, value: ChannelLayout) { - unsafe { - (*self.as_mut_ptr()).channel_layout = value.bits() as u64; - } + unsafe { (*self.as_mut_ptr()).channel_layout = value.bits() } } #[inline] @@ -140,7 +138,7 @@ impl Audio { panic!("out of bounds"); } - if !::is_valid(self.format(), self.channels() as u16) { + if !::is_valid(self.format(), self.channels()) { panic!("unsupported type"); } @@ -153,7 +151,7 @@ impl Audio { panic!("out of bounds"); } - if !::is_valid(self.format(), self.channels() as u16) { + if !::is_valid(self.format(), self.channels()) { panic!("unsupported type"); } diff --git a/src/util/frame/mod.rs b/src/util/frame/mod.rs index 0f6a944..0ab7c38 100644 --- a/src/util/frame/mod.rs +++ b/src/util/frame/mod.rs @@ -79,8 +79,8 @@ impl Frame { pub fn packet(&self) -> Packet { unsafe { Packet { - duration: (*self.as_ptr()).pkt_duration as i64, - position: (*self.as_ptr()).pkt_pos as i64, + duration: (*self.as_ptr()).pkt_duration, + position: (*self.as_ptr()).pkt_pos, size: (*self.as_ptr()).pkt_size as usize, #[cfg(not(feature = "ffmpeg_5_0"))] @@ -95,7 +95,7 @@ impl Frame { unsafe { match (*self.as_ptr()).pts { AV_NOPTS_VALUE => None, - pts => Some(pts as i64), + pts => Some(pts), } } } @@ -112,7 +112,7 @@ impl Frame { unsafe { match (*self.as_ptr()).best_effort_timestamp { AV_NOPTS_VALUE => None, - t => Some(t as i64), + t => Some(t), } } } diff --git a/src/util/frame/side_data.rs b/src/util/frame/side_data.rs index ae375a0..6b16e83 100644 --- a/src/util/frame/side_data.rs +++ b/src/util/frame/side_data.rs @@ -213,7 +213,10 @@ impl<'a> SideData<'a> { #[inline] pub fn data(&self) -> &[u8] { - unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) } + #[allow(clippy::unnecessary_cast)] + unsafe { + slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) + } } #[inline] diff --git a/src/util/time.rs b/src/util/time.rs index 373a5ea..9757953 100644 --- a/src/util/time.rs +++ b/src/util/time.rs @@ -3,12 +3,12 @@ use Error; #[inline(always)] pub fn current() -> i64 { - unsafe { av_gettime() as i64 } + unsafe { av_gettime() } } #[inline(always)] pub fn relative() -> i64 { - unsafe { av_gettime_relative() as i64 } + unsafe { av_gettime_relative() } } #[inline(always)]