Skip to content

Commit

Permalink
chore: Fix clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeljanov authored and a1phyr committed Oct 10, 2024
1 parent f6aaa12 commit efdeae7
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 24 deletions.
5 changes: 4 additions & 1 deletion symphonia-bundle-flac/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ rust-version = "1.53"
log = "0.4"
symphonia-core = { version = "0.5.4", path = "../symphonia-core" }
symphonia-metadata = { version = "0.5.4", path = "../symphonia-metadata" }
symphonia-utils-xiph = { version = "0.5.4", path = "../symphonia-utils-xiph" }
symphonia-utils-xiph = { version = "0.5.4", path = "../symphonia-utils-xiph" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
4 changes: 4 additions & 0 deletions symphonia-bundle-mp3/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ pub struct FrameHeader {
pub sample_rate: u32,
pub sample_rate_idx: usize,
pub channel_mode: ChannelMode,
#[allow(dead_code)]
pub emphasis: Emphasis,
#[allow(dead_code)]
pub is_copyrighted: bool,
#[allow(dead_code)]
pub is_original: bool,
#[allow(dead_code)]
pub has_padding: bool,
pub has_crc: bool,
pub frame_size: usize,
Expand Down
6 changes: 3 additions & 3 deletions symphonia-bundle-mp3/src/layer3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ struct GranuleChannel {
/// per scale factor.
///
/// - For MPEG1 bitstreams, `scalefac_compress` is a 4-bit index into
/// `SCALE_FACTOR_SLEN[0..16]` to obtain a number of bits per scale factor pair.
/// `SCALE_FACTOR_SLEN[0..16]` to obtain a number of bits per scale factor pair.
///
/// - For MPEG2/2.5 bitstreams, `scalefac_compress` is a 9-bit value that decodes into
/// `slen[0..3]` (referred to as slen1-4 in the standard) for the number of bits per scale
/// factor, and depending on which range the value falls into, for which bands.
/// `slen[0..3]` (referred to as slen1-4 in the standard) for the number of bits per scale
/// factor, and depending on which range the value falls into, for which bands.
scalefac_compress: u16,
/// Indicates the block type (type of window) for the channel in the granule.
block_type: BlockType,
Expand Down
2 changes: 0 additions & 2 deletions symphonia-codec-vorbis/src/codebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::usize;

use symphonia_core::errors::{decode_error, Result};
use symphonia_core::io::{
vlc::{BitOrder, Codebook, CodebookBuilder, Entry32x32},
Expand Down
4 changes: 2 additions & 2 deletions symphonia-core/src/io/media_source_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ impl SeekBuffered for MediaSourceStream {

// Forward seek.
let delta = if pos > old_pos {
assert!(pos - old_pos < std::isize::MAX as u64);
assert!(pos - old_pos < isize::MAX as u64);
(pos - old_pos) as isize
}
else if pos < old_pos {
// Backward seek.
assert!(old_pos - pos < std::isize::MAX as u64);
assert!(old_pos - pos < isize::MAX as u64);
-((old_pos - pos) as isize)
}
else {
Expand Down
2 changes: 1 addition & 1 deletion symphonia-core/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub trait SeekBuffered {
/// This function is identical to [`SeekBuffered::seek_buffered_rel`] when a negative delta is
/// provided.
fn seek_buffered_rev(&mut self, delta: usize) {
assert!(delta < std::isize::MAX as usize);
assert!(delta < isize::MAX as usize);
self.seek_buffered_rel(-(delta as isize));
}
}
Expand Down
4 changes: 2 additions & 2 deletions symphonia-core/src/io/scoped_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ impl<B: ReadBytes + SeekBuffered> SeekBuffered for ScopedStream<B> {
fn seek_buffered_rel(&mut self, delta: isize) -> u64 {
// Clamp the delta value such that the absolute position after the buffered seek will be
// within the bounds of the ScopedStream.
let max_back = self.read.min(std::isize::MAX as u64) as isize;
let max_forward = (self.len - self.read).min(std::isize::MAX as u64) as isize;
let max_back = self.read.min(isize::MAX as u64) as isize;
let max_forward = (self.len - self.read).min(isize::MAX as u64) as isize;
self.inner.seek_buffered_rel(delta.clamp(-max_back, max_forward))
}
}
7 changes: 3 additions & 4 deletions symphonia-format-caf/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ impl Chunk {
}
other => {
// Log unsupported chunk types but don't return an error
info!(
"unsupported chunk type ('{}')",
str::from_utf8(other.as_slice()).unwrap_or("????")
);
info!("unsupported chunk type ('{}')", str::from_utf8(other).unwrap_or("????"));

if chunk_size >= 0 {
reader.ignore_bytes(chunk_size as u64)?;
Expand Down Expand Up @@ -371,7 +368,9 @@ impl ChannelLayout {
#[derive(Debug)]
pub struct ChannelDescription {
pub channel_label: u32,
#[allow(dead_code)]
pub channel_flags: u32,
#[allow(dead_code)]
pub coordinates: [f32; 3],
}

Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/edts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader, AtomIterator, AtomType, ElstAtom};

/// Edits atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct EdtsAtom {
header: AtomHeader,
Expand Down
2 changes: 2 additions & 0 deletions symphonia-format-isomp4/src/atoms/esds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class ES_Descriptor extends BaseDescriptor : bit(8) tag=ES_DescrTag {
}
*/

#[allow(dead_code)]
#[derive(Debug)]
pub struct ESDescriptor {
pub es_id: u16,
Expand Down Expand Up @@ -202,6 +203,7 @@ class DecoderConfigDescriptor extends BaseDescriptor : bit(8) tag=DecoderConfigD
}
*/

#[allow(dead_code)]
#[derive(Debug)]
pub struct DecoderConfigDescriptor {
pub codec_type: CodecType,
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/ftyp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::atoms::{Atom, AtomHeader};
use crate::fourcc::FourCc;

/// File type atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct FtypAtom {
header: AtomHeader,
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/hdlr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum HandlerType {
}

/// Handler atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct HdlrAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/ilst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use encoding_rs::{SHIFT_JIS, UTF_16BE};
use log::warn;

/// Data type enumeration for metadata value atoms as defined in the QuickTime File Format standard.
#[allow(dead_code)]
#[derive(Debug, Copy, Clone)]
pub enum DataType {
AffineTransformF64,
Expand Down
2 changes: 1 addition & 1 deletion symphonia-format-isomp4/src/atoms/mdhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Atom for MdhdAtom {
mdhd.timescale = reader.read_be_u32()?;
// 0xffff_ffff is a special case.
mdhd.duration = match reader.read_be_u32()? {
std::u32::MAX => std::u64::MAX,
u32::MAX => u64::MAX,
duration => u64::from(duration),
};
}
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/mdia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use symphonia_core::io::ReadBytes;

use crate::atoms::{Atom, AtomHeader, AtomIterator, AtomType, HdlrAtom, MdhdAtom, MinfAtom};

#[allow(dead_code)]
#[derive(Debug)]
pub struct MdiaAtom {
header: AtomHeader,
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/mehd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader};

/// Movie extends header atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct MehdAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/minf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader, AtomIterator, AtomType, SmhdAtom, StblAtom};

/// Media information atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct MinfAtom {
/// Atom header.
Expand Down
3 changes: 2 additions & 1 deletion symphonia-format-isomp4/src/atoms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ impl AtomHeader {
}

pub trait Atom: Sized {
#[allow(dead_code)]
fn header(&self) -> AtomHeader;

fn read<B: ReadBytes>(reader: &mut B, header: AtomHeader) -> Result<Self>;
Expand Down Expand Up @@ -442,7 +443,7 @@ impl<B: ReadBytes> AtomIterator<B> {
// An atom with a length of zero is defined to span to the end of the stream. If
// len is available, use it for the next atom start position, otherwise, use u64 max
// which will trip an end of stream error on the next iteration.
self.len.map(|l| self.base_pos + l).unwrap_or(std::u64::MAX)
self.len.map(|l| self.base_pos + l).unwrap_or(u64::MAX)
}

len => self.next_atom_pos + len,
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/moov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::atoms::{
use log::warn;

/// Movie atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct MoovAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/mvex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader, AtomIterator, AtomType, MehdAtom, TrexAtom};

/// Movie extends atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct MvexAtom {
/// Atom header.
Expand Down
2 changes: 1 addition & 1 deletion symphonia-format-isomp4/src/atoms/mvhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Atom for MvhdAtom {
mvhd.timescale = reader.read_be_u32()?;
// 0xffff_ffff is a special case.
mvhd.duration = match reader.read_be_u32()? {
std::u32::MAX => std::u64::MAX,
u32::MAX => u64::MAX,
duration => u64::from(duration),
};
}
Expand Down
2 changes: 2 additions & 0 deletions symphonia-format-isomp4/src/atoms/sidx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum ReferenceType {
Media,
}

#[allow(dead_code)]
#[derive(Debug)]
pub struct SidxReference {
pub reference_type: ReferenceType,
Expand All @@ -27,6 +28,7 @@ pub struct SidxReference {
}

/// Segment index atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct SidxAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/smhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::atoms::{Atom, AtomHeader};
use crate::fp::FpI8;

/// Sound header atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct SmhdAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/stsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use symphonia_core::io::ReadBytes;

use crate::atoms::{Atom, AtomHeader};

#[allow(dead_code)]
#[derive(Debug)]
pub struct StscEntry {
pub first_chunk: u32,
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/stsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ pub enum AudioCodecSpecific {
Pcm(Pcm),
}

#[allow(dead_code)]
#[derive(Debug)]
pub struct AudioSampleEntry {
pub num_channels: u32,
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/tfhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader};

/// Track fragment header atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct TfhdAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/tkhd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::atoms::{Atom, AtomHeader};
use crate::fp::FpU8;

/// Track header atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct TkhdAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/trak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader, AtomIterator, AtomType, EdtsAtom, MdiaAtom, TkhdAtom};

/// Track atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct TrakAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/trex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use symphonia_core::io::ReadBytes;
use crate::atoms::{Atom, AtomHeader};

/// Track extends atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct TrexAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-isomp4/src/atoms/trun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use symphonia_core::util::bits;
use crate::atoms::{Atom, AtomHeader};

/// Track fragment run atom.
#[allow(dead_code)]
#[derive(Debug)]
pub struct TrunAtom {
/// Atom header.
Expand Down
1 change: 1 addition & 0 deletions symphonia-format-mkv/src/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ impl<R: ReadBytes> ElementIterator<R> {
}

/// An EBML element data.
#[allow(dead_code)]
#[derive(Clone, Debug)]
pub(crate) enum ElementData {
/// A binary buffer.
Expand Down
5 changes: 4 additions & 1 deletion symphonia-format-ogg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ rust-version = "1.53"
log = "0.4"
symphonia-core = { version = "0.5.4", path = "../symphonia-core" }
symphonia-metadata = { version = "0.5.4", path = "../symphonia-metadata" }
symphonia-utils-xiph = { version = "0.5.4", path = "../symphonia-utils-xiph" }
symphonia-utils-xiph = { version = "0.5.4", path = "../symphonia-utils-xiph" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
1 change: 1 addition & 0 deletions symphonia-format-ogg/src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub const OGG_PAGE_MAX_SIZE: usize = OGG_PAGE_HEADER_SIZE + 255 + 255 * 255;

#[derive(Copy, Clone, Default)]
pub struct PageHeader {
#[allow(dead_code)]
pub version: u8,
pub absgp: u64,
pub serial: u32,
Expand Down
3 changes: 3 additions & 0 deletions symphonia-format-riff/src/aiff/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct CommonChunk {
/// The number of channels.
pub n_channels: i16,
/// The number of audio frames.
#[allow(dead_code)]
pub n_sample_frames: u32,
/// The sample size in bits.
pub sample_size: i16,
Expand Down Expand Up @@ -251,7 +252,9 @@ impl CommonChunkParser for ChunkParser<CommonChunk> {
/// `SoundChunk` is a required AIFF chunk, containing the audio data.
pub struct SoundChunk {
pub len: u32,
#[allow(dead_code)]
pub offset: u32,
#[allow(dead_code)]
pub block_size: u32,
}

Expand Down
8 changes: 4 additions & 4 deletions symphonia-play/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ mod pulseaudio {
// attributes for very short audio streams.
//
// let pa_buf_attr = pulse::def::BufferAttr {
// maxlength: std::u32::MAX,
// maxlength: u32::MAX,
// tlength: 1024,
// prebuf: std::u32::MAX,
// minreq: std::u32::MAX,
// fragsize: std::u32::MAX,
// prebuf: u32::MAX,
// minreq: u32::MAX,
// fragsize: u32::MAX,
// };

// Create a PulseAudio connection.
Expand Down
2 changes: 1 addition & 1 deletion symphonia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
//! 4. Instantiate a [`MediaSourceStream`][core::io::MediaSourceStream] with the `MediaSource`
//! above.
//! 5. Using the `Probe`, call [`format`][core::probe::Probe::format] and pass it the
//! `MediaSourceStream`.
//! `MediaSourceStream`.
//! 6. If the probe successfully detects a compatible format, a `FormatReader` will be returned.
//! This is an instance of a demuxer that can read and demux the provided source into
//! [`Packet`][core::formats::Packet]s.
Expand Down

0 comments on commit efdeae7

Please sign in to comment.