Fix a lot of Clippy warnings (#1808)

* fix a lot of clippy warnings

* fix more clippy warnings

* fix yet more clippy warnings

* bump msrv to 1.70.0 to silence warnings

* fix a lot of clippy warnings

* fix more clippy warnings

* fix yet more clippy warnings

* fix a few more warnings

* fix a clippy warning

* remove a commented out line

* silense too many arguments error

* fix more clippy warnings

* prefix underscore to unused vars/functions to fix warnings

* use filter instead of map

* move raw-rs-tests feature flat to module level to fix unused imports warnings

* fix a couple of unused result warnings

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Raminder Singh
2024-07-09 17:32:52 +05:30
committed by GitHub
parent f7ada701e5
commit 62f73df048
49 changed files with 264 additions and 260 deletions

View File

@@ -30,7 +30,7 @@ pub fn decode<R: Read + Seek>(ifd: Ifd, file: &mut TiffRead<R>) -> RawImage {
let image_width: usize = ifd.image_width.try_into().unwrap();
let image_height: usize = ifd.image_height.try_into().unwrap();
let bits_per_sample: usize = ifd.bits_per_sample.into();
let _bits_per_sample: usize = ifd.bits_per_sample.into();
let [cfa_pattern_width, cfa_pattern_height] = ifd.cfa_pattern_dim;
assert!(cfa_pattern_width == 2 && cfa_pattern_height == 2);
@@ -81,10 +81,10 @@ fn sony_arw2_load_raw<R: Read + Seek>(width: usize, height: usize, curve: CurveL
let max_minus_min = max as i32 - min as i32;
let shift_by_bits = (0..4).find(|&shift| (0x80 << shift) > max_minus_min).unwrap_or(4);
let mut pixel = [0_u16; 16];
let mut pixels = [0_u16; 16];
let mut bit = 30;
for i in 0..16 {
pixel[i] = match () {
for (i, pixel) in pixels.iter_mut().enumerate() {
*pixel = match () {
_ if i as u32 == index_to_set_max => max,
_ if i as u32 == index_to_set_min => min,
_ => {
@@ -98,7 +98,7 @@ fn sony_arw2_load_raw<R: Read + Seek>(width: usize, height: usize, curve: CurveL
};
}
for value in pixel {
for value in pixels {
image[row * width + column] = curve.get((value << 1).into()) >> 2;
// Skip between interlaced columns

View File

@@ -29,7 +29,7 @@ pub fn decode<R: Read + Seek>(ifd: Ifd, file: &mut TiffRead<R>) -> RawImage {
let image_width: usize = ifd.image_width.try_into().unwrap();
let image_height: usize = ifd.image_height.try_into().unwrap();
let rows_per_strip: usize = ifd.rows_per_strip.try_into().unwrap();
let bits_per_sample: usize = ifd.bits_per_sample.into();
let _bits_per_sample: usize = ifd.bits_per_sample.into();
let [cfa_pattern_width, cfa_pattern_height] = ifd.cfa_pattern_dim;
assert!(cfa_pattern_width == 2 && cfa_pattern_height == 2);

View File

@@ -106,7 +106,7 @@ impl Ifd {
})
}
fn next_ifd<R: Read + Seek>(&self, file: &mut TiffRead<R>) -> Result<Self, TiffError> {
fn _next_ifd<R: Read + Seek>(&self, file: &mut TiffRead<R>) -> Result<Self, TiffError> {
Ifd::new_from_offset(file, self.next_ifd_offset.unwrap_or(0))
}

View File

@@ -270,7 +270,7 @@ impl PrimitiveType for TypeIfd {
fn read_primitive<R: Read + Seek>(the_type: IfdTagType, file: &mut TiffRead<R>) -> Result<Self::Output, TiffError> {
let offset = TypeLong::read_primitive(the_type, file)?;
Ok(Ifd::new_from_offset(file, offset)?)
Ifd::new_from_offset(file, offset)
}
}
@@ -284,7 +284,7 @@ impl<T: PrimitiveType> TagType for T {
type Output = T::Output;
fn read<R: Read + Seek>(file: &mut TiffRead<R>) -> Result<Self::Output, TiffError> {
let the_type = IfdTagType::try_from(file.read_u16()?).map_err(|_| TiffError::InvalidType)?;
let the_type = IfdTagType::from(file.read_u16()?);
let count = file.read_u32()?;
if count != 1 {
@@ -313,7 +313,7 @@ impl<T: PrimitiveType> TagType for Array<T> {
type Output = Vec<T::Output>;
fn read<R: Read + Seek>(file: &mut TiffRead<R>) -> Result<Self::Output, TiffError> {
let the_type = IfdTagType::try_from(file.read_u16()?).map_err(|_| TiffError::InvalidType)?;
let the_type = IfdTagType::from(file.read_u16()?);
let count = file.read_u32()?;
let size = T::get_size(the_type).ok_or(TiffError::InvalidType)?;
@@ -334,7 +334,7 @@ impl<T: PrimitiveType, const N: usize> TagType for ConstArray<T, N> {
type Output = [T::Output; N];
fn read<R: Read + Seek>(file: &mut TiffRead<R>) -> Result<Self::Output, TiffError> {
let the_type = IfdTagType::try_from(file.read_u16()?).map_err(|_| TiffError::InvalidType)?;
let the_type = IfdTagType::from(file.read_u16()?);
let count = file.read_u32()?;
if count != N.try_into()? {

View File

@@ -1,3 +1,4 @@
#![cfg(feature = "raw-rs-tests")]
use std::collections::HashMap;
use std::fmt::Write;
use std::fs::{read_dir, File};
@@ -13,7 +14,6 @@ const BASE_URL: &str = "https://static.graphite.rs/test-data/libraries/raw-rs/";
const BASE_PATH: &str = "./tests/images";
#[test]
#[cfg(feature = "raw-rs-tests")]
fn test_images_match_with_libraw() {
download_images();
@@ -30,7 +30,7 @@ fn test_images_match_with_libraw() {
print!("{} => ", path.display());
let raw_image = match test_raw_data(&content) {
let _raw_image = match test_raw_data(&content) {
Err(err_msg) => {
failed_tests += 1;
return println!("{}", err_msg);
@@ -54,7 +54,6 @@ fn test_images_match_with_libraw() {
}
}
#[cfg(feature = "raw-rs-tests")]
fn download_images() {
let mut path = Path::new(BASE_PATH).to_owned();
let mut downloads: Vec<Download> = Vec::new();
@@ -75,7 +74,6 @@ fn download_images() {
}
}
#[cfg(feature = "raw-rs-tests")]
fn test_raw_data(content: &[u8]) -> Result<RawImage, String> {
let processor = libraw::Processor::new();
let libraw_raw_image = processor.decode(content).unwrap();
@@ -149,8 +147,7 @@ fn test_raw_data(content: &[u8]) -> Result<RawImage, String> {
Ok(raw_image)
}
#[cfg(feature = "raw-rs-tests")]
fn test_final_image(content: &[u8], raw_image: RawImage) -> Result<(), String> {
fn _test_final_image(content: &[u8], raw_image: RawImage) -> Result<(), String> {
let processor = libraw::Processor::new();
let libraw_image = processor.process_8bit(content).unwrap();