Skip to content

Commit

Permalink
Apply clippy lint suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
onethumb committed Sep 7, 2024
1 parent 3189b5b commit 18dcbf5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/bin/calculate_pclmulqdq_artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ fn main() {
}

let polynomial = u64::from_str_radix(
&args[1].trim_start_matches("0x"), 16
args[1].trim_start_matches("0x"), 16
).expect("Failed to parse polynomial");

for (_, &size) in KEY_SIZES.iter().enumerate() {
for &size in KEY_SIZES.iter() {
println!("k_{} = 0x{:x}", size, generate_key(size as u64, polynomial));
}

Expand Down
12 changes: 6 additions & 6 deletions src/bin/crc_64_nvme_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn calculate_crc_64_simd_from_file(file: &str) -> u64 {

c.write(std::fs::read(file).unwrap().as_slice());

return c.sum64();
c.sum64()
}

fn calculate_crc_64_validate_from_file(file: &str) -> u64 {
Expand All @@ -32,15 +32,15 @@ fn calculate_crc_64_validate_from_file(file: &str) -> u64 {

digest.update(std::fs::read(file).unwrap().as_slice());

return digest.finalize();
digest.finalize()
}

fn calculate_crc_64_simd_from_string(input: &str) -> u64 {
let mut c = Digest::new();

c.write(input.as_bytes());

return c.sum64();
c.sum64()
}

fn calculate_crc_64_validate_from_string(input: &str) -> u64 {
Expand All @@ -50,7 +50,7 @@ fn calculate_crc_64_validate_from_string(input: &str) -> u64 {

digest.update(input.as_bytes());

return digest.finalize();
digest.finalize()
}

fn main() -> ExitCode {
Expand All @@ -70,7 +70,7 @@ fn main() -> ExitCode {
if "--file" == input_type {
let file = &args[2];

if false == fs::metadata(file).is_ok() {
if fs::metadata(file).is_err() {
println!("Couldn't open file {}", file);

return ExitCode::from(1);
Expand Down Expand Up @@ -107,5 +107,5 @@ fn main() -> ExitCode {

println!("An error occurred, likely due to bad command-line arguments.");

return ExitCode::from(1);
ExitCode::from(1)
}
13 changes: 6 additions & 7 deletions src/pclmulqdq/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! AArch64 implementation of the PCLMULQDQ-based CRC calculation.
use std::arch::{aarch64::*, is_aarch64_feature_detected};
use std::mem::transmute;
use std::ops::BitXor;

#[repr(transparent)]
Expand Down Expand Up @@ -68,18 +67,18 @@ impl super::SimdExt for Simd {
#[target_feature(enable = "neon")]
unsafe fn fold_8(self, coeff: u64) -> Self {
let [x0, x1] = self.into_poly64s();
let h = Self::from_mul(transmute(coeff), x0);
let l = Self::new(0, transmute(x1));
let h = Self::from_mul(coeff, x0);
let l = Self::new(0, x1);
h ^ l
}

#[inline]
#[target_feature(enable = "neon")]
unsafe fn barrett(self, poly: u64, mu: u64) -> u64 {
let t1 = Self::from_mul(self.low_64(), transmute(mu)).low_64();
let l = Self::from_mul(t1, transmute(poly));
let reduced: u64 = transmute((self ^ l).high_64());
let t1: u64 = transmute(t1);
let t1 = Self::from_mul(self.low_64(), mu).low_64();
let l = Self::from_mul(t1, poly);
let reduced: u64 = (self ^ l).high_64();
let t1: u64 = t1;
reduced ^ t1
}
}
Expand Down

0 comments on commit 18dcbf5

Please sign in to comment.