Skip to content

Commit

Permalink
linting: Comply with the unused_qualifications lint level
Browse files Browse the repository at this point in the history
Fix the issues shown by this lint when running the
"Check that the fuzz testing framework is still working" test.

Signed-off-by: Tomás González <[email protected]>
  • Loading branch information
tgonzalezorlandoarm committed Mar 14, 2024
1 parent 6cf4ad5 commit 3726930
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 25 deletions.
1 change: 0 additions & 1 deletion e2e_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
Expand Down
1 change: 0 additions & 1 deletion e2e_tests/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
Expand Down
1 change: 0 additions & 1 deletion fuzz/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
Expand Down
1 change: 0 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
Expand Down
10 changes: 5 additions & 5 deletions src/key_info_managers/on_disk_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ impl ApplicationName {
}

#[allow(deprecated)]
impl std::fmt::Display for ApplicationName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl fmt::Display for ApplicationName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.name)
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ impl fmt::Display for KeyTriple {
impl TryFrom<KeyIdentity> for KeyTriple {
type Error = String;

fn try_from(key_identity: KeyIdentity) -> ::std::result::Result<Self, Self::Error> {
fn try_from(key_identity: KeyIdentity) -> std::result::Result<Self, Self::Error> {
let provider_id = match key_identity.provider.uuid().as_str() {
CoreProvider::PROVIDER_UUID => Ok(ProviderId::Core),
#[cfg(feature = "cryptoauthlib-provider")]
Expand Down Expand Up @@ -188,7 +188,7 @@ impl TryFrom<(KeyTriple, ProviderIdentity, AuthType)> for KeyIdentity {

fn try_from(
(key_triple, provider_identity, auth_type): (KeyTriple, ProviderIdentity, AuthType),
) -> ::std::result::Result<Self, Self::Error> {
) -> std::result::Result<Self, Self::Error> {
// Result types required by clippy as Err result has the possibility of not being compiled.
let provider_uuid = match key_triple.provider_id {
ProviderId::Core => Ok::<String, Self::Error>(
Expand Down Expand Up @@ -489,7 +489,7 @@ impl OnDiskKeyInfoManager {
fs::remove_file(&key_name_file_path)?;
}

let mut mapping_file = fs::File::create(&key_name_file_path).map_err(|e| {
let mut mapping_file = File::create(&key_name_file_path).map_err(|e| {
error!(
"Failed to create Key Info Mapping file at {:?}",
key_name_file_path
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
Expand Down
2 changes: 1 addition & 1 deletion src/providers/cryptoauthlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ impl ProviderBuilder {
};
Provider::new(
self.provider_name.ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::InvalidData, "missing provider name")
std::io::Error::new(ErrorKind::InvalidData, "missing provider name")
})?,
self.key_info_store
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "missing key info store"))?,
Expand Down
4 changes: 2 additions & 2 deletions src/providers/mbed_crypto/key_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl Provider {
.expect("Grabbing key handle mutex failed");

let id = key::Id::from_persistent_key_id(key_id)?;
let key_attributes = key::Attributes::from_key_id(id)?;
let key_attributes = Attributes::from_key_id(id)?;
let buffer_size = key_attributes.export_public_key_output_size()?;
let mut buffer = vec![0u8; buffer_size];

Expand Down Expand Up @@ -206,7 +206,7 @@ impl Provider {
.expect("Grabbing key handle mutex failed");

let id = key::Id::from_persistent_key_id(key_id)?;
let key_attributes = key::Attributes::from_key_id(id)?;
let key_attributes = Attributes::from_key_id(id)?;
let buffer_size = key_attributes.export_key_output_size()?;
let mut buffer = vec![0u8; buffer_size];

Expand Down
5 changes: 2 additions & 3 deletions src/providers/mbed_crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,8 @@ impl ProviderBuilder {
/// Build into a MbedProvider
pub fn build(self) -> std::io::Result<Provider> {
Provider::new(
self.provider_name.ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::InvalidData, "missing provider name")
})?,
self.provider_name
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "missing provider name"))?,
self.key_info_store
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "missing key info store"))?,
)
Expand Down
8 changes: 4 additions & 4 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ impl ProviderIdentity {
impl TryFrom<ProviderIdentity> for ProviderId {
type Error = String;

fn try_from(provider_identity: ProviderIdentity) -> ::std::result::Result<Self, Self::Error> {
fn try_from(provider_identity: ProviderIdentity) -> std::result::Result<Self, Self::Error> {
let provider_id = match provider_identity.uuid.as_str() {
#[cfg(feature = "cryptoauthlib-provider")]
crate::providers::cryptoauthlib::Provider::PROVIDER_UUID => Ok(ProviderId::CryptoAuthLib),
#[cfg(feature = "mbed-crypto-provider")]
crate::providers::mbed_crypto::Provider::PROVIDER_UUID => Ok(ProviderId::MbedCrypto),
mbed_crypto::Provider::PROVIDER_UUID => Ok(ProviderId::MbedCrypto),
#[cfg(feature = "pkcs11-provider")]
crate::providers::pkcs11::Provider::PROVIDER_UUID => Ok(ProviderId::Pkcs11),
pkcs11::Provider::PROVIDER_UUID => Ok(ProviderId::Pkcs11),
#[cfg(feature = "tpm-provider")]
crate::providers::tpm::Provider::PROVIDER_UUID => Ok(ProviderId::Tpm),
tpm::Provider::PROVIDER_UUID => Ok(ProviderId::Tpm),
#[cfg(feature = "trusted-service-provider")]
crate::providers::trusted_service::Provider::PROVIDER_UUID => Ok(ProviderId::TrustedService),
_ => Err(format!("Cannot convert from ProviderIdentity to ProviderId.\nProvider \"{}\" is not recognised.\nCould be it does not exist, or Parsec was not compiled with the required provider feature flags.", provider_identity.uuid)),
Expand Down
5 changes: 2 additions & 3 deletions src/providers/pkcs11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,8 @@ impl ProviderBuilder {
};

Ok(Provider::new(
self.provider_name.ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::InvalidData, "missing provider name")
})?,
self.provider_name
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "missing provider name"))?,
self.key_info_store
.ok_or_else(|| Error::new(ErrorKind::InvalidData, "missing key info store"))?,
backend,
Expand Down
2 changes: 1 addition & 1 deletion src/providers/tpm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl ProviderBuilder {
}
Ok(Provider::new(
self.provider_name.ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::InvalidData, "missing provider name")
std::io::Error::new(ErrorKind::InvalidData, "missing provider name")
})?,
self.key_info_store.ok_or_else(|| {
std::io::Error::new(ErrorKind::InvalidData, "missing key info store")
Expand Down
1 change: 1 addition & 0 deletions src/utils/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// WARNING: This file should be only updated in a non-breaking way. CLI flags should not be
// removed, new flags should be tested.
// See https://github.com/parallaxsecond/parsec/issues/392 for details.
#![allow(unused_qualifications)]

use structopt::StructOpt;

Expand Down
2 changes: 1 addition & 1 deletion src/utils/service_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ unsafe fn get_provider(
);

let tcti_name_conf = TctiNameConf::from_str(tcti).map_err(|_| {
std::io::Error::new(ErrorKind::InvalidData, "Invalid TCTI configuration string")
Error::new(ErrorKind::InvalidData, "Invalid TCTI configuration string")
})?;
if *skip_if_no_tpm == Some(true) {
// TODO: When the TPM Provider uses the new TctiContext, pass it directly to the
Expand Down

0 comments on commit 3726930

Please sign in to comment.