Fix various new clippy 1.79 warnings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1627>
This commit is contained in:
Sebastian Dröge 2024-06-14 08:20:14 +03:00 committed by GStreamer Marge Bot
parent 0186930777
commit 998b4734bf
33 changed files with 36 additions and 52 deletions

View file

@ -11,8 +11,8 @@ use gst::prelude::*;
use gst::subclass::prelude::*; use gst::subclass::prelude::*;
use gst_audio::subclass::prelude::*; use gst_audio::subclass::prelude::*;
use std::cmp;
use std::sync::Mutex; use std::sync::Mutex;
use std::{cmp, u64};
use byte_slice_cast::*; use byte_slice_cast::*;

View file

@ -18,7 +18,6 @@ use gst::subclass::prelude::*;
use std::mem; use std::mem;
use std::sync::Mutex; use std::sync::Mutex;
use std::u64;
use byte_slice_cast::*; use byte_slice_cast::*;

View file

@ -12,7 +12,6 @@ use gst::subclass::prelude::*;
use gst_audio::subclass::prelude::*; use gst_audio::subclass::prelude::*;
use gst_base::prelude::*; use gst_base::prelude::*;
use std::i32;
use std::sync::atomic; use std::sync::atomic;
use std::sync::Mutex; use std::sync::Mutex;

View file

@ -198,7 +198,7 @@ fn basic_two_channels() {
#[test] #[test]
fn silence() { fn silence() {
run_test("wave=silence", None, 1000, 1024, 1, std::f64::NEG_INFINITY); run_test("wave=silence", None, 1000, 1024, 1, f64::NEG_INFINITY);
} }
#[test] #[test]
@ -228,7 +228,7 @@ fn below_threshold() {
1000, 1000,
1024, 1024,
1, 1,
std::f64::NEG_INFINITY, f64::NEG_INFINITY,
); );
} }

View file

@ -17,7 +17,6 @@ use gst_base::subclass::prelude::*;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex; use std::sync::Mutex;
use std::{f64, i32};
use byte_slice_cast::*; use byte_slice_cast::*;

View file

@ -500,7 +500,7 @@ impl Decrypter {
gst::debug!(CAT, obj: pad, "Stream Block index: {}", chunk_index); gst::debug!(CAT, obj: pad, "Stream Block index: {}", chunk_index);
let pull_offset = offset - (chunk_index * block_size as u64); let pull_offset = offset - (chunk_index * block_size as u64);
assert!(pull_offset <= std::u32::MAX as u64); assert!(pull_offset <= u32::MAX as u64);
let pull_offset = pull_offset as u32; let pull_offset = pull_offset as u32;
let pulled_buffer = let pulled_buffer =

View file

@ -30,7 +30,6 @@ use once_cell::sync::Lazy;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use std::u32;
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::{Context, PadSrc, Task, TaskState}; use crate::runtime::{Context, PadSrc, Task, TaskState};

View file

@ -26,7 +26,6 @@ use once_cell::sync::Lazy;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex as StdMutex; use std::sync::Mutex as StdMutex;
use std::u32;
static DATA_QUEUE_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static DATA_QUEUE_CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(

View file

@ -30,7 +30,6 @@ use once_cell::sync::Lazy;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; use std::time::Duration;
use std::u32;
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::{self, PadSink, PadSrc}; use crate::runtime::{self, PadSink, PadSrc};

View file

@ -266,7 +266,7 @@ impl SinkHandler {
inner.gap_packets.insert(GapPacket::new(buffer)); inner.gap_packets.insert(GapPacket::new(buffer));
if gap_packets_length > 0 { if gap_packets_length > 0 {
let mut prev_gap_seq = std::u32::MAX; let mut prev_gap_seq = u32::MAX;
let mut all_consecutive = true; let mut all_consecutive = true;
for gap_packet in inner.gap_packets.iter() { for gap_packet in inner.gap_packets.iter() {
@ -279,7 +279,7 @@ impl SinkHandler {
all_consecutive = gap_packet.pt == pt; all_consecutive = gap_packet.pt == pt;
if prev_gap_seq == std::u32::MAX { if prev_gap_seq == u32::MAX {
prev_gap_seq = gap_packet.seq as u32; prev_gap_seq = gap_packet.seq as u32;
} else if gst_rtp::compare_seqnum(gap_packet.seq, prev_gap_seq as u16) != -1 { } else if gst_rtp::compare_seqnum(gap_packet.seq, prev_gap_seq as u16) != -1 {
all_consecutive = false; all_consecutive = false;

View file

@ -91,7 +91,7 @@ impl RTPJitterBufferItem {
r#type: 0, r#type: 0,
dts: dts.into().into_glib(), dts: dts.into().into_glib(),
pts: pts.into().into_glib(), pts: pts.into().into_glib(),
seqnum: seqnum.map(|s| s as u32).unwrap_or(std::u32::MAX), seqnum: seqnum.map(|s| s as u32).unwrap_or(u32::MAX),
count: 1, count: 1,
rtptime, rtptime,
}, },
@ -138,7 +138,7 @@ impl RTPJitterBufferItem {
pub fn seqnum(&self) -> Option<u16> { pub fn seqnum(&self) -> Option<u16> {
unsafe { unsafe {
let item = self.0.as_ref().expect("Invalid wrapper"); let item = self.0.as_ref().expect("Invalid wrapper");
if item.as_ref().seqnum == std::u32::MAX { if item.as_ref().seqnum == u32::MAX {
None None
} else { } else {
Some(item.as_ref().seqnum as u16) Some(item.as_ref().seqnum as u16)
@ -306,7 +306,7 @@ impl RTPJitterBuffer {
let pts = from_glib(pts.assume_init()); let pts = from_glib(pts.assume_init());
let seqnum = seqnum.assume_init(); let seqnum = seqnum.assume_init();
let seqnum = if seqnum == std::u32::MAX { let seqnum = if seqnum == u32::MAX {
None None
} else { } else {
Some(seqnum as u16) Some(seqnum as u16)
@ -339,7 +339,7 @@ impl RTPJitterBuffer {
(None, None) (None, None)
} else { } else {
let seqnum = (*item).seqnum; let seqnum = (*item).seqnum;
let seqnum = if seqnum == std::u32::MAX { let seqnum = if seqnum == u32::MAX {
None None
} else { } else {
Some(seqnum as u16) Some(seqnum as u16)

View file

@ -31,7 +31,6 @@ use std::collections::{HashMap, VecDeque};
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use std::sync::{Mutex, MutexGuard}; use std::sync::{Mutex, MutexGuard};
use std::time::Duration; use std::time::Duration;
use std::{u32, u64};
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::{Context, PadSink, PadSinkWeak, PadSrc, PadSrcWeak, Task}; use crate::runtime::{Context, PadSink, PadSinkWeak, PadSrc, PadSrcWeak, Task};

View file

@ -30,7 +30,6 @@ use once_cell::sync::Lazy;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use std::{u32, u64};
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::{Context, PadSink, PadSrc, Task}; use crate::runtime::{Context, PadSink, PadSrc, Task};

View file

@ -31,8 +31,6 @@ use std::io;
use std::net::{IpAddr, SocketAddr, TcpStream}; use std::net::{IpAddr, SocketAddr, TcpStream};
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use std::u16;
use std::u32;
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::task; use crate::runtime::task;

View file

@ -37,8 +37,6 @@ use std::collections::BTreeSet;
use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}; use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; use std::time::Duration;
use std::u16;
use std::u8;
const DEFAULT_HOST: Option<&str> = Some("127.0.0.1"); const DEFAULT_HOST: Option<&str> = Some("127.0.0.1");
const DEFAULT_PORT: i32 = 5004; const DEFAULT_PORT: i32 = 5004;

View file

@ -27,12 +27,10 @@ use gst_net::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::i32;
use std::io; use std::io;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket};
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use std::u16;
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::{Async, Context, PadSrc, Task}; use crate::runtime::{Async, Context, PadSrc, Task};

View file

@ -107,7 +107,7 @@ fn setup_video_sink(pipeline: &gst::Pipeline, path: &Path, name: &str) -> Result
let enc = gst::ElementFactory::make("x264enc") let enc = gst::ElementFactory::make("x264enc")
.property("bframes", 0u32) .property("bframes", 0u32)
.property("bitrate", VIDEO_BITRATE / 1000u32) .property("bitrate", VIDEO_BITRATE / 1000u32)
.property("key-int-max", std::i32::MAX as u32) .property("key-int-max", i32::MAX as u32)
.property_from_str("tune", "zerolatency") .property_from_str("tune", "zerolatency")
.build()?; .build()?;
let h264_capsfilter = gst::ElementFactory::make("capsfilter") let h264_capsfilter = gst::ElementFactory::make("capsfilter")

View file

@ -135,13 +135,13 @@ impl ElementImpl for NdiSink {
gst_video::VideoFormat::Rgbx.to_str(), gst_video::VideoFormat::Rgbx.to_str(),
]), ]),
) )
.field("width", gst::IntRange::<i32>::new(1, std::i32::MAX)) .field("width", gst::IntRange::<i32>::new(1, i32::MAX))
.field("height", gst::IntRange::<i32>::new(1, std::i32::MAX)) .field("height", gst::IntRange::<i32>::new(1, i32::MAX))
.field( .field(
"framerate", "framerate",
gst::FractionRange::new( gst::FractionRange::new(
gst::Fraction::new(0, 1), gst::Fraction::new(0, 1),
gst::Fraction::new(std::i32::MAX, 1), gst::Fraction::new(i32::MAX, 1),
), ),
) )
.build(), .build(),

View file

@ -7,7 +7,6 @@ use gst_base::subclass::base_src::CreateSuccess;
use gst_base::subclass::prelude::*; use gst_base::subclass::prelude::*;
use std::sync::Mutex; use std::sync::Mutex;
use std::u32;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;

View file

@ -27,7 +27,9 @@ pub enum Buffer {
}, },
Metadata { Metadata {
frame: MetadataFrame, frame: MetadataFrame,
#[allow(unused)]
receive_time_gst: gst::ClockTime, receive_time_gst: gst::ClockTime,
#[allow(unused)]
receive_time_real: gst::ClockTime, receive_time_real: gst::ClockTime,
}, },
} }

View file

@ -226,8 +226,8 @@ pub enum NDIlib_frame_format_type_e {
NDIlib_frame_format_type_field_1 = 3, NDIlib_frame_format_type_field_1 = 3,
} }
pub const NDIlib_send_timecode_synthesize: i64 = ::std::i64::MAX; pub const NDIlib_send_timecode_synthesize: i64 = i64::MAX;
pub const NDIlib_recv_timestamp_undefined: i64 = ::std::i64::MAX; pub const NDIlib_recv_timestamp_undefined: i64 = i64::MAX;
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]

View file

@ -872,7 +872,7 @@ impl ElementImpl for RaptorqEnc {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::builder("application/x-rtp") let caps = gst::Caps::builder("application/x-rtp")
.field("clock-rate", gst::IntRange::new(0, std::i32::MAX)) .field("clock-rate", gst::IntRange::new(0, i32::MAX))
.build(); .build();
let srcpad_template = gst::PadTemplate::new( let srcpad_template = gst::PadTemplate::new(

View file

@ -9,7 +9,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; use std::time::Duration;
use std::u64;
use futures::future; use futures::future;
use futures::prelude::*; use futures::prelude::*;
@ -539,6 +538,8 @@ impl ReqwestHttpSrc {
.unwrap_or(false); .unwrap_or(false);
let seekable = size.is_some() && accept_byte_ranges; let seekable = size.is_some() && accept_byte_ranges;
#[allow(clippy::manual_unwrap_or_default)]
// https://github.com/rust-lang/rust-clippy/issues/12928
let position = if let Some((range_start, _)) = headers let position = if let Some((range_start, _)) = headers
.typed_get::<ContentRange>() .typed_get::<ContentRange>()
.and_then(|range| range.bytes_range()) .and_then(|range| range.bytes_range())

View file

@ -19,7 +19,6 @@ use byte_slice_cast::*;
use std::ops::Rem; use std::ops::Rem;
use std::sync::Mutex; use std::sync::Mutex;
use std::u32;
use num_traits::cast::NumCast; use num_traits::cast::NumCast;
use num_traits::float::Float; use num_traits::float::Float;

View file

@ -262,21 +262,21 @@ impl ObjectImpl for FallbackSrc {
glib::ParamSpecUInt64::builder("timeout") glib::ParamSpecUInt64::builder("timeout")
.nick("Timeout") .nick("Timeout")
.blurb("Timeout for switching to the fallback URI") .blurb("Timeout for switching to the fallback URI")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.default_value(5 * *gst::ClockTime::SECOND) .default_value(5 * *gst::ClockTime::SECOND)
.mutable_ready() .mutable_ready()
.build(), .build(),
glib::ParamSpecUInt64::builder("restart-timeout") glib::ParamSpecUInt64::builder("restart-timeout")
.nick("Timeout") .nick("Timeout")
.blurb("Timeout for restarting an active source") .blurb("Timeout for restarting an active source")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.default_value(5 * *gst::ClockTime::SECOND) .default_value(5 * *gst::ClockTime::SECOND)
.mutable_ready() .mutable_ready()
.build(), .build(),
glib::ParamSpecUInt64::builder("retry-timeout") glib::ParamSpecUInt64::builder("retry-timeout")
.nick("Retry Timeout") .nick("Retry Timeout")
.blurb("Timeout for stopping after repeated failure") .blurb("Timeout for stopping after repeated failure")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.default_value(60 * *gst::ClockTime::SECOND) .default_value(60 * *gst::ClockTime::SECOND)
.mutable_ready() .mutable_ready()
.build(), .build(),
@ -296,14 +296,14 @@ impl ObjectImpl for FallbackSrc {
.blurb("When the main source has a higher latency than the fallback source \ .blurb("When the main source has a higher latency than the fallback source \
this allows to configure a minimum latency that would be configured \ this allows to configure a minimum latency that would be configured \
if initially the fallback is enabled") if initially the fallback is enabled")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.mutable_ready() .mutable_ready()
.build(), .build(),
glib::ParamSpecInt64::builder("buffer-duration") glib::ParamSpecInt64::builder("buffer-duration")
.nick("Buffer Duration") .nick("Buffer Duration")
.blurb("Buffer duration when buffering streams (-1 default value)") .blurb("Buffer duration when buffering streams (-1 default value)")
.minimum(-1) .minimum(-1)
.maximum(std::i64::MAX - 1) .maximum(i64::MAX - 1)
.default_value(-1) .default_value(-1)
.mutable_ready() .mutable_ready()
.build(), .build(),

View file

@ -1329,21 +1329,21 @@ impl ObjectImpl for FallbackSwitch {
glib::ParamSpecUInt64::builder(PROP_TIMEOUT) glib::ParamSpecUInt64::builder(PROP_TIMEOUT)
.nick("Input timeout") .nick("Input timeout")
.blurb("Timeout on an input before switching to a lower priority input.") .blurb("Timeout on an input before switching to a lower priority input.")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.default_value(Settings::default().timeout.nseconds()) .default_value(Settings::default().timeout.nseconds())
.mutable_playing() .mutable_playing()
.build(), .build(),
glib::ParamSpecUInt64::builder(PROP_LATENCY) glib::ParamSpecUInt64::builder(PROP_LATENCY)
.nick("Latency") .nick("Latency")
.blurb("Additional latency in live mode to allow upstream to take longer to produce buffers for the current position (in nanoseconds)") .blurb("Additional latency in live mode to allow upstream to take longer to produce buffers for the current position (in nanoseconds)")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.default_value(Settings::default().latency.nseconds()) .default_value(Settings::default().latency.nseconds())
.mutable_ready() .mutable_ready()
.build(), .build(),
glib::ParamSpecUInt64::builder(PROP_MIN_UPSTREAM_LATENCY) glib::ParamSpecUInt64::builder(PROP_MIN_UPSTREAM_LATENCY)
.nick("Minimum Upstream Latency") .nick("Minimum Upstream Latency")
.blurb("When sources with a higher latency are expected to be plugged in dynamically after the fallbackswitch has started playing, this allows overriding the minimum latency reported by the initial source(s). This is only taken into account when larger than the actually reported minimum latency. (nanoseconds)") .blurb("When sources with a higher latency are expected to be plugged in dynamically after the fallbackswitch has started playing, this allows overriding the minimum latency reported by the initial source(s). This is only taken into account when larger than the actually reported minimum latency. (nanoseconds)")
.maximum(std::u64::MAX - 1) .maximum(u64::MAX - 1)
.default_value(Settings::default().min_upstream_latency.nseconds()) .default_value(Settings::default().min_upstream_latency.nseconds())
.mutable_ready() .mutable_ready()
.build(), .build(),

View file

@ -20,7 +20,6 @@ use once_cell::sync::Lazy;
use parking_lot::{Condvar, Mutex, MutexGuard}; use parking_lot::{Condvar, Mutex, MutexGuard};
use std::cmp; use std::cmp;
use std::collections::HashMap; use std::collections::HashMap;
use std::f64;
use std::iter; use std::iter;
use std::sync::Arc; use std::sync::Arc;

View file

@ -15,7 +15,6 @@ use crate::ccutils::{extract_cdp, ParseError, ParseErrorCode};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::sync::Mutex; use std::sync::Mutex;
use std::u64;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| { static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new( gst::DebugCategory::new(

View file

@ -1144,8 +1144,8 @@ impl ElementImpl for MccParse {
{ {
let caps = caps.get_mut().unwrap(); let caps = caps.get_mut().unwrap();
let framerate = gst::FractionRange::new( let framerate = gst::FractionRange::new(
gst::Fraction::new(1, std::i32::MAX), gst::Fraction::new(1, i32::MAX),
gst::Fraction::new(std::i32::MAX, 1), gst::Fraction::new(i32::MAX, 1),
); );
let s = gst::Structure::builder("closedcaption/x-cea-708") let s = gst::Structure::builder("closedcaption/x-cea-708")

View file

@ -1144,8 +1144,8 @@ impl ElementImpl for TtToCea608 {
.unwrap(); .unwrap();
let framerate = gst::FractionRange::new( let framerate = gst::FractionRange::new(
gst::Fraction::new(1, std::i32::MAX), gst::Fraction::new(1, i32::MAX),
gst::Fraction::new(std::i32::MAX, 1), gst::Fraction::new(i32::MAX, 1),
); );
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")

View file

@ -16,7 +16,6 @@ use gst_video::subclass::prelude::*;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::i32;
use std::sync::{Mutex, MutexGuard}; use std::sync::{Mutex, MutexGuard};
const DEFAULT_N_THREADS: u32 = 0; const DEFAULT_N_THREADS: u32 = 0;
@ -513,7 +512,7 @@ impl ObjectImpl for Dav1dDec {
.nick("Maximum frame delay") .nick("Maximum frame delay")
.blurb("Maximum delay in frames for the decoder (set to 1 for low latency, 0 to be equal to the number of logical cores. -1 to choose between these two based on pipeline liveness)") .blurb("Maximum delay in frames for the decoder (set to 1 for low latency, 0 to be equal to the number of logical cores. -1 to choose between these two based on pipeline liveness)")
.minimum(-1) .minimum(-1)
.maximum(std::u32::MAX.into()) .maximum(u32::MAX.into())
.default_value(DEFAULT_MAX_FRAME_DELAY) .default_value(DEFAULT_MAX_FRAME_DELAY)
.mutable_ready() .mutable_ready()
.build(), .build(),

View file

@ -150,7 +150,7 @@ impl ObjectImpl for GifEnc {
.nick("Repeat") .nick("Repeat")
.blurb("Repeat (-1 to loop forever, 0 .. n finite repetitions)") .blurb("Repeat (-1 to loop forever, 0 .. n finite repetitions)")
.minimum(-1) .minimum(-1)
.maximum(std::u16::MAX as i32) .maximum(u16::MAX as i32)
.default_value(DEFAULT_REPEAT) .default_value(DEFAULT_REPEAT)
.mutable_ready() .mutable_ready()
.build(), .build(),

View file

@ -292,7 +292,7 @@ impl ObjectImpl for Rav1Enc {
glib::ParamSpecUInt::builder("min-quantizer") glib::ParamSpecUInt::builder("min-quantizer")
.nick("Min Quantizer") .nick("Min Quantizer")
.blurb("Min Quantizer") .blurb("Min Quantizer")
.maximum(std::u8::MAX as u32) .maximum(u8::MAX as u32)
.default_value(DEFAULT_MIN_QUANTIZER as u32) .default_value(DEFAULT_MIN_QUANTIZER as u32)
.mutable_ready() .mutable_ready()
.build(), .build(),