From 529b91b524413c7afde5e0e6d2480081560f8e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 14 Jun 2024 08:08:27 +0300 Subject: [PATCH] Fix various new 1.79 clippy warnings Part-of: --- examples/src/bin/appsink.rs | 2 -- examples/src/bin/pad_probes.rs | 2 -- examples/src/glupload.rs | 1 + gstreamer-analytics/src/relation_meta.rs | 4 +-- gstreamer-app/src/app_sink.rs | 26 ++++++++--------- gstreamer-app/src/app_src.rs | 2 +- gstreamer-audio/src/audio_aggregator.rs | 2 +- .../src/audio_aggregator_convert_pad.rs | 2 +- gstreamer-audio/src/functions.rs | 4 +-- gstreamer-audio/src/subclass/audio_decoder.rs | 4 +-- gstreamer-base/src/aggregator.rs | 4 +-- gstreamer-pbutils/src/discoverer.rs | 2 +- gstreamer-play/src/play_signal_adapter.rs | 6 ++-- gstreamer-player/src/player.rs | 6 ++-- gstreamer-rtp/src/rtp_base_depayload.rs | 2 +- gstreamer-rtp/src/rtp_base_payload.rs | 2 +- gstreamer-rtsp-server/src/rtsp_auth.rs | 2 +- .../src/rtsp_session_pool.rs | 2 +- .../src/subclass/rtsp_media_factory.rs | 7 +++-- gstreamer-validate/src/enums.rs | 10 +++---- gstreamer-video/src/functions.rs | 2 +- .../src/video_aggregator_convert_pad.rs | 2 +- gstreamer-video/src/video_hdr.rs | 28 ++++++++++++++++--- gstreamer/src/bin.rs | 2 +- gstreamer/src/buffer.rs | 2 +- gstreamer/src/buffer_cursor.rs | 2 +- gstreamer/src/bus.rs | 2 +- gstreamer/src/enums.rs | 14 +++++----- gstreamer/src/format/clock_time.rs | 6 ++-- gstreamer/src/format/macros.rs | 12 ++++---- gstreamer/src/segment_serde.rs | 16 +++++------ gstreamer/src/stream_collection.rs | 2 +- gstreamer/src/subclass/tracer.rs | 2 +- gstreamer/src/tags_serde.rs | 6 ++-- gstreamer/src/typefind.rs | 2 -- 35 files changed, 103 insertions(+), 89 deletions(-) diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index 15bf095f9..601c5fc0d 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -10,8 +10,6 @@ // This is the format we request: // Audio / Signed 16bit / 1 channel / arbitrary sample rate -use std::i16; - use anyhow::Error; use byte_slice_cast::*; use derive_more::{Display, Error}; diff --git a/examples/src/bin/pad_probes.rs b/examples/src/bin/pad_probes.rs index 16c1b88af..2eeafd64e 100644 --- a/examples/src/bin/pad_probes.rs +++ b/examples/src/bin/pad_probes.rs @@ -8,8 +8,6 @@ // {audiotestsrc} - {fakesink} #![allow(clippy::question_mark)] -use std::i16; - use byte_slice_cast::*; use gst::prelude::*; diff --git a/examples/src/glupload.rs b/examples/src/glupload.rs index 929658f37..730245608 100644 --- a/examples/src/glupload.rs +++ b/examples/src/glupload.rs @@ -81,6 +81,7 @@ void main() { #[allow(clippy::too_many_arguments)] #[allow(clippy::manual_non_exhaustive)] #[allow(clippy::upper_case_acronyms)] +#[allow(clippy::missing_transmute_annotations)] pub(crate) mod gl { pub use self::Gles2 as Gl; include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs")); diff --git a/gstreamer-analytics/src/relation_meta.rs b/gstreamer-analytics/src/relation_meta.rs index 3fb566ddc..9adb7ab8d 100644 --- a/gstreamer-analytics/src/relation_meta.rs +++ b/gstreamer-analytics/src/relation_meta.rs @@ -484,7 +484,7 @@ macro_rules! define_mtd_iter { meta, state: std::ptr::null_mut(), mtd_type: T::mtd_type(), - an_meta_id: std::u32::MAX, + an_meta_id: u32::MAX, rel_type: RelTypes::ANY.into_glib(), phantom: PhantomData, } @@ -513,7 +513,7 @@ macro_rules! define_mtd_iter { unsafe { let mut mtd = ffi::GstAnalyticsMtd::unsafe_from(&**self.meta); let ret = { - if self.an_meta_id == std::u32::MAX { + if self.an_meta_id == u32::MAX { ffi::gst_analytics_relation_meta_iterate( self.meta.as_mut_ptr(), &mut self.state, diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 58fa707df..feed1c605 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -652,7 +652,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::async\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_async_trampoline:: as *const (), )), Box::into_raw(f), @@ -680,7 +680,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::blocksize\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_blocksize_trampoline:: as *const (), )), Box::into_raw(f), @@ -708,7 +708,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::enable-last-sample\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_enable_last_sample_trampoline:: as *const (), )), Box::into_raw(f), @@ -736,7 +736,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::last-sample\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_last_sample_trampoline:: as *const (), )), Box::into_raw(f), @@ -764,7 +764,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::max-bitrate\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_bitrate_trampoline:: as *const (), )), Box::into_raw(f), @@ -792,7 +792,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::max-lateness\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_lateness_trampoline:: as *const (), )), Box::into_raw(f), @@ -822,7 +822,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::processing-deadline\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_processing_deadline_trampoline:: as *const (), )), Box::into_raw(f), @@ -848,7 +848,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::qos\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_qos_trampoline:: as *const (), )), Box::into_raw(f), @@ -876,7 +876,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::render-delay\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_render_delay_trampoline:: as *const (), )), Box::into_raw(f), @@ -904,7 +904,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::stats\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_stats_trampoline:: as *const (), )), Box::into_raw(f), @@ -930,7 +930,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::sync\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_sync_trampoline:: as *const (), )), Box::into_raw(f), @@ -958,7 +958,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::throttle-time\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_throttle_time_trampoline:: as *const (), )), Box::into_raw(f), @@ -986,7 +986,7 @@ impl AppSink { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::ts-offset\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_ts_offset_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index f8666b654..c0abe51b4 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -329,7 +329,7 @@ impl AppSrc { glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::do-timestamp\0".as_ptr() as *const _, - Some(mem::transmute::<_, unsafe extern "C" fn()>( + Some(mem::transmute::<*const (), unsafe extern "C" fn()>( notify_do_timestamp_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-audio/src/audio_aggregator.rs b/gstreamer-audio/src/audio_aggregator.rs index 473bd0fdc..8fc53a478 100644 --- a/gstreamer-audio/src/audio_aggregator.rs +++ b/gstreamer-audio/src/audio_aggregator.rs @@ -68,7 +68,7 @@ pub trait AudioAggregatorExtManual: sealed::Sealed + IsA + 'sta connect_raw( self.as_ptr() as *mut _, b"notify::output-buffer-duration-fraction\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( notify_output_buffer_duration_fraction_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-audio/src/audio_aggregator_convert_pad.rs b/gstreamer-audio/src/audio_aggregator_convert_pad.rs index 26c588d4e..684e4998c 100644 --- a/gstreamer-audio/src/audio_aggregator_convert_pad.rs +++ b/gstreamer-audio/src/audio_aggregator_convert_pad.rs @@ -52,7 +52,7 @@ pub trait AudioAggregatorConvertPadExtManual: connect_raw( self.as_ptr() as *mut _, b"notify::converter-config\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( notify_converter_config_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-audio/src/functions.rs b/gstreamer-audio/src/functions.rs index 67c322628..a4504ef0a 100644 --- a/gstreamer-audio/src/functions.rs +++ b/gstreamer-audio/src/functions.rs @@ -1,7 +1,5 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::i32; - use glib::translate::{from_glib_full, IntoGlibPtr, ToGlibPtr}; #[doc(alias = "gst_audio_buffer_clip")] @@ -39,7 +37,7 @@ pub fn audio_buffer_truncate( buffer.into_glib_ptr(), bpf as i32, trim, - samples.unwrap_or(std::usize::MAX), + samples.unwrap_or(usize::MAX), )) } } diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index 568c9f2d8..66a02f904 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -602,8 +602,8 @@ unsafe extern "C" fn audio_decoder_parse( gst::panic_to_error!(imp, gst::FlowReturn::Error, { match imp.parse(&from_glib_borrow(adapter)) { Ok((new_offset, new_len)) => { - assert!(new_offset <= std::i32::MAX as u32); - assert!(new_len <= std::i32::MAX as u32); + assert!(new_offset <= i32::MAX as u32); + assert!(new_len <= i32::MAX as u32); *offset = new_offset as i32; *len = new_len as i32; Ok(gst::FlowSuccess::Ok) diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index 33d849bae..64fffad2c 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -65,7 +65,7 @@ pub trait AggregatorExtManual: sealed::Sealed + IsA + 'static { connect_raw( self.as_ptr() as *mut _, b"notify::min-upstream-latency\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( notify_min_upstream_latency_trampoline:: as *const (), )), Box_::into_raw(f), @@ -184,7 +184,7 @@ pub trait AggregatorExtManual: sealed::Sealed + IsA + 'static { connect_raw( self.as_ptr() as *mut _, b"samples-selected\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( samples_selected_trampoline:: as *const (), )), Box_::into_raw(f), diff --git a/gstreamer-pbutils/src/discoverer.rs b/gstreamer-pbutils/src/discoverer.rs index 9e7bdc00e..0d18f0067 100644 --- a/gstreamer-pbutils/src/discoverer.rs +++ b/gstreamer-pbutils/src/discoverer.rs @@ -29,7 +29,7 @@ impl Discoverer { connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( notify_timeout_trampoline:: as *const (), )), Box_::into_raw(f), diff --git a/gstreamer-play/src/play_signal_adapter.rs b/gstreamer-play/src/play_signal_adapter.rs index 96160899e..bbc381b44 100644 --- a/gstreamer-play/src/play_signal_adapter.rs +++ b/gstreamer-play/src/play_signal_adapter.rs @@ -34,7 +34,7 @@ impl PlaySignalAdapter { connect_raw( self.as_ptr() as *mut _, b"duration-changed\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( duration_changed_trampoline:: as *const (), )), Box_::into_raw(f), @@ -65,7 +65,7 @@ impl PlaySignalAdapter { connect_raw( self.as_ptr() as *mut _, b"position-updated\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( position_updated_trampoline:: as *const (), )), Box_::into_raw(f), @@ -97,7 +97,7 @@ impl PlaySignalAdapter { connect_raw( self.as_ptr() as *mut _, b"seek-done\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( seek_done_trampoline:: as *const (), )), Box_::into_raw(f), diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index 410f61683..4ba634867 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -37,7 +37,7 @@ impl Player { connect_raw( self.as_ptr() as *mut _, b"duration-changed\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( duration_changed_trampoline:: as *const (), )), Box_::into_raw(f), @@ -55,7 +55,7 @@ impl Player { connect_raw( self.as_ptr() as *mut _, b"position-updated\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( position_updated_trampoline:: as *const (), )), Box_::into_raw(f), @@ -73,7 +73,7 @@ impl Player { connect_raw( self.as_ptr() as *mut _, b"seek-done\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( seek_done_trampoline:: as *const (), )), Box_::into_raw(f), diff --git a/gstreamer-rtp/src/rtp_base_depayload.rs b/gstreamer-rtp/src/rtp_base_depayload.rs index ee0d7788b..d954c69cd 100644 --- a/gstreamer-rtp/src/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/rtp_base_depayload.rs @@ -45,7 +45,7 @@ pub trait RTPBaseDepayloadExtManual: sealed::Sealed + IsA + 's glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::extensions\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_extensions_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-rtp/src/rtp_base_payload.rs b/gstreamer-rtp/src/rtp_base_payload.rs index 962cedc35..c13bf7606 100644 --- a/gstreamer-rtp/src/rtp_base_payload.rs +++ b/gstreamer-rtp/src/rtp_base_payload.rs @@ -62,7 +62,7 @@ pub trait RTPBasePayloadExtManual: sealed::Sealed + IsA + 'stati glib::signal::connect_raw( self.as_ptr() as *mut _, b"notify::extensions\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_extensions_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-rtsp-server/src/rtsp_auth.rs b/gstreamer-rtsp-server/src/rtsp_auth.rs index 8a6a38a66..c862e9993 100644 --- a/gstreamer-rtsp-server/src/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/rtsp_auth.rs @@ -45,7 +45,7 @@ pub trait RTSPAuthExtManual: sealed::Sealed + IsA + 'static { connect_raw( self.as_ptr() as *mut _, b"accept-certificate\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( accept_certificate_trampoline:: as *const (), )), Box_::into_raw(f), diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index 12cdcf9a3..07af44cb8 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -53,7 +53,7 @@ pub trait RTSPSessionPoolExtManual: sealed::Sealed + IsA + 'sta glib::ffi::g_source_set_callback( source, Some(transmute::< - _, + *const (), unsafe extern "C" fn(glib::ffi::gpointer) -> i32, >(trampoline_watch:: as *const ())), into_raw_watch(func), diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs index fbfa8f355..b26a8b455 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs @@ -241,9 +241,10 @@ unsafe extern "C" fn factory_create_pipeline( media as *mut _, pipeline_quark.into_glib(), pipeline as *mut _, - Some(transmute::<_, unsafe extern "C" fn(glib::ffi::gpointer)>( - glib::gobject_ffi::g_object_unref as *const (), - )), + Some(transmute::< + *const (), + unsafe extern "C" fn(glib::ffi::gpointer), + >(glib::gobject_ffi::g_object_unref as *const ())), ); pipeline as *mut _ diff --git a/gstreamer-validate/src/enums.rs b/gstreamer-validate/src/enums.rs index 2a71a1975..a111300d0 100644 --- a/gstreamer-validate/src/enums.rs +++ b/gstreamer-validate/src/enums.rs @@ -107,7 +107,7 @@ impl FromGlib for ActionReturn { { ActionReturn::Error } else { - std::mem::transmute(value) + std::mem::transmute::(value) } } } @@ -129,21 +129,21 @@ impl ActionReturn { pub fn into_result(self) -> Result { match self { Self::Error | Self::ErrorReported | Self::None => { - Err(unsafe { std::mem::transmute(self) }) + Err(unsafe { std::mem::transmute::(self) }) } - _ => Ok(unsafe { std::mem::transmute(self) }), + _ => Ok(unsafe { std::mem::transmute::(self) }), } } #[inline] pub fn from_error(v: ActionError) -> Self { skip_assert_initialized!(); - unsafe { std::mem::transmute(v) } + unsafe { std::mem::transmute::(v) } } #[inline] pub fn from_ok(v: ActionSuccess) -> Self { skip_assert_initialized!(); - unsafe { std::mem::transmute(v) } + unsafe { std::mem::transmute::(v) } } } diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index a69f81fbc..414b9385a 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::{i32, mem, ptr}; +use std::{mem, ptr}; use glib::translate::{from_glib, from_glib_full, IntoGlib, ToGlibPtr}; diff --git a/gstreamer-video/src/video_aggregator_convert_pad.rs b/gstreamer-video/src/video_aggregator_convert_pad.rs index 1a0b396d7..da92aee18 100644 --- a/gstreamer-video/src/video_aggregator_convert_pad.rs +++ b/gstreamer-video/src/video_aggregator_convert_pad.rs @@ -52,7 +52,7 @@ pub trait VideoAggregatorConvertPadExtManual: connect_raw( self.as_ptr() as *mut _, b"notify::converter-config\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( notify_converter_config_trampoline:: as *const (), )), Box::into_raw(f), diff --git a/gstreamer-video/src/video_hdr.rs b/gstreamer-video/src/video_hdr.rs index afe96fffd..1c97bf714 100644 --- a/gstreamer-video/src/video_hdr.rs +++ b/gstreamer-video/src/video_hdr.rs @@ -151,8 +151,18 @@ impl VideoMasteringDisplayInfo { skip_assert_initialized!(); VideoMasteringDisplayInfo(ffi::GstVideoMasteringDisplayInfo { - display_primaries: unsafe { mem::transmute(display_primaries) }, - white_point: unsafe { mem::transmute(white_point) }, + display_primaries: unsafe { + mem::transmute::< + [VideoMasteringDisplayInfoCoordinate; 3], + [ffi::GstVideoMasteringDisplayInfoCoordinates; 3], + >(display_primaries) + }, + white_point: unsafe { + mem::transmute::< + VideoMasteringDisplayInfoCoordinate, + ffi::GstVideoMasteringDisplayInfoCoordinates, + >(white_point) + }, max_display_mastering_luminance, min_display_mastering_luminance, _gst_reserved: [ptr::null_mut(); 4], @@ -167,7 +177,12 @@ impl VideoMasteringDisplayInfo { &mut self, display_primaries: [VideoMasteringDisplayInfoCoordinate; 3], ) { - self.0.display_primaries = unsafe { mem::transmute(display_primaries) }; + self.0.display_primaries = unsafe { + mem::transmute::< + [VideoMasteringDisplayInfoCoordinate; 3], + [ffi::GstVideoMasteringDisplayInfoCoordinates; 3], + >(display_primaries) + }; } pub fn white_point(&self) -> VideoMasteringDisplayInfoCoordinate { @@ -175,7 +190,12 @@ impl VideoMasteringDisplayInfo { } pub fn set_white_point(&mut self, white_point: VideoMasteringDisplayInfoCoordinate) { - self.0.white_point = unsafe { mem::transmute(white_point) }; + self.0.white_point = unsafe { + mem::transmute::< + VideoMasteringDisplayInfoCoordinate, + ffi::GstVideoMasteringDisplayInfoCoordinates, + >(white_point) + }; } pub fn max_display_mastering_luminance(&self) -> u32 { diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index 885e4ecb3..5cab6f960 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -95,7 +95,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA + 'static { connect_raw( self.as_ptr() as *mut _, b"do-latency\0".as_ptr() as *const _, - Some(transmute::<_, unsafe extern "C" fn()>( + Some(transmute::<*const (), unsafe extern "C" fn()>( do_latency_trampoline:: as *const (), )), Box_::into_raw(f), diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index 1f6c692f7..c1defc35a 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -5,7 +5,7 @@ use std::{ marker::PhantomData, mem, ops, ops::{Bound, ControlFlow, Range, RangeBounds}, - ptr, slice, u64, usize, + ptr, slice, }; use glib::translate::*; diff --git a/gstreamer/src/buffer_cursor.rs b/gstreamer/src/buffer_cursor.rs index 727f9fe2c..394e8a01f 100644 --- a/gstreamer/src/buffer_cursor.rs +++ b/gstreamer/src/buffer_cursor.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::{fmt, io, marker::PhantomData, mem, ptr, u64, usize}; +use std::{fmt, io, marker::PhantomData, mem, ptr}; use crate::{ buffer::{Readable, Writable}, diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 42181d043..732a15ac2 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -120,7 +120,7 @@ impl Bus { glib::ffi::g_source_set_callback( source, Some(transmute::< - _, + *const (), unsafe extern "C" fn(glib::ffi::gpointer) -> i32, >(trampoline_watch:: as *const ())), into_raw_watch(func), diff --git a/gstreamer/src/enums.rs b/gstreamer/src/enums.rs index 3fa438cab..c73de944b 100644 --- a/gstreamer/src/enums.rs +++ b/gstreamer/src/enums.rs @@ -76,7 +76,7 @@ impl StateChangeReturn { pub fn into_result(self) -> Result { match self { StateChangeReturn::Failure => Err(StateChangeError), - _ => Ok(unsafe { std::mem::transmute(self) }), + _ => Ok(unsafe { std::mem::transmute::(self) }), } } @@ -171,7 +171,7 @@ impl FromGlib for FlowReturn { { FlowReturn::Ok } else { - std::mem::transmute(value) + std::mem::transmute::(value) } } } @@ -225,9 +225,9 @@ impl FlowReturn { #[inline] pub fn into_result(self) -> Result { if self.into_glib() >= 0 { - Ok(unsafe { std::mem::transmute(self) }) + Ok(unsafe { std::mem::transmute::(self) }) } else { - Err(unsafe { std::mem::transmute(self) }) + Err(unsafe { std::mem::transmute::(self) }) } } @@ -321,7 +321,7 @@ impl FromGlib for PadLinkReturn { } else if value < ffi::GST_PAD_LINK_REFUSED { PadLinkReturn::Refused } else { - std::mem::transmute(value) + std::mem::transmute::(value) } } } @@ -377,7 +377,7 @@ impl PadLinkReturn { if self == PadLinkReturn::Ok { Ok(PadLinkSuccess) } else { - Err(unsafe { std::mem::transmute(self) }) + Err(unsafe { std::mem::transmute::(self) }) } } @@ -428,7 +428,7 @@ impl ClockReturn { match self { ClockReturn::Ok => Ok(ClockSuccess::Ok), ClockReturn::Done => Ok(ClockSuccess::Done), - _ => Err(unsafe { std::mem::transmute(self) }), + _ => Err(unsafe { std::mem::transmute::(self) }), } } diff --git a/gstreamer/src/format/clock_time.rs b/gstreamer/src/format/clock_time.rs index 7e510db25..4043b7aed 100644 --- a/gstreamer/src/format/clock_time.rs +++ b/gstreamer/src/format/clock_time.rs @@ -565,8 +565,8 @@ impl TryFrom for ClockTime { let nanos = d.as_nanos(); - // Note: `std::u64::MAX` is `ClockTime::NONE`. - if nanos >= std::u64::MAX as u128 { + // Note: `u64::MAX` is `ClockTime::NONE`. + if nanos >= u64::MAX as u128 { return Err(DurationError); } @@ -1305,7 +1305,7 @@ mod tests { fn display() { let none = Option::::None; let some = Some(45_834_908_569_837 * ClockTime::NSECOND); - let lots = ClockTime::from_nseconds(std::u64::MAX - 1); + let lots = ClockTime::from_nseconds(u64::MAX - 1); // Simple diff --git a/gstreamer/src/format/macros.rs b/gstreamer/src/format/macros.rs index 51402d903..f4fcb1b8b 100644 --- a/gstreamer/src/format/macros.rs +++ b/gstreamer/src/format/macros.rs @@ -1452,12 +1452,12 @@ macro_rules! impl_signed_div_mul_trait( match self { Positive(lhs) => { $into_inner(lhs) - .mul_div_floor(num.abs() as $inner, denom.abs() as $inner) + .mul_div_floor(num.unsigned_abs(), denom.unsigned_abs()) .and_then(|val| Self::signed_from_inner(val, num.signum() * denom.signum())) } Negative(lhs) => { $into_inner(lhs) - .mul_div_floor(num.abs() as $inner, denom.abs() as $inner) + .mul_div_floor(num.unsigned_abs(), denom.unsigned_abs()) .and_then(|val| Self::signed_from_inner(val, -num.signum() * denom.signum())) } } @@ -1469,12 +1469,12 @@ macro_rules! impl_signed_div_mul_trait( match self { Positive(lhs) => { $into_inner(lhs) - .mul_div_round(num.abs() as $inner, denom.abs() as $inner) + .mul_div_round(num.unsigned_abs(), denom.unsigned_abs()) .and_then(|val| Self::signed_from_inner(val, num.signum() * denom.signum())) } Negative(lhs) => { $into_inner(lhs) - .mul_div_round(num.abs() as $inner, denom.abs() as $inner) + .mul_div_round(num.unsigned_abs(), denom.unsigned_abs()) .and_then(|val| Self::signed_from_inner(val, -num.signum() * denom.signum())) } } @@ -1486,12 +1486,12 @@ macro_rules! impl_signed_div_mul_trait( match self { Positive(lhs) => { $into_inner(lhs) - .mul_div_ceil(num.abs() as $inner, denom.abs() as $inner) + .mul_div_ceil(num.unsigned_abs(), denom.unsigned_abs()) .and_then(|val| Self::signed_from_inner(val, num.signum() * denom.signum())) } Negative(lhs) => { $into_inner(lhs) - .mul_div_ceil(num.abs() as $inner, denom.abs() as $inner) + .mul_div_ceil(num.unsigned_abs(), denom.unsigned_abs()) .and_then(|val| Self::signed_from_inner(val, -num.signum() * denom.signum())) } } diff --git a/gstreamer/src/segment_serde.rs b/gstreamer/src/segment_serde.rs index 0347981a6..ceeee617e 100644 --- a/gstreamer/src/segment_serde.rs +++ b/gstreamer/src/segment_serde.rs @@ -172,12 +172,12 @@ mod tests { let segment: Segment = ron::de::from_str(segment_ron).unwrap(); assert_eq!(segment.flags(), SegmentFlags::RESET | SegmentFlags::SEGMENT); - assert!((segment.rate() - 1f64).abs() < std::f64::EPSILON); - assert!((segment.applied_rate() - 0.9f64).abs() < std::f64::EPSILON); + assert!((segment.rate() - 1f64).abs() < f64::EPSILON); + assert!((segment.applied_rate() - 0.9f64).abs() < f64::EPSILON); assert_eq!(segment.format(), Format::Time); assert_eq!(segment.flags(), SegmentFlags::RESET | SegmentFlags::SEGMENT); - assert!((segment.rate() - 1f64).abs() < std::f64::EPSILON); - assert!((segment.applied_rate() - 0.9f64).abs() < std::f64::EPSILON); + assert!((segment.rate() - 1f64).abs() < f64::EPSILON); + assert!((segment.applied_rate() - 0.9f64).abs() < f64::EPSILON); assert_eq!(segment.format(), Format::Time); assert_eq!( segment.base(), @@ -233,8 +233,8 @@ mod tests { let fmt_seg: FormattedSegment