From ae39434eff9ed2be8bfd7fa682f3b05ad207868c Mon Sep 17 00:00:00 2001 From: user Date: Fri, 19 Aug 2022 15:14:26 +0200 Subject: [PATCH 1/2] Fix lints --- curve25519-parser/src/lib.rs | 4 ++-- mla/benches/bench_archive.rs | 4 ++-- mla/src/lib.rs | 9 ++++----- mla/tests/aes_gcm_navs_test_vector.rs | 4 ++-- mlar/tests/integration.rs | 13 ++++++------- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/curve25519-parser/src/lib.rs b/curve25519-parser/src/lib.rs index 391baed..9b6b39a 100644 --- a/curve25519-parser/src/lib.rs +++ b/curve25519-parser/src/lib.rs @@ -422,14 +422,14 @@ mod tests { let pub_pem_key = keypair.public_as_pem(); assert_eq!( - parse_openssl_25519_pubkey(&pub_pem_key.as_bytes()) + parse_openssl_25519_pubkey(pub_pem_key.as_bytes()) .unwrap() .as_bytes(), pub_key.as_bytes() ); let priv_pem_key = keypair.private_as_pem(); assert_eq!( - &parse_openssl_25519_privkey(&priv_pem_key.as_bytes()) + &parse_openssl_25519_privkey(priv_pem_key.as_bytes()) .unwrap() .to_bytes(), &priv_key.to_bytes() diff --git a/mla/benches/bench_archive.rs b/mla/benches/bench_archive.rs index e5a3dbe..e050bbc 100644 --- a/mla/benches/bench_archive.rs +++ b/mla/benches/bench_archive.rs @@ -47,7 +47,7 @@ pub fn multiple_layers_multiple_block_size(c: &mut Criterion) { let data: Vec = Alphanumeric .sample_iter(&mut rng) - .take(size.clone()) + .take(*size) .map(|c| c as u8) .collect(); @@ -98,7 +98,7 @@ pub fn multiple_compression_quality(c: &mut Criterion) { let data: Vec = Alphanumeric .sample_iter(&mut rng) - .take(size.clone()) + .take(size) .map(|c| c as u8) .collect(); diff --git a/mla/src/lib.rs b/mla/src/lib.rs index 9f34eb8..83fb383 100644 --- a/mla/src/lib.rs +++ b/mla/src/lib.rs @@ -835,7 +835,7 @@ impl<'a, T: Read + Seek> Read for BlocksToFileReader<'a, T> { } #[derive(Serialize, Deserialize)] -#[cfg_attr(test, derive(PartialEq, Debug))] +#[cfg_attr(test, derive(PartialEq, Eq, Debug))] pub struct FileInfo { /// File information to save in the footer /// @@ -1235,7 +1235,6 @@ impl<'b, R: 'b + Read> ArchiveFailSafeReader<'b, R> { pub(crate) mod tests { use super::*; use curve25519_parser::{parse_openssl_25519_privkey, parse_openssl_25519_pubkey}; - use hex; use rand::distributions::{Distribution, Standard}; use rand::{RngCore, SeedableRng}; use rand_chacha::ChaChaRng; @@ -1938,7 +1937,7 @@ pub(crate) mod tests { .rev() .map(|i| { let id = name2id.get(&fnames[i]).unwrap(); - mla.append_file_content(id.clone(), 32, &files.get(&fnames[i]).unwrap()[..32]) + mla.append_file_content(*id, 32, &files.get(&fnames[i]).unwrap()[..32]) .unwrap(); }) .for_each(drop); @@ -1948,7 +1947,7 @@ pub(crate) mod tests { .map(|i| { let id = name2id.get(&fnames[i]).unwrap(); let data = &files.get(&fnames[i]).unwrap()[32..]; - mla.append_file_content(id.clone(), data.len() as u64, data) + mla.append_file_content(*id, data.len() as u64, data) .unwrap(); }) .for_each(drop); @@ -1958,7 +1957,7 @@ pub(crate) mod tests { .rev() .map(|i| { let id = name2id.get(&fnames[i]).unwrap(); - mla.end_file(id.clone()).unwrap(); + mla.end_file(*id).unwrap(); }) .for_each(drop); diff --git a/mla/tests/aes_gcm_navs_test_vector.rs b/mla/tests/aes_gcm_navs_test_vector.rs index d2376aa..3f7c480 100644 --- a/mla/tests/aes_gcm_navs_test_vector.rs +++ b/mla/tests/aes_gcm_navs_test_vector.rs @@ -3027,9 +3027,9 @@ fn test_nist_cavs_vectors() { for tv in TEST_VECTORS { // Full (all at once) let mut key = Key::default(); - key.copy_from_slice(&tv.key); + key.copy_from_slice(tv.key); let mut nonce = Nonce::default(); - nonce.copy_from_slice(&tv.nonce); + nonce.copy_from_slice(tv.nonce); let mut cipher = AesGcm256::new(&key, &nonce, tv.aad).unwrap(); let mut buffer = tv.plaintext.to_vec(); cipher.encrypt(&mut buffer); diff --git a/mlar/tests/integration.rs b/mlar/tests/integration.rs index 4e1dd37..d85489a 100644 --- a/mlar/tests/integration.rs +++ b/mlar/tests/integration.rs @@ -1,6 +1,5 @@ use assert_cmd::Command; use assert_fs::fixture::{FileWriteBin, NamedTempFile, TempDir}; -use glob; use permutate::Permutator; use rand::distributions::{Alphanumeric, Distribution, Standard}; use rand::rngs::StdRng; @@ -298,7 +297,7 @@ fn test_create_list_tar() { assert.success(); // Inspect the created TAR file - ensure_tar_content(&tar_file.path(), &testfs.files); + ensure_tar_content(tar_file.path(), &testfs.files); } #[test] @@ -560,8 +559,8 @@ fn test_multiple_compression_level() { let assert = cmd.assert(); assert.success(); } - ensure_tar_content(&tar_file_q0.path(), &testfs.files); - ensure_tar_content(&tar_file_q5.path(), &testfs.files); + ensure_tar_content(tar_file_q0.path(), &testfs.files); + ensure_tar_content(tar_file_q5.path(), &testfs.files); } #[test] @@ -635,7 +634,7 @@ fn test_convert() { assert.success(); // Inspect the created TAR file - ensure_tar_content(&tar_file.path(), &testfs.files); + ensure_tar_content(tar_file.path(), &testfs.files); } #[test] @@ -687,7 +686,7 @@ fn test_stdio() { assert.success(); // Inspect the created TAR file - ensure_tar_content(&tar_file.path(), &testfs.files); + ensure_tar_content(tar_file.path(), &testfs.files); } #[test] @@ -748,7 +747,7 @@ fn test_multi_fileorders() { assert.success(); // Inspect the created TAR file - ensure_tar_content(&tar_file.path(), &testfs.files); + ensure_tar_content(tar_file.path(), &testfs.files); } } From e4d4525ee792fa94a1c3afd000e96ff7ad031d8a Mon Sep 17 00:00:00 2001 From: user Date: Fri, 19 Aug 2022 15:47:50 +0200 Subject: [PATCH 2/2] Check clippy lints for all targets --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a057ae4..2f0b1e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -174,4 +174,4 @@ jobs: - uses: actions-rs/cargo@v1 with: command: clippy - args: -- -D warnings + args: --all-targets -- -D warnings