From b5b7e91c497701075b2352e1aa8cca823fefcb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 4 Jul 2019 18:30:26 +0300 Subject: [PATCH] Fix various clippy warnings --- gst-plugin-flv/src/flvdemux.rs | 23 ++++++++++----------- gst-plugin-s3/src/s3sink.rs | 24 +++++++++++----------- gst-plugin-s3/src/s3src.rs | 11 +++++----- gst-plugin-s3/src/s3url.rs | 8 ++++---- gst-plugin-sodium/src/decrypter.rs | 2 +- gst-plugin-sodium/src/encrypter.rs | 2 -- gst-plugin-threadshare/src/appsrc.rs | 2 +- gst-plugin-threadshare/src/proxy.rs | 2 +- gst-plugin-threadshare/src/tcpclientsrc.rs | 12 ++++------- gst-plugin-threadshare/src/udpsrc.rs | 14 +++++-------- gst-plugin-version-helper/src/lib.rs | 2 +- 11 files changed, 45 insertions(+), 57 deletions(-) diff --git a/gst-plugin-flv/src/flvdemux.rs b/gst-plugin-flv/src/flvdemux.rs index a86c421c..b06843a0 100644 --- a/gst-plugin-flv/src/flvdemux.rs +++ b/gst-plugin-flv/src/flvdemux.rs @@ -305,18 +305,17 @@ impl FlvDemux { } // TODO: pull mode - if false - && query.has_scheduling_mode_with_flags( - gst::PadMode::Pull, - gst::SchedulingFlags::SEEKABLE, - ) - { - gst_debug!(CAT, obj: pad, "Activating in Pull mode"); - gst::PadMode::Pull - } else { - gst_debug!(CAT, obj: pad, "Activating in Push mode"); - gst::PadMode::Push - } + // if query.has_scheduling_mode_with_flags( + // gst::PadMode::Pull, + // gst::SchedulingFlags::SEEKABLE, + // ) + // { + // gst_debug!(CAT, obj: pad, "Activating in Pull mode"); + // gst::PadMode::Pull + // } else { + gst_debug!(CAT, obj: pad, "Activating in Push mode"); + gst::PadMode::Push + // } }; pad.activate_mode(mode, true)?; diff --git a/gst-plugin-s3/src/s3sink.rs b/gst-plugin-s3/src/s3sink.rs index 7770c3d5..b173d8cc 100644 --- a/gst-plugin-s3/src/s3sink.rs +++ b/gst-plugin-s3/src/s3sink.rs @@ -290,10 +290,9 @@ impl S3Sink { s3utils::wait(&self.canceller, &self.runtime, complete_req_future) .map_err(|err| { - err.unwrap_or(gst_error_msg!( - gst::LibraryError::Failed, - ["Interrupted during stop"] - )) + err.unwrap_or_else(|| { + gst_error_msg!(gst::LibraryError::Failed, ["Interrupted during stop"]) + }) }) .map(|_| ()) } @@ -313,16 +312,17 @@ impl S3Sink { }); let response = s3utils::wait(&self.canceller, &self.runtime, create_multipart_req_future) .map_err(|err| { - err.unwrap_or(gst_error_msg!( - gst::LibraryError::Failed, - ["Interrupted during start"] - )) + err.unwrap_or_else(|| { + gst_error_msg!(gst::LibraryError::Failed, ["Interrupted during start"]) + }) })?; - let upload_id = response.upload_id.ok_or(gst_error_msg!( - gst::ResourceError::Failed, - ["Failed to get multipart upload ID"] - ))?; + let upload_id = response.upload_id.ok_or_else(|| { + gst_error_msg!( + gst::ResourceError::Failed, + ["Failed to get multipart upload ID"] + ) + })?; Ok(Started::new( Vec::with_capacity(self.settings.lock().unwrap().buffer_size as usize), diff --git a/gst-plugin-s3/src/s3src.rs b/gst-plugin-s3/src/s3src.rs index 9933e401..305cc39f 100644 --- a/gst-plugin-s3/src/s3src.rs +++ b/gst-plugin-s3/src/s3src.rs @@ -119,10 +119,9 @@ impl S3Src { }), ) .map_err(|err| { - err.unwrap_or(gst_error_msg!( - gst::LibraryError::Failed, - ["Interrupted during start"] - )) + err.unwrap_or_else(|| { + gst_error_msg!(gst::LibraryError::Failed, ["Interrupted during start"]) + }) })?; if let Some(size) = output.content_length { @@ -300,7 +299,7 @@ impl ObjectImpl for S3Src { let basesrc = obj.downcast_ref::().unwrap(); basesrc.set_format(gst::Format::Bytes); /* Set a larger default blocksize to make read more efficient */ - basesrc.set_blocksize(262144); + basesrc.set_blocksize(256 * 1024); } } @@ -368,7 +367,7 @@ impl BaseSrcImpl for S3Src { *state = StreamingState::Started { url: s3url, client: s3client, - size: size, + size, }; Ok(()) diff --git a/gst-plugin-s3/src/s3url.rs b/gst-plugin-s3/src/s3url.rs index 2baae1ba..7c2af613 100644 --- a/gst-plugin-s3/src/s3url.rs +++ b/gst-plugin-s3/src/s3url.rs @@ -85,10 +85,10 @@ pub fn parse_s3_url(url_str: &str) -> Result { } Ok(GstS3Url { - region: region, - bucket: bucket, - object: object, - version: version, + region, + bucket, + object, + version, }) } diff --git a/gst-plugin-sodium/src/decrypter.rs b/gst-plugin-sodium/src/decrypter.rs index 7fc6901e..20d8ae6c 100644 --- a/gst-plugin-sodium/src/decrypter.rs +++ b/gst-plugin-sodium/src/decrypter.rs @@ -140,7 +140,7 @@ impl State { gst_debug!(CAT, obj: pad, "Returned pull size: {}", map.len()); - let mut nonce = add_nonce(self.initial_nonce.clone().unwrap(), chunk_index); + let mut nonce = add_nonce(self.initial_nonce.unwrap(), chunk_index); let block_size = self.block_size.expect("Block size wasn't set") as usize + box_::MACBYTES; for subbuffer in map.chunks(block_size) { diff --git a/gst-plugin-sodium/src/encrypter.rs b/gst-plugin-sodium/src/encrypter.rs index 03dbb16b..495ac3fc 100644 --- a/gst-plugin-sodium/src/encrypter.rs +++ b/gst-plugin-sodium/src/encrypter.rs @@ -271,7 +271,6 @@ impl Encrypter { })?, ); - drop(state); drop(state_guard); for buffer in buffers { @@ -324,7 +323,6 @@ impl Encrypter { } // drop the lock before pushing into the pad - drop(state); drop(state_mutex); for buffer in buffers { diff --git a/gst-plugin-threadshare/src/appsrc.rs b/gst-plugin-threadshare/src/appsrc.rs index 5185f9f6..f431919a 100644 --- a/gst-plugin-threadshare/src/appsrc.rs +++ b/gst-plugin-threadshare/src/appsrc.rs @@ -223,7 +223,7 @@ impl AppSrc { } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or_else(|| gst::Caps::new_any()) + .unwrap_or_else(gst::Caps::new_any) }; q.set_result(&caps); diff --git a/gst-plugin-threadshare/src/proxy.rs b/gst-plugin-threadshare/src/proxy.rs index 7756c4b5..98f35636 100644 --- a/gst-plugin-threadshare/src/proxy.rs +++ b/gst-plugin-threadshare/src/proxy.rs @@ -858,7 +858,7 @@ impl ProxySrc { } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or_else(|| gst::Caps::new_any()) + .unwrap_or_else(gst::Caps::new_any) }; q.set_result(&caps); diff --git a/gst-plugin-threadshare/src/tcpclientsrc.rs b/gst-plugin-threadshare/src/tcpclientsrc.rs index f9e6a41f..5e9ad5c6 100644 --- a/gst-plugin-threadshare/src/tcpclientsrc.rs +++ b/gst-plugin-threadshare/src/tcpclientsrc.rs @@ -169,14 +169,10 @@ impl SocketRead for TcpClientReader { }, }; match socket.poll_read(buf) { - Ok(Async::Ready(result)) => { - return Ok(Async::Ready((result, None))); - } - Ok(Async::NotReady) => { - return Ok(Async::NotReady); - } + Ok(Async::Ready(result)) => Ok(Async::Ready((result, None))), + Ok(Async::NotReady) => Ok(Async::NotReady), Err(result) => return Err(result), - }; + } } } @@ -270,7 +266,7 @@ impl TcpClientSrc { } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or_else(|| gst::Caps::new_any()) + .unwrap_or_else(gst::Caps::new_any) }; q.set_result(&caps); diff --git a/gst-plugin-threadshare/src/udpsrc.rs b/gst-plugin-threadshare/src/udpsrc.rs index cf036863..8d932623 100644 --- a/gst-plugin-threadshare/src/udpsrc.rs +++ b/gst-plugin-threadshare/src/udpsrc.rs @@ -303,14 +303,10 @@ impl SocketRead for UdpReader { buf: &mut [u8], ) -> Poll<(usize, Option), io::Error> { match self.socket.poll_recv_from(buf) { - Ok(Async::Ready(result)) => { - return Ok(Async::Ready((result.0, Some(result.1)))); - } - Ok(Async::NotReady) => { - return Ok(Async::NotReady); - } - Err(result) => return Err(result), - }; + Ok(Async::Ready(result)) => Ok(Async::Ready((result.0, Some(result.1)))), + Ok(Async::NotReady) => Ok(Async::NotReady), + Err(result) => Err(result), + } } } @@ -404,7 +400,7 @@ impl UdpSrc { } else { q.get_filter() .map(|f| f.to_owned()) - .unwrap_or_else(|| gst::Caps::new_any()) + .unwrap_or_else(gst::Caps::new_any) }; q.set_result(&caps); diff --git a/gst-plugin-version-helper/src/lib.rs b/gst-plugin-version-helper/src/lib.rs index 1d37fa96..75a300be 100644 --- a/gst-plugin-version-helper/src/lib.rs +++ b/gst-plugin-version-helper/src/lib.rs @@ -2,7 +2,7 @@ use chrono::TimeZone; use git2::{Commit, ObjectType, Repository}; use std::path; -pub fn get_info() -> () { +pub fn get_info() { let mut commit_id = "UNKNOWN".to_string(); let mut commit_date = chrono::Utc::now().format("%Y-%m-%d").to_string();