From 4f186e01470c8ae21083eedbd72e4d40a53a93e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 24 Mar 2022 12:40:52 +0200 Subject: [PATCH] Don't unnecessarily borrow dereferenced values explicitly warning: this expression borrows a value the compiler would automatically borrow --> gstreamer-rtsp-server/src/rtsp_session_pool.rs:16:5 | 16 | (&mut *func.borrow_mut())(&from_glib_borrow(pool)).into_glib() | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `(*func.borrow_mut())` | = note: `#[warn(clippy::needless_borrow)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow --- gstreamer-app/src/app_sink.rs | 10 ++++------ gstreamer-app/src/app_src.rs | 2 +- gstreamer-rtsp-server/src/rtsp_session_pool.rs | 2 +- gstreamer/src/bus.rs | 4 ++-- gstreamer/src/pad.rs | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 76470e665..b84285990 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -169,9 +169,7 @@ unsafe extern "C" fn trampoline_eos(appsink: *mut ffi::GstAppSink, callbacks: gp } if let Some(ref eos) = callbacks.eos { - let result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - (&mut *eos.borrow_mut())(&element) - })); + let result = panic::catch_unwind(panic::AssertUnwindSafe(|| (*eos.borrow_mut())(&element))); match result { Ok(result) => result, Err(err) => { @@ -197,7 +195,7 @@ unsafe extern "C" fn trampoline_new_preroll( let ret = if let Some(ref new_preroll) = callbacks.new_preroll { let result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - (&mut *new_preroll.borrow_mut())(&element).into() + (*new_preroll.borrow_mut())(&element).into() })); match result { Ok(result) => result, @@ -230,7 +228,7 @@ unsafe extern "C" fn trampoline_new_sample( let ret = if let Some(ref new_sample) = callbacks.new_sample { let result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - (&mut *new_sample.borrow_mut())(&element).into() + (*new_sample.borrow_mut())(&element).into() })); match result { Ok(result) => result, @@ -263,7 +261,7 @@ unsafe extern "C" fn trampoline_new_event( let ret = if let Some(ref new_event) = callbacks.new_event { let result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - (&mut *new_event.borrow_mut())(&element) + (*new_event.borrow_mut())(&element) })); match result { Ok(result) => result, diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index 58e78e142..b9e2c99ae 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -137,7 +137,7 @@ unsafe extern "C" fn trampoline_need_data( if let Some(ref need_data) = callbacks.need_data { let result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - (&mut *need_data.borrow_mut())(&element, length) + (*need_data.borrow_mut())(&element, length) })); match result { Ok(result) => result, diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index 8e2a6783f..403853d56 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -13,7 +13,7 @@ unsafe extern "C" fn trampoline_watch Continue + S func: gpointer, ) -> gboolean { let func: &RefCell = &*(func as *const RefCell); - (&mut *func.borrow_mut())(&from_glib_borrow(pool)).into_glib() + (*func.borrow_mut())(&from_glib_borrow(pool)).into_glib() } unsafe extern "C" fn destroy_closure_watch< diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 579eb9c0c..4ad3ec83b 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -24,7 +24,7 @@ unsafe extern "C" fn trampoline_watch Continue + Sen func: gpointer, ) -> gboolean { let func: &RefCell = &*(func as *const RefCell); - (&mut *func.borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).into_glib() + (*func.borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).into_glib() } unsafe extern "C" fn destroy_closure_watch< @@ -48,7 +48,7 @@ unsafe extern "C" fn trampoline_watch_local Continue ) -> gboolean { let func: &glib::thread_guard::ThreadGuard> = &*(func as *const glib::thread_guard::ThreadGuard>); - (&mut *func.get_ref().borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)) + (*func.get_ref().borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)) .into_glib() } diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index f7c4dd00d..a87538eaa 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -1598,7 +1598,7 @@ unsafe extern "C" fn destroy_closure(ptr: gpointer) { unsafe extern "C" fn trampoline_pad_task(func: gpointer) { let func: &RefCell = &*(func as *const RefCell); - (&mut *func.borrow_mut())() + (*func.borrow_mut())() } fn into_raw_pad_task(func: F) -> gpointer {