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
This commit is contained in:
Sebastian Dröge 2022-03-24 12:40:52 +02:00
parent 208e1ef7a4
commit 07be60a22f
5 changed files with 9 additions and 11 deletions

View file

@ -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,

View file

@ -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,

View file

@ -13,7 +13,7 @@ unsafe extern "C" fn trampoline_watch<F: FnMut(&RTSPSessionPool) -> Continue + S
func: gpointer,
) -> gboolean {
let func: &RefCell<F> = &*(func as *const RefCell<F>);
(&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<

View file

@ -24,7 +24,7 @@ unsafe extern "C" fn trampoline_watch<F: FnMut(&Bus, &Message) -> Continue + Sen
func: gpointer,
) -> gboolean {
let func: &RefCell<F> = &*(func as *const RefCell<F>);
(&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<F: FnMut(&Bus, &Message) -> Continue
) -> gboolean {
let func: &glib::thread_guard::ThreadGuard<RefCell<F>> =
&*(func as *const glib::thread_guard::ThreadGuard<RefCell<F>>);
(&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()
}

View file

@ -1598,7 +1598,7 @@ unsafe extern "C" fn destroy_closure<F>(ptr: gpointer) {
unsafe extern "C" fn trampoline_pad_task<F: FnMut() + Send + 'static>(func: gpointer) {
let func: &RefCell<F> = &*(func as *const RefCell<F>);
(&mut *func.borrow_mut())()
(*func.borrow_mut())()
}
fn into_raw_pad_task<F: FnMut() + Send + 'static>(func: F) -> gpointer {