Fix/silence various 1.72 clippy warnings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1306>
This commit is contained in:
Sebastian Dröge 2023-08-22 10:00:35 +03:00 committed by GStreamer Marge Bot
parent f4486f5d61
commit 83a562e227
22 changed files with 69 additions and 42 deletions

View file

@ -29,7 +29,7 @@ pub trait AudioVisualizerExtManual:
fn set_req_spf(&self, spf: u32, token: &AudioVisualizerSetupToken) {
assert_eq!(
self.as_ptr() as *mut ffi::GstAudioVisualizer,
token.0.as_ptr() as *mut ffi::GstAudioVisualizer
token.0.as_ptr()
);
let sinkpad = self.static_pad("sink").expect("sink pad presence");

View file

@ -37,7 +37,7 @@ pub trait AudioVisualizerImplExt: sealed::Sealed + ObjectSubclass {
fn parent_setup(&self, token: &AudioVisualizerSetupToken) -> Result<(), LoggableError> {
assert_eq!(
self.obj().as_ptr() as *mut ffi::GstAudioVisualizer,
token.0.as_ptr() as *mut ffi::GstAudioVisualizer
token.0.as_ptr()
);
unsafe {

View file

@ -659,6 +659,7 @@ macro_rules! define_iter(
}
impl<'a> $name<'a> {
#[allow(clippy::redundant_closure_call)]
fn new(media: &'a SDPMediaRef) -> $name<'a> {
skip_assert_initialized!();
let len = $get_len(media);
@ -671,6 +672,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> Iterator for $name<'a> {
type Item = $typ;
@ -715,6 +717,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.len {

View file

@ -190,7 +190,7 @@ impl SDPMessageRef {
#[doc(alias = "gst_sdp_message_add_media")]
pub fn add_media(&mut self, media: SDPMedia) {
unsafe {
ffi::gst_sdp_message_add_media(&mut self.0, media.as_ptr() as *mut ffi::GstSDPMedia);
ffi::gst_sdp_message_add_media(&mut self.0, media.as_ptr());
}
}
@ -1013,6 +1013,7 @@ macro_rules! define_iter(
len: usize,
}
#[allow(clippy::redundant_closure_call)]
impl<'a> $name<'a> {
fn new(message: &'a SDPMessageRef) -> $name<'a> {
skip_assert_initialized!();
@ -1026,6 +1027,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> Iterator for $name<'a> {
type Item = $typ;
@ -1069,6 +1071,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.len {
@ -1106,6 +1109,7 @@ macro_rules! define_iter_mut(
len: usize,
}
#[allow(clippy::redundant_closure_call)]
impl<'a> $name<'a> {
fn new(message: &'a mut SDPMessageRef) -> $name<'a> {
skip_assert_initialized!();
@ -1119,6 +1123,7 @@ macro_rules! define_iter_mut(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> Iterator for $name<'a> {
type Item = $typ;
@ -1178,6 +1183,7 @@ macro_rules! define_iter_mut(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
let message = unsafe {

View file

@ -199,7 +199,7 @@ impl<'a> ActionTypeBuilder<'a> {
) -> c_int {
let action_type = ffi::gst_validate_get_action_type((*action).type_);
let scenario = from_glib_borrow(scenario);
let action = crate::ActionRef::from_mut_ptr(action as *mut ffi::GstValidateAction);
let action = crate::ActionRef::from_mut_ptr(action);
let func: &ActionFunction = &*(gst::ffi::gst_mini_object_get_qdata(
action_type as *mut gst::ffi::GstMiniObject,

View file

@ -64,7 +64,7 @@ pub trait VideoAggregatorImplExt: sealed::Sealed + ObjectSubclass {
) -> Result<gst::FlowSuccess, gst::FlowError> {
assert_eq!(
self.obj().as_ptr() as *mut ffi::GstVideoAggregator,
token.0.as_ptr() as *mut ffi::GstVideoAggregator
token.0.as_ptr()
);
unsafe {

View file

@ -58,8 +58,8 @@ pub trait VideoAggregatorPadImplExt: ObjectSubclass {
buffer: &gst::Buffer,
) -> Option<crate::VideoFrame<crate::video_frame::Readable>> {
assert_eq!(
aggregator.as_ptr() as *mut ffi::GstVideoAggregator,
token.0.as_ptr() as *mut ffi::GstVideoAggregator
aggregator.as_ptr(),
token.0.as_ptr()
);
unsafe {
@ -97,8 +97,8 @@ pub trait VideoAggregatorPadImplExt: ObjectSubclass {
frame: Option<crate::VideoFrame<crate::video_frame::Readable>>,
) {
assert_eq!(
aggregator.as_ptr() as *mut ffi::GstVideoAggregator,
token.0.as_ptr() as *mut ffi::GstVideoAggregator
aggregator.as_ptr(),
token.0.as_ptr()
);
unsafe {

View file

@ -42,6 +42,7 @@ macro_rules! event_builder_generic_impl {
}
#[must_use = "Building the event without using it has no effect"]
#[allow(clippy::redundant_closure_call)]
pub fn build(mut self) -> gst::Event {
skip_assert_initialized!();
unsafe {

View file

@ -237,7 +237,7 @@ impl VideoFormatInfo {
unsafe {
use std::ptr;
let mut src_ptr = [ptr::null() as *const u8; ffi::GST_VIDEO_MAX_PLANES as usize];
let mut src_ptr = [ptr::null(); ffi::GST_VIDEO_MAX_PLANES as usize];
for plane in 0..(self.n_planes()) {
src_ptr[plane as usize] = src[plane as usize].as_ptr();
}
@ -247,7 +247,7 @@ impl VideoFormatInfo {
flags.into_glib(),
dest.as_mut_ptr() as *mut _,
src_ptr.as_ptr() as *const _,
stride.as_ptr() as *const i32,
stride.as_ptr(),
x,
y,
width,
@ -313,7 +313,7 @@ impl VideoFormatInfo {
unsafe {
use std::ptr;
let mut dest_ptr = [ptr::null_mut() as *mut u8; ffi::GST_VIDEO_MAX_PLANES as usize];
let mut dest_ptr = [ptr::null_mut(); ffi::GST_VIDEO_MAX_PLANES as usize];
for plane in 0..(self.n_planes()) {
dest_ptr[plane as usize] = dest[plane as usize].as_mut_ptr();
}
@ -324,7 +324,7 @@ impl VideoFormatInfo {
src.as_ptr() as *mut _,
src_stride,
dest_ptr.as_mut_ptr() as *mut _,
dest_stride.as_ptr() as *const i32,
dest_stride.as_ptr(),
chroma_site.into_glib(),
y,
width,

View file

@ -41,6 +41,7 @@ macro_rules! message_builder_generic_impl {
}
#[must_use = "Building the message without using it has no effect"]
#[allow(clippy::redundant_closure_call)]
pub fn build(mut self) -> Message {
skip_assert_initialized!();
unsafe {

View file

@ -803,6 +803,7 @@ macro_rules! define_meta_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a, T: MetaAPI> Iterator for $name<'a, T> {
type Item = $mtyp;
@ -875,6 +876,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> Iterator for $name<'a> {
type Item = $mtyp;
@ -927,6 +929,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.n_memory {
@ -984,7 +987,7 @@ define_iter!(
if ptr.is_null() {
None
} else {
Some(MemoryRef::from_mut_ptr(ptr as *mut ffi::GstMemory))
Some(MemoryRef::from_mut_ptr(ptr))
}
}
);
@ -1149,7 +1152,7 @@ impl<'a, T> BufferMap<'a, T> {
if self.map_info.size == 0 {
return &[];
}
unsafe { slice::from_raw_parts(self.map_info.data as *const u8, self.map_info.size) }
unsafe { slice::from_raw_parts(self.map_info.data, self.map_info.size) }
}
}
@ -1159,7 +1162,7 @@ impl<'a> BufferMap<'a, Writable> {
if self.map_info.size == 0 {
return &mut [];
}
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) }
unsafe { slice::from_raw_parts_mut(self.map_info.data, self.map_info.size) }
}
}
@ -1225,7 +1228,7 @@ impl<T> MappedBuffer<T> {
if self.map_info.size == 0 {
return &[];
}
unsafe { slice::from_raw_parts(self.map_info.data as *const u8, self.map_info.size) }
unsafe { slice::from_raw_parts(self.map_info.data, self.map_info.size) }
}
#[doc(alias = "get_size")]
@ -1258,7 +1261,7 @@ impl MappedBuffer<Writable> {
if self.map_info.size == 0 {
return &mut [];
}
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) }
unsafe { slice::from_raw_parts_mut(self.map_info.data, self.map_info.size) }
}
}

View file

@ -98,7 +98,9 @@ macro_rules! define_seek_impl(
);
macro_rules! define_read_write_fn_impl(
($self:ident, $data:ident, $data_type:ty, $get_buffer_ref:expr, $map_flags:path, $copy:expr, $split:expr) => {{
($self:ident, $data:ident, $data_type:ty, $get_buffer_ref:expr, $map_flags:path, $copy:expr, $split:expr) => {
#[allow(clippy::redundant_closure_call)]
{
let mut copied = 0;
while !$data.is_empty() && $self.cur_mem_idx < $self.num_mem {

View file

@ -2,7 +2,7 @@
use std::{fmt, ops::ControlFlow, ptr};
use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlib, IntoGlibPtr};
use glib::translate::*;
use crate::{Buffer, BufferRef};
@ -140,9 +140,10 @@ impl BufferListRef {
) -> glib::ffi::gboolean {
let func = user_data as *const _ as usize as *mut F;
let res = (*func)(
Buffer::from_glib_full(
ptr::replace(buffer, ptr::null_mut::<ffi::GstBuffer>()) as *mut ffi::GstBuffer
),
Buffer::from_glib_full(ptr::replace(
buffer as *mut *const ffi::GstBuffer,
ptr::null_mut::<ffi::GstBuffer>(),
)),
idx,
);
@ -227,6 +228,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> Iterator for $name<'a> {
type Item = $styp;
@ -271,6 +273,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.size {

View file

@ -726,6 +726,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> Iterator for $name<'a> {
type Item = $styp;
@ -775,6 +776,7 @@ macro_rules! define_iter(
}
}
#[allow(clippy::redundant_closure_call)]
impl<'a> DoubleEndedIterator for $name<'a> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.idx == self.n_structures {
@ -832,9 +834,7 @@ define_iter!(
if ptr.is_null() {
None
} else {
Some(StructureRef::from_glib_borrow_mut(
ptr as *mut ffi::GstStructure,
))
Some(StructureRef::from_glib_borrow_mut(ptr))
}
}
);
@ -849,8 +849,8 @@ define_iter!(
None
} else {
Some((
StructureRef::from_glib_borrow(ptr1 as *const ffi::GstStructure),
CapsFeaturesRef::from_glib_borrow(ptr2 as *const ffi::GstCapsFeatures),
StructureRef::from_glib_borrow(ptr1),
CapsFeaturesRef::from_glib_borrow(ptr2),
))
}
}
@ -866,8 +866,8 @@ define_iter!(
None
} else {
Some((
StructureRef::from_glib_borrow_mut(ptr1 as *mut ffi::GstStructure),
CapsFeaturesRef::from_glib_borrow_mut(ptr2 as *mut ffi::GstCapsFeatures),
StructureRef::from_glib_borrow_mut(ptr1),
CapsFeaturesRef::from_glib_borrow_mut(ptr2),
))
}
}

View file

@ -2111,6 +2111,7 @@ macro_rules! event_builder_generic_impl {
}
#[must_use = "Building the event without using it has no effect"]
#[allow(clippy::redundant_closure_call)]
pub fn build(mut self) -> Event {
unsafe {
let event = $new_fn(&mut self);

View file

@ -1425,6 +1425,7 @@ macro_rules! impl_signed_extra_div_mul(
macro_rules! impl_signed_div_mul_trait(
($typ:ty, $inner:ty, $signed_rhs:ty, $into_inner:expr) => {
#[allow(clippy::redundant_closure_call)]
impl muldiv::MulDiv<$signed_rhs> for crate::Signed<$typ> {
type Output = Self;
@ -1480,6 +1481,7 @@ macro_rules! impl_signed_div_mul_trait(
}
}
#[allow(clippy::redundant_closure_call)]
impl muldiv::MulDiv<$inner> for crate::Signed<$typ> {
type Output = Self;
@ -1802,6 +1804,7 @@ macro_rules! impl_signed_int_into_signed(
};
($typ:ty, $inner:ty, $signed:ty, $into_inner:expr) => {
#[allow(clippy::redundant_closure_call)]
impl TryFrom<crate::Signed<$typ>> for $signed {
type Error = std::num::TryFromIntError;

View file

@ -1145,7 +1145,7 @@ impl fmt::Display for LoggedObject {
let parent_name = if parent_ptr.is_null() {
"<null>"
} else {
let name_ptr = (*(parent_ptr as *mut ffi::GstObject)).name;
let name_ptr = (*(parent_ptr)).name;
if name_ptr.is_null() {
"<null>"
} else {

View file

@ -353,7 +353,7 @@ impl<'a, T> MemoryMap<'a, T> {
if self.map_info.size == 0 {
return &[];
}
unsafe { slice::from_raw_parts(self.map_info.data as *const u8, self.map_info.size) }
unsafe { slice::from_raw_parts(self.map_info.data, self.map_info.size) }
}
}
@ -363,7 +363,7 @@ impl<'a> MemoryMap<'a, Writable> {
if self.map_info.size == 0 {
return &mut [];
}
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) }
unsafe { slice::from_raw_parts_mut(self.map_info.data, self.map_info.size) }
}
}
@ -429,7 +429,7 @@ impl<T> MappedMemory<T> {
if self.map_info.size == 0 {
return &[];
}
unsafe { slice::from_raw_parts(self.map_info.data as *const u8, self.map_info.size) }
unsafe { slice::from_raw_parts(self.map_info.data, self.map_info.size) }
}
#[doc(alias = "get_size")]
@ -462,7 +462,7 @@ impl MappedMemory<Writable> {
if self.map_info.size == 0 {
return &mut [];
}
unsafe { slice::from_raw_parts_mut(self.map_info.data as *mut u8, self.map_info.size) }
unsafe { slice::from_raw_parts_mut(self.map_info.data, self.map_info.size) }
}
}
@ -974,6 +974,6 @@ mod tests {
let mem = crate::Memory::from_slice(vec![1, 2, 3, 4]);
let v = mem.to_value();
assert!(matches!(v.get::<Option<crate::Memory>>(), Ok(Some(_))));
assert!(matches!(v.get::<crate::Memory>(), Ok(_)));
assert!(v.get::<crate::Memory>().is_ok());
}
}

View file

@ -2545,6 +2545,7 @@ macro_rules! message_builder_generic_impl {
}
#[must_use = "Building the message without using it has no effect"]
#[allow(clippy::redundant_closure_call)]
pub fn build(mut self) -> Message {
unsafe {
let src = self.builder.src.to_glib_none().0;

View file

@ -508,6 +508,7 @@ macro_rules! mini_object_wrapper (
}
}
#[allow(clippy::redundant_closure_call)]
impl $crate::glib::types::StaticType for $ref_name {
#[inline]
fn static_type() -> $crate::glib::types::Type {

View file

@ -52,6 +52,7 @@ impl<'a> TagValuesSer<'a> {
}
impl<'a> Serialize for TagValuesSer<'a> {
#[allow(clippy::redundant_closure_call)]
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use std::ops::DerefMut;

View file

@ -47,23 +47,24 @@ impl<'de> Deserialize<'de> for Fraction {
}
macro_rules! ser_some_value (
($value:expr, $t:ty, $ser_closure:expr) => (
($value:expr, $t:ty, $ser_closure:expr) => {
{
let value = $value.get::<$t>().expect("ser_some_value macro");
$ser_closure(stringify!($t), value)
}
);
}
);
macro_rules! ser_opt_value (
($value:expr, $t:ty, $ser_closure:expr) => (
($value:expr, $t:ty, $ser_closure:expr) => {
{
let value = $value.get::<Option<$t>>().expect("ser_opt_value macro");
$ser_closure(stringify!($t), value)
}
);
}
);
macro_rules! ser_value (
($value:expr, $ser_closure:expr) => (
($value:expr, $ser_closure:expr) => {
#[allow(clippy::redundant_closure_call)]
match $value.type_() {
glib::Type::I8 => ser_some_value!($value, i8, $ser_closure),
glib::Type::U8 => ser_some_value!($value, u8, $ser_closure),
@ -115,7 +116,7 @@ macro_rules! ser_value (
}
}
}
);
}
);
#[repr(transparent)]