From aa325ea98d4548b6c08c685adeaf509d4b9a8466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 21 Feb 2019 20:12:09 +0200 Subject: [PATCH] Fix various clippy warnings --- gst-plugin-closedcaption/src/scc_enc.rs | 1 - gst-plugin-flv/src/flvdemux.rs | 4 ++-- gst-plugin-threadshare/src/appsrc.rs | 8 ++++---- gst-plugin-threadshare/src/dataqueue.rs | 6 +++--- gst-plugin-threadshare/src/proxy.rs | 14 +++++++------- gst-plugin-threadshare/src/queue.rs | 6 +++--- gst-plugin-threadshare/src/socket.rs | 4 ++-- gst-plugin-threadshare/src/tcpclientsrc.rs | 12 ++++++------ gst-plugin-threadshare/src/udpsrc.rs | 10 +++++----- gst-plugin-tutorial/src/sinesrc.rs | 6 +++--- 10 files changed, 35 insertions(+), 36 deletions(-) diff --git a/gst-plugin-closedcaption/src/scc_enc.rs b/gst-plugin-closedcaption/src/scc_enc.rs index 888e8580..6f352318 100644 --- a/gst-plugin-closedcaption/src/scc_enc.rs +++ b/gst-plugin-closedcaption/src/scc_enc.rs @@ -213,7 +213,6 @@ impl State { }; // Clear the internal buffer - drop(first_buf); self.internal_buffer.clear(); Ok(Some(buffer)) diff --git a/gst-plugin-flv/src/flvdemux.rs b/gst-plugin-flv/src/flvdemux.rs index 5724e7d2..4c38cf4c 100644 --- a/gst-plugin-flv/src/flvdemux.rs +++ b/gst-plugin-flv/src/flvdemux.rs @@ -891,7 +891,7 @@ impl StreamingState { ); drop(data); adapter.flush((tag_header.data_size - 1) as usize); - return Ok(true); + Ok(true) } Err(nom::Err::Incomplete(_)) => unreachable!(), Ok((_, header)) => { @@ -1060,7 +1060,7 @@ impl StreamingState { ); drop(data); adapter.flush((tag_header.data_size - 1) as usize); - return Ok(None); + Ok(None) } Err(nom::Err::Incomplete(_)) => unreachable!(), Ok((_, header)) => { diff --git a/gst-plugin-threadshare/src/appsrc.rs b/gst-plugin-threadshare/src/appsrc.rs index 816e8e7e..41ff27f4 100644 --- a/gst-plugin-threadshare/src/appsrc.rs +++ b/gst-plugin-threadshare/src/appsrc.rs @@ -36,7 +36,7 @@ use rand; use iocontext::*; -const DEFAULT_CONTEXT: &'static str = ""; +const DEFAULT_CONTEXT: &str = ""; const DEFAULT_CONTEXT_WAIT: u32 = 0; const DEFAULT_CAPS: Option = None; const DEFAULT_MAX_BUFFERS: u32 = 10; @@ -219,11 +219,11 @@ impl AppSrc { let caps = if let Some(ref caps) = state.configured_caps { q.get_filter() .map(|f| f.intersect_with_mode(caps, gst::CapsIntersectMode::First)) - .unwrap_or(caps.clone()) + .unwrap_or_else(|| caps.clone()) } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or(gst::Caps::new_any()) + .unwrap_or_else(|| gst::Caps::new_any()) }; q.set_result(&caps); @@ -565,7 +565,7 @@ impl ObjectSubclass for AppSrc { gst::DebugColorFlags::empty(), "Thread-sharing app source", ), - src_pad: src_pad, + src_pad, state: Mutex::new(State::default()), settings: Mutex::new(Settings::default()), } diff --git a/gst-plugin-threadshare/src/dataqueue.rs b/gst-plugin-threadshare/src/dataqueue.rs index f1222a21..c0286dd6 100644 --- a/gst-plugin-threadshare/src/dataqueue.rs +++ b/gst-plugin-threadshare/src/dataqueue.rs @@ -106,9 +106,9 @@ impl DataQueue { queue: VecDeque::new(), cur_size_buffers: 0, cur_size_bytes: 0, - max_size_buffers: max_size_buffers, - max_size_bytes: max_size_bytes, - max_size_time: max_size_time, + max_size_buffers, + max_size_bytes, + max_size_time, current_task: None, shutdown_receiver: None, }))) diff --git a/gst-plugin-threadshare/src/proxy.rs b/gst-plugin-threadshare/src/proxy.rs index 1d4ca9c3..0794321b 100644 --- a/gst-plugin-threadshare/src/proxy.rs +++ b/gst-plugin-threadshare/src/proxy.rs @@ -43,12 +43,12 @@ lazy_static! { Mutex::new(HashMap::new()); } -const DEFAULT_PROXY_CONTEXT: &'static str = ""; +const DEFAULT_PROXY_CONTEXT: &str = ""; const DEFAULT_MAX_SIZE_BUFFERS: u32 = 200; const DEFAULT_MAX_SIZE_BYTES: u32 = 1024 * 1024; const DEFAULT_MAX_SIZE_TIME: u64 = gst::SECOND_VAL; -const DEFAULT_CONTEXT: &'static str = ""; +const DEFAULT_CONTEXT: &str = ""; const DEFAULT_CONTEXT_WAIT: u32 = 0; #[derive(Debug, Clone)] @@ -395,7 +395,7 @@ impl ProxySink { let res = if let Some((ref mut task, _, ref mut items)) = *pending_queue { - if let &Some(ref queue) = queue { + if let Some(ref queue) = queue { let mut failed_item = None; while let Some(item) = items.pop_front() { if let Err(item) = queue.push(item) { @@ -695,7 +695,7 @@ impl ObjectSubclass for ProxySink { gst::DebugColorFlags::empty(), "Thread-sharing proxy sink", ), - sink_pad: sink_pad, + sink_pad, state: Mutex::new(StateSink::default()), settings: Mutex::new(SettingsSink::default()), } @@ -854,11 +854,11 @@ impl ProxySrc { let caps = if let Some(ref caps) = self.src_pad.get_current_caps() { q.get_filter() .map(|f| f.intersect_with_mode(caps, gst::CapsIntersectMode::First)) - .unwrap_or(caps.clone()) + .unwrap_or_else(|| caps.clone()) } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or(gst::Caps::new_any()) + .unwrap_or_else(|| gst::Caps::new_any()) }; q.set_result(&caps); @@ -1223,7 +1223,7 @@ impl ObjectSubclass for ProxySrc { gst::DebugColorFlags::empty(), "Thread-sharing proxy source", ), - src_pad: src_pad, + src_pad, state: Mutex::new(StateSrc::default()), settings: Mutex::new(SettingsSrc::default()), } diff --git a/gst-plugin-threadshare/src/queue.rs b/gst-plugin-threadshare/src/queue.rs index d4ec7709..78fc87f4 100644 --- a/gst-plugin-threadshare/src/queue.rs +++ b/gst-plugin-threadshare/src/queue.rs @@ -40,7 +40,7 @@ use iocontext::*; const DEFAULT_MAX_SIZE_BUFFERS: u32 = 200; const DEFAULT_MAX_SIZE_BYTES: u32 = 1024 * 1024; const DEFAULT_MAX_SIZE_TIME: u64 = gst::SECOND_VAL; -const DEFAULT_CONTEXT: &'static str = ""; +const DEFAULT_CONTEXT: &str = ""; const DEFAULT_CONTEXT_WAIT: u32 = 0; #[derive(Debug, Clone)] @@ -846,8 +846,8 @@ impl ObjectSubclass for Queue { gst::DebugColorFlags::empty(), "Thread-sharing queue", ), - sink_pad: sink_pad, - src_pad: src_pad, + sink_pad, + src_pad, state: Mutex::new(State::default()), settings: Mutex::new(Settings::default()), } diff --git a/gst-plugin-threadshare/src/socket.rs b/gst-plugin-threadshare/src/socket.rs index 9a336f1a..01d5bd23 100644 --- a/gst-plugin-threadshare/src/socket.rs +++ b/gst-plugin-threadshare/src/socket.rs @@ -70,8 +70,8 @@ impl Socket { Socket(Arc::new(Mutex::new(SocketInner:: { element: element.clone(), state: SocketState::Unscheduled, - reader: reader, - buffer_pool: buffer_pool, + reader, + buffer_pool, current_task: None, shutdown_receiver: None, clock: None, diff --git a/gst-plugin-threadshare/src/tcpclientsrc.rs b/gst-plugin-threadshare/src/tcpclientsrc.rs index 916ac1bf..11841f1a 100644 --- a/gst-plugin-threadshare/src/tcpclientsrc.rs +++ b/gst-plugin-threadshare/src/tcpclientsrc.rs @@ -41,11 +41,11 @@ use rand; use iocontext::*; use socket::*; -const DEFAULT_ADDRESS: Option<&'static str> = Some("127.0.0.1"); +const DEFAULT_ADDRESS: Option<&str> = Some("127.0.0.1"); const DEFAULT_PORT: u32 = 5000; const DEFAULT_CAPS: Option = None; const DEFAULT_CHUNK_SIZE: u32 = 4096; -const DEFAULT_CONTEXT: &'static str = ""; +const DEFAULT_CONTEXT: &str = ""; const DEFAULT_CONTEXT_WAIT: u32 = 0; #[derive(Debug, Clone)] @@ -142,7 +142,7 @@ pub struct TcpClientReader { impl TcpClientReader { pub fn new(connect_future: net::tcp::ConnectFuture) -> Self { Self { - connect_future: connect_future, + connect_future, socket: None, } } @@ -256,11 +256,11 @@ impl TcpClientSrc { let caps = if let Some(ref caps) = state.configured_caps { q.get_filter() .map(|f| f.intersect_with_mode(caps, gst::CapsIntersectMode::First)) - .unwrap_or(caps.clone()) + .unwrap_or_else(|| caps.clone()) } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or(gst::Caps::new_any()) + .unwrap_or_else(|| gst::Caps::new_any()) }; q.set_result(&caps); @@ -618,7 +618,7 @@ impl ObjectSubclass for TcpClientSrc { gst::DebugColorFlags::empty(), "Thread-sharing TCP Client source", ), - src_pad: src_pad, + src_pad, state: Mutex::new(State::default()), settings: Mutex::new(Settings::default()), } diff --git a/gst-plugin-threadshare/src/udpsrc.rs b/gst-plugin-threadshare/src/udpsrc.rs index 46f2ec8c..cddf293e 100644 --- a/gst-plugin-threadshare/src/udpsrc.rs +++ b/gst-plugin-threadshare/src/udpsrc.rs @@ -52,14 +52,14 @@ use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket} use iocontext::*; use socket::*; -const DEFAULT_ADDRESS: Option<&'static str> = Some("127.0.0.1"); +const DEFAULT_ADDRESS: Option<&str> = Some("127.0.0.1"); const DEFAULT_PORT: u32 = 5000; const DEFAULT_REUSE: bool = true; const DEFAULT_CAPS: Option = None; const DEFAULT_MTU: u32 = 1500; const DEFAULT_SOCKET: Option = None; const DEFAULT_USED_SOCKET: Option = None; -const DEFAULT_CONTEXT: &'static str = ""; +const DEFAULT_CONTEXT: &str = ""; const DEFAULT_CONTEXT_WAIT: u32 = 0; // Send/Sync struct for passing around a gio::Socket @@ -378,11 +378,11 @@ impl UdpSrc { let caps = if let Some(ref caps) = state.configured_caps { q.get_filter() .map(|f| f.intersect_with_mode(caps, gst::CapsIntersectMode::First)) - .unwrap_or(caps.clone()) + .unwrap_or_else(|| caps.clone()) } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or(gst::Caps::new_any()) + .unwrap_or_else(|| gst::Caps::new_any()) }; q.set_result(&caps); @@ -927,7 +927,7 @@ impl ObjectSubclass for UdpSrc { gst::DebugColorFlags::empty(), "Thread-sharing UDP source", ), - src_pad: src_pad, + src_pad, state: Mutex::new(State::default()), settings: Mutex::new(Settings::default()), } diff --git a/gst-plugin-tutorial/src/sinesrc.rs b/gst-plugin-tutorial/src/sinesrc.rs index 94db3f75..b08d8dc0 100644 --- a/gst-plugin-tutorial/src/sinesrc.rs +++ b/gst-plugin-tutorial/src/sinesrc.rs @@ -813,9 +813,9 @@ impl BaseSrcImpl for SineSrc { *state = State { info: state.info.clone(), - sample_offset: sample_offset, - sample_stop: sample_stop, - accumulator: accumulator, + sample_offset, + sample_stop, + accumulator, }; true