mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-13 14:12:31 +00:00
Add some more lints
This commit is contained in:
parent
a1463f3985
commit
2b2b6d2532
11 changed files with 19 additions and 18 deletions
|
@ -284,7 +284,7 @@ where
|
|||
|
||||
if let Ok(len) = u16::try_from(comment_count) {
|
||||
text_chunks.extend(b"COMT");
|
||||
text_chunks.extend((len as u16).to_be_bytes());
|
||||
text_chunks.extend(len.to_be_bytes());
|
||||
|
||||
for comt in comments {
|
||||
text_chunks.extend(comt.timestamp.to_be_bytes());
|
||||
|
@ -386,10 +386,10 @@ where
|
|||
let first = chunks_remove.pop().unwrap(); // Infallible
|
||||
|
||||
for (s, e) in &chunks_remove {
|
||||
file_bytes.drain(*s as usize..*e as usize);
|
||||
file_bytes.drain(*s..*e);
|
||||
}
|
||||
|
||||
file_bytes.splice(first.0 as usize..first.1 as usize, text_chunks);
|
||||
file_bytes.splice(first.0..first.1, text_chunks);
|
||||
}
|
||||
|
||||
let total_size = ((file_bytes.len() - 8) as u32).to_be_bytes();
|
||||
|
|
|
@ -134,7 +134,11 @@
|
|||
clippy::all,
|
||||
missing_docs,
|
||||
rustdoc::broken_intra_doc_links,
|
||||
rust_2018_idioms
|
||||
rust_2018_idioms,
|
||||
trivial_casts,
|
||||
trivial_numeric_casts,
|
||||
unused_import_braces,
|
||||
explicit_outlives_requirements
|
||||
)]
|
||||
// TODO: This had multiple FPs right now, remove this when it is fixed
|
||||
#![allow(clippy::needless_borrow)]
|
||||
|
|
|
@ -116,7 +116,7 @@ pub(super) fn read_properties(
|
|||
overall_bitrate: 0,
|
||||
audio_bitrate: 0,
|
||||
sample_rate: first_frame_header.sample_rate,
|
||||
channels: first_frame_header.channels as u8,
|
||||
channels: first_frame_header.channels,
|
||||
emphasis: first_frame_header.emphasis,
|
||||
};
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ where
|
|||
duration,
|
||||
overall_bitrate,
|
||||
audio_bitrate,
|
||||
sample_rate: Some(sample_rate as u32),
|
||||
sample_rate: Some(sample_rate),
|
||||
bit_depth: Some(bits_per_sample as u8),
|
||||
channels: Some(channels as u8),
|
||||
})
|
||||
|
|
|
@ -64,7 +64,7 @@ where
|
|||
let mut first_byte = 0_u8;
|
||||
first_byte |= last_block_info.0 & 0x7F;
|
||||
|
||||
file_bytes[last_block_info.1 as usize] = first_byte;
|
||||
file_bytes[last_block_info.1] = first_byte;
|
||||
|
||||
let mut padding_block = [0; 1028];
|
||||
let mut padding_byte = 0;
|
||||
|
@ -76,10 +76,7 @@ where
|
|||
// [0, 4, 0] = 1024
|
||||
padding_block[2] = 4;
|
||||
|
||||
file_bytes.splice(
|
||||
last_block_info.2 as usize..last_block_info.2 as usize,
|
||||
padding_block,
|
||||
);
|
||||
file_bytes.splice(last_block_info.2..last_block_info.2, padding_block);
|
||||
}
|
||||
|
||||
let mut comment_blocks = Cursor::new(Vec::new());
|
||||
|
|
|
@ -99,7 +99,7 @@ where
|
|||
|
||||
if let Some(frame_count) = last_page_abgp.checked_sub(first_page_abgp + u64::from(pre_skip)) {
|
||||
let length = frame_count * 1000 / 48000;
|
||||
properties.duration = Duration::from_millis(length as u64);
|
||||
properties.duration = Duration::from_millis(length);
|
||||
|
||||
properties.overall_bitrate = ((file_length * 8) / length) as u32;
|
||||
properties.audio_bitrate = (audio_size * 8 / length) as u32;
|
||||
|
|
|
@ -140,7 +140,7 @@ where
|
|||
if let Some(frame_count) = last_page_abgp.checked_sub(first_page_abgp) {
|
||||
if properties.sample_rate > 0 {
|
||||
let length = frame_count * 1000 / u64::from(properties.sample_rate);
|
||||
properties.duration = Duration::from_millis(length as u64);
|
||||
properties.duration = Duration::from_millis(length);
|
||||
|
||||
properties.overall_bitrate = ((file_length * 8) / length) as u32;
|
||||
properties.audio_bitrate = (properties.nominal_bitrate as u64 / 1000) as u32;
|
||||
|
|
|
@ -114,7 +114,7 @@ where
|
|||
if let Some(frame_count) = last_page_abgp.checked_sub(first_page_abgp) {
|
||||
if properties.sample_rate > 0 {
|
||||
let length = frame_count * 1000 / u64::from(properties.sample_rate);
|
||||
properties.duration = Duration::from_millis(length as u64);
|
||||
properties.duration = Duration::from_millis(length);
|
||||
|
||||
properties.overall_bitrate = ((file_length * 8) / length) as u32;
|
||||
properties.audio_bitrate = (properties.bitrate_nominal as u64 / 1000) as u32;
|
||||
|
|
|
@ -37,7 +37,7 @@ pub(crate) fn write_to(
|
|||
let p = Page::read(data, false)?;
|
||||
|
||||
if p.header_type() & 0x01 != 1 {
|
||||
data.seek(SeekFrom::Start(p.start as u64))?;
|
||||
data.seek(SeekFrom::Start(p.start))?;
|
||||
data.read_to_end(&mut remaining)?;
|
||||
|
||||
reached_md_end = true;
|
||||
|
|
|
@ -200,7 +200,7 @@ where
|
|||
}
|
||||
|
||||
data.seek(SeekFrom::Start(0))?;
|
||||
data.set_len(first_page.end as u64)?;
|
||||
data.set_len(first_page.end)?;
|
||||
data.write_all(&*writer)?;
|
||||
|
||||
Ok(())
|
||||
|
@ -218,7 +218,7 @@ fn replace_packet(
|
|||
let p = Page::read(data, true)?;
|
||||
|
||||
if p.header_type() & 0x01 != 0x01 {
|
||||
data.seek(SeekFrom::Start(p.start as u64))?;
|
||||
data.seek(SeekFrom::Start(p.start))?;
|
||||
reached_md_end = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -803,7 +803,7 @@ impl Picture {
|
|||
size -= 20;
|
||||
|
||||
if data_len <= size {
|
||||
let mut data = try_vec![0; data_len as usize];
|
||||
let mut data = try_vec![0; data_len];
|
||||
|
||||
if let Ok(()) = reader.read_exact(&mut data) {
|
||||
return Ok((
|
||||
|
|
Loading…
Reference in a new issue