From c46901d150b91f2d0a59f4484945389660d65ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 30 Nov 2021 16:31:50 +0200 Subject: [PATCH] Fix or silence various new 1.57 clippy warnings --- audio/audiofx/src/audiornnoise/imp.rs | 8 ++--- generic/fmp4/src/fmp4mux/mod.rs | 1 + generic/sodium/tests/decrypter.rs | 2 +- generic/threadshare/src/inputselector/imp.rs | 11 +------ generic/threadshare/src/jitterbuffer/imp.rs | 12 +------ net/reqwest/src/reqwesthttpsrc/imp.rs | 2 -- net/rusoto/src/aws_transcribe_parse/imp.rs | 4 +++ net/rusoto/src/aws_transcriber/packet/mod.rs | 3 ++ net/rusoto/src/s3src/imp.rs | 11 +------ text/json/src/jsongstenc/imp.rs | 16 +--------- text/regex/src/gstregex/imp.rs | 7 +--- .../uriplaylistbin/src/uriplaylistbin/imp.rs | 15 +-------- video/cdg/src/typefind.rs | 4 +-- video/closedcaption/src/mcc_enc/imp.rs | 11 +------ video/closedcaption/src/parser_utils.rs | 2 +- video/closedcaption/src/tttocea608/imp.rs | 6 ++-- video/closedcaption/tests/ccdetect.rs | 32 ++++++------------- video/closedcaption/tests/tttocea608.rs | 2 +- video/webp/src/dec/imp.rs | 10 +----- 19 files changed, 37 insertions(+), 122 deletions(-) diff --git a/audio/audiofx/src/audiornnoise/imp.rs b/audio/audiofx/src/audiornnoise/imp.rs index b58b9952..e2202faf 100644 --- a/audio/audiofx/src/audiornnoise/imp.rs +++ b/audio/audiofx/src/audiornnoise/imp.rs @@ -154,9 +154,9 @@ impl AudioRNNoise { buffer.set_pts(pts); let mut out_map = buffer.map_writable().map_err(|_| gst::FlowError::Error)?; - let mut out_data = out_map.as_mut_slice_of::().unwrap(); + let out_data = out_map.as_mut_slice_of::().unwrap(); - state.process(in_data, &mut out_data); + state.process(in_data, out_data); } let srcpad = element.static_pad("src").unwrap(); @@ -189,9 +189,9 @@ impl AudioRNNoise { buffer.set_pts(pts); let mut out_map = buffer.map_writable().map_err(|_| gst::FlowError::Error)?; - let mut out_data = out_map.as_mut_slice_of::().unwrap(); + let out_data = out_map.as_mut_slice_of::().unwrap(); - state.process(in_data, &mut out_data); + state.process(in_data, out_data); } Ok(GenerateOutputSuccess::Buffer(buffer)) diff --git a/generic/fmp4/src/fmp4mux/mod.rs b/generic/fmp4/src/fmp4mux/mod.rs index eadfb017..45bbc383 100644 --- a/generic/fmp4/src/fmp4mux/mod.rs +++ b/generic/fmp4/src/fmp4mux/mod.rs @@ -90,6 +90,7 @@ pub(crate) struct FragmentHeaderConfiguration<'a> { start_dts: Option, end_pts: gst::ClockTime, end_dts: Option, + #[allow(dead_code)] dts_offset: Option, } diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs index f5f968ec..8fc8a525 100644 --- a/generic/sodium/tests/decrypter.rs +++ b/generic/sodium/tests/decrypter.rs @@ -189,7 +189,7 @@ fn test_pull_range() { // get the seeking capabilities let (seekable, start, stop) = q.result(); - assert_eq!(seekable, true); + assert!(seekable); assert_eq!( start, gst::GenericFormattedValue::Bytes(Some(gst::format::Bytes(0))) diff --git a/generic/threadshare/src/inputselector/imp.rs b/generic/threadshare/src/inputselector/imp.rs index 3dfcca44..cb046b7b 100644 --- a/generic/threadshare/src/inputselector/imp.rs +++ b/generic/threadshare/src/inputselector/imp.rs @@ -350,21 +350,12 @@ impl Default for State { } } -#[derive(Debug)] +#[derive(Debug, Default)] struct Pads { pad_serial: u32, sink_pads: HashMap, } -impl Default for Pads { - fn default() -> Pads { - Pads { - pad_serial: 0, - sink_pads: HashMap::new(), - } - } -} - #[derive(Debug)] pub struct InputSelector { src_pad: PadSrc, diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index cbf854ec..d37134d1 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -967,23 +967,13 @@ impl PadSrcHandler for SrcHandler { } } -#[derive(Debug)] +#[derive(Debug, Default)] struct Stats { num_pushed: u64, num_lost: u64, num_late: u64, } -impl Default for Stats { - fn default() -> Self { - Self { - num_pushed: 0, - num_lost: 0, - num_late: 0, - } - } -} - // Shared state between element, sink and source pad struct State { jbuf: glib::SendUniqueCell, diff --git a/net/reqwest/src/reqwesthttpsrc/imp.rs b/net/reqwest/src/reqwesthttpsrc/imp.rs index 1af019be..02f6ec57 100644 --- a/net/reqwest/src/reqwesthttpsrc/imp.rs +++ b/net/reqwest/src/reqwesthttpsrc/imp.rs @@ -131,7 +131,6 @@ enum State { seekable: bool, position: u64, size: Option, - start: u64, stop: Option, caps: Option, tags: Option, @@ -612,7 +611,6 @@ impl ReqwestHttpSrc { seekable, position, size, - start, stop, caps, tags: if tags.n_tags() > 0 { Some(tags) } else { None }, diff --git a/net/rusoto/src/aws_transcribe_parse/imp.rs b/net/rusoto/src/aws_transcribe_parse/imp.rs index b9be3c74..a22dae17 100644 --- a/net/rusoto/src/aws_transcribe_parse/imp.rs +++ b/net/rusoto/src/aws_transcribe_parse/imp.rs @@ -56,6 +56,7 @@ pub struct TranscribeParse { #[derive(Deserialize, Debug)] #[serde(rename_all = "snake_case")] struct Alternative { + #[allow(dead_code)] confidence: serde_json::Value, content: String, } @@ -73,6 +74,7 @@ struct Item { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] struct Results { + #[allow(dead_code)] transcripts: serde_json::Value, items: Vec, } @@ -80,7 +82,9 @@ struct Results { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] struct Transcript { + #[allow(dead_code)] job_name: String, + #[allow(dead_code)] account_id: String, results: Results, } diff --git a/net/rusoto/src/aws_transcriber/packet/mod.rs b/net/rusoto/src/aws_transcriber/packet/mod.rs index f6a65708..84bda0d6 100644 --- a/net/rusoto/src/aws_transcriber/packet/mod.rs +++ b/net/rusoto/src/aws_transcriber/packet/mod.rs @@ -29,6 +29,7 @@ const CRC: crc::Crc = crc::Crc::::new(&crc::CRC_32_ISO_HDLC); struct Prelude { total_bytes: u32, header_bytes: u32, + #[allow(dead_code)] prelude_crc: u32, } @@ -41,9 +42,11 @@ pub struct Header { #[derive(Debug)] pub struct Packet<'a> { + #[allow(dead_code)] prelude: Prelude, headers: Vec
, pub payload: &'a [u8], + #[allow(dead_code)] msg_crc: u32, } diff --git a/net/rusoto/src/s3src/imp.rs b/net/rusoto/src/s3src/imp.rs index 3c823b8f..61eaebf1 100644 --- a/net/rusoto/src/s3src/imp.rs +++ b/net/rusoto/src/s3src/imp.rs @@ -43,22 +43,13 @@ impl Default for StreamingState { } } +#[derive(Default)] struct Settings { url: Option, access_key: Option, secret_access_key: Option, } -impl Default for Settings { - fn default() -> Self { - Settings { - url: None, - access_key: None, - secret_access_key: None, - } - } -} - #[derive(Default)] pub struct S3Src { settings: Mutex, diff --git a/text/json/src/jsongstenc/imp.rs b/text/json/src/jsongstenc/imp.rs index 9a5bc059..6b5a384d 100644 --- a/text/json/src/jsongstenc/imp.rs +++ b/text/json/src/jsongstenc/imp.rs @@ -47,25 +47,11 @@ static CAT: Lazy = Lazy::new(|| { ) }); -#[derive(Debug)] +#[derive(Debug, Default)] struct State { - start_ts: Option, - end_ts: Option, - current_line: String, format: Option, } -impl Default for State { - fn default() -> Self { - Self { - start_ts: None, - end_ts: None, - current_line: "".to_string(), - format: None, - } - } -} - pub struct JsonGstEnc { srcpad: gst::Pad, sinkpad: gst::Pad, diff --git a/text/regex/src/gstregex/imp.rs b/text/regex/src/gstregex/imp.rs index 857d39d3..f6b47d78 100644 --- a/text/regex/src/gstregex/imp.rs +++ b/text/regex/src/gstregex/imp.rs @@ -44,16 +44,11 @@ struct Command { operation: Operation, } +#[derive(Default)] struct State { commands: Vec, } -impl Default for State { - fn default() -> Self { - Self { commands: vec![] } - } -} - pub struct RegEx { srcpad: gst::Pad, sinkpad: gst::Pad, diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 906cf524..142de04e 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -57,23 +57,13 @@ impl std::error::Error for PlaylistError { } /// Number of different streams currently handled by the element -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Default, Clone, PartialEq)] struct StreamsTopology { audio: u32, video: u32, text: u32, } -impl Default for StreamsTopology { - fn default() -> Self { - Self { - audio: 0, - video: 0, - text: 0, - } - } -} - impl StreamsTopology { fn n_streams(&self) -> u32 { self.audio + self.video + self.text @@ -246,7 +236,6 @@ enum ItemState { stream_selected_msg: Option, concat_sink_pads: Vec<(gst::Element, gst::Pad)>, sender: crossbeam_channel::Sender, - receiver: crossbeam_channel::Receiver, }, /// Buffers are flowing Streaming { @@ -544,7 +533,6 @@ impl Item { ItemState::WaitingForPads { uridecodebin, sender, - receiver, stream_collection_msg, concat_sink_pads, .. @@ -552,7 +540,6 @@ impl Item { inner.state = ItemState::Blocked { uridecodebin: uridecodebin.clone(), sender: sender.clone(), - receiver: receiver.clone(), concat_sink_pads: concat_sink_pads.clone(), stream_collection_msg: stream_collection_msg.copy(), stream_selected_msg: None, diff --git a/video/cdg/src/typefind.rs b/video/cdg/src/typefind.rs index 44f32052..0b40a517 100644 --- a/video/cdg/src/typefind.rs +++ b/video/cdg/src/typefind.rs @@ -78,8 +78,8 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst::Rank::None, Some("cdg"), Some(&Caps::builder("video/x-cdg").build()), - |mut typefind| { - let proba = compute_probability(&mut typefind); + |typefind| { + let proba = compute_probability(typefind); if proba != gst::TypeFindProbability::None { typefind.suggest(proba, &Caps::builder("video/x-cdg").build()); diff --git a/video/closedcaption/src/mcc_enc/imp.rs b/video/closedcaption/src/mcc_enc/imp.rs index 0d59fd6f..eccf7183 100644 --- a/video/closedcaption/src/mcc_enc/imp.rs +++ b/video/closedcaption/src/mcc_enc/imp.rs @@ -52,21 +52,12 @@ impl Default for State { } } -#[derive(Debug, Clone)] +#[derive(Default, Debug, Clone)] struct Settings { uuid: Option, creation_date: Option, } -impl Default for Settings { - fn default() -> Self { - Self { - uuid: None, - creation_date: None, - } - } -} - pub struct MccEnc { srcpad: gst::Pad, sinkpad: gst::Pad, diff --git a/video/closedcaption/src/parser_utils.rs b/video/closedcaption/src/parser_utils.rs index 90bf1493..cdfcc805 100644 --- a/video/closedcaption/src/parser_utils.rs +++ b/video/closedcaption/src/parser_utils.rs @@ -33,7 +33,7 @@ pub fn digits(s: &[u8]) -> IResult<&[u8], u32> { use nom::combinator::map_res; map_res( - map_res(take_while(is_digit), |s: &[u8]| std::str::from_utf8(s)), + map_res(take_while(is_digit), std::str::from_utf8), |s: &str| s.parse::(), )(s) } diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs index e2c16e7f..b579422a 100644 --- a/video/closedcaption/src/tttocea608/imp.rs +++ b/video/closedcaption/src/tttocea608/imp.rs @@ -657,7 +657,7 @@ impl TtToCea608 { if j == 0 { prepend_space = self.open_line( element, - &mut state, + state, settings, chunk, mut_list, @@ -665,7 +665,7 @@ impl TtToCea608 { row as i32, line.carriage_return, ); - } else if self.open_chunk(element, &mut state, chunk, mut_list, col) { + } else if self.open_chunk(element, state, chunk, mut_list, col) { prepend_space = false; col += 1; } @@ -754,7 +754,7 @@ impl TtToCea608 { self.open_line( element, - &mut state, + state, settings, chunk, mut_list, diff --git a/video/closedcaption/tests/ccdetect.rs b/video/closedcaption/tests/ccdetect.rs index c456f797..1f5f56e5 100644 --- a/video/closedcaption/tests/ccdetect.rs +++ b/video/closedcaption/tests/ccdetect.rs @@ -32,20 +32,12 @@ fn init() { }); } +#[derive(Default)] struct NotifyState { cc608_count: u32, cc708_count: u32, } -impl Default for NotifyState { - fn default() -> Self { - NotifyState { - cc608_count: 0, - cc708_count: 0, - } - } -} - macro_rules! assert_push_data { ($h:expr, $state:expr, $data:expr, $ts:expr, $cc608_count:expr, $cc708_count:expr) => { let mut buf = gst::Buffer::from_mut_slice($data); @@ -399,13 +391,10 @@ fn test_gap_events() { assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0); /* pushing gap event within the window changes nothing */ - assert_eq!( - h.push_event(gst::event::Gap::new( - ClockTime::from_nseconds(100_000_000), - ClockTime::from_nseconds(1) - )), - true - ); + assert!(h.push_event(gst::event::Gap::new( + ClockTime::from_nseconds(100_000_000), + ClockTime::from_nseconds(1) + )),); { let state_guard = state.lock().unwrap(); @@ -414,13 +403,10 @@ fn test_gap_events() { } /* pushing gap event outside the window moves cc608 property to false */ - assert_eq!( - h.push_event(gst::event::Gap::new( - ClockTime::from_nseconds(1_000_000_000), - ClockTime::from_nseconds(1) - )), - true - ); + assert!(h.push_event(gst::event::Gap::new( + ClockTime::from_nseconds(1_000_000_000), + ClockTime::from_nseconds(1) + )),); { let state_guard = state.lock().unwrap(); diff --git a/video/closedcaption/tests/tttocea608.rs b/video/closedcaption/tests/tttocea608.rs index 38fad967..231dffb6 100644 --- a/video/closedcaption/tests/tttocea608.rs +++ b/video/closedcaption/tests/tttocea608.rs @@ -142,7 +142,7 @@ fn test_one_timed_buffer_and_eos() { } } - assert_eq!(h.events_in_queue() == 1, true); + assert_eq!(h.events_in_queue(), 1); let event = h.pull_event().unwrap(); assert_eq!(event.type_(), gst::EventType::Eos); diff --git a/video/webp/src/dec/imp.rs b/video/webp/src/dec/imp.rs index 96047379..0b8660a3 100644 --- a/video/webp/src/dec/imp.rs +++ b/video/webp/src/dec/imp.rs @@ -35,20 +35,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[derive(Default)] struct State { buffers: Vec, total_size: usize, } -impl Default for State { - fn default() -> Self { - Self { - buffers: vec![], - total_size: 0, - } - } -} - struct Decoder<'a> { decoder: *mut ffi::WebPAnimDecoder, phantom: PhantomData<&'a [u8]>,