rust: Fix cargo clippy and cargo doc findings

Fix the new `cargo clippy` and `cargo doc` findings that were triggered
with the recent policy addition.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2024-11-11 14:09:17 +00:00
committed by Steffen Eiden
parent 2155b83c1f
commit 667a8d714b
15 changed files with 20 additions and 20 deletions

View File

@@ -77,7 +77,7 @@ impl X509StoreContextExtension for X509StoreContextRef {
{
struct Cleanup<'a>(&'a mut X509StoreContextRef);
impl<'a> Drop for Cleanup<'a> {
impl Drop for Cleanup<'_> {
fn drop(&mut self) {
unsafe {
openssl_sys::X509_STORE_CTX_cleanup(self.0.as_ptr());

View File

@@ -63,7 +63,7 @@ impl Stackable for StackableX509Crl {
}
pub struct MemBioSlice<'a>(*mut openssl_sys::BIO, PhantomData<&'a [u8]>);
impl<'a> Drop for MemBioSlice<'a> {
impl Drop for MemBioSlice<'_> {
fn drop(&mut self) {
unsafe {
openssl_sys::BIO_free_all(self.0);

View File

@@ -288,7 +288,7 @@ impl EcPubKeyCoord {
hash(MessageDigest::sha256(), self.as_ref())
}
/// Construct a [``EcPubKeyCoord]
/// Construct a [`EcPubKeyCoord`]
///
/// # Safety
/// This function is marked unsafe, because data not representing two EC points violates the

View File

@@ -168,7 +168,7 @@ impl CertVerifier {
/// * `crl_paths` - Paths to certificate revocation lists for the chain of trust
/// * `root_ca_path` - Path to the root of trust
/// * `offline` - if set to true the verification process will not try to download CRLs from the
/// internet.
/// internet.
///
/// # Errors
///

View File

@@ -25,7 +25,7 @@ use std::str::from_utf8;
use std::{cmp::Ordering, ffi::c_int};
/// Minimum security level for the keys/certificates used to establish a chain of
/// trust (see https://www.openssl.org/docs/man1.1.1/man3/X509_VERIFY_PARAM_set_auth_level.html
/// trust (see <https://www.openssl.org/docs/man1.1.1/man3/X509_VERIFY_PARAM_set_auth_level.html>
/// for details).
const SECURITY_LEVEL: usize = 2;
const SECURITY_BITS_ARRAY: [u32; 6] = [0, 80, 112, 128, 192, 256];
@@ -213,7 +213,7 @@ fn is_ibm_signing_cert(cert: &X509) -> bool {
return false;
}
return match subj.entries_by_nid(Nid::ORGANIZATIONALUNITNAME).next() {
match subj.entries_by_nid(Nid::ORGANIZATIONALUNITNAME).next() {
None => false,
Some(entry) => match entry.data().as_utf8() {
Err(_) => false,
@@ -221,7 +221,7 @@ fn is_ibm_signing_cert(cert: &X509) -> bool {
.as_bytes()
.ends_with(IBM_Z_ORGANIZATIONAL_UNIT_NAME_SUFFIX.as_bytes()),
},
};
}
}
fn get_ibm_z_sign_key(certs: &[X509]) -> Result<X509> {

View File

@@ -152,9 +152,8 @@ impl AttestationCmd {
/// If called before a successful attestation the data in this buffer is undefined.
pub fn additional(&mut self) -> Option<&[u8]> {
// truncate the add size to the UV reported size
match &mut self.additional {
Some(ref mut a) => a.truncate(self.uvio_attest.add_data_len as usize),
None => (),
if let Some(ref mut a) = &mut self.additional {
a.truncate(self.uvio_attest.add_data_len as usize)
}
self.additional.as_deref()
}

View File

@@ -53,8 +53,8 @@ impl AddCmd {
///
/// # Errors
///
/// This function will return an error if the provided data does not start with the
/// [`crate::AddSecretRequest`] magic Value.
/// This function will return an error if the provided data does not start
/// with the `AddSecretRequest` magic Value.
pub fn new<R: Read>(bin_add_secret_req: &mut R) -> Result<Self> {
let mut data = Vec::with_capacity(PAGESIZE);
bin_add_secret_req.read_to_end(&mut data)?;

View File

@@ -337,7 +337,7 @@ where
{
struct FieldVisitor;
impl<'de> serde::de::Visitor<'de> for FieldVisitor {
impl serde::de::Visitor<'_> for FieldVisitor {
type Value = [u8; SecretId::ID_SIZE];
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {

View File

@@ -11,7 +11,7 @@ use byteorder::{BigEndian, ByteOrder};
use std::{fmt::Display, mem::size_of};
use zerocopy::{AsBytes, U16};
/// The magic value used to identify an [`crate:AddSecretRequest`]
/// The magic value used to identify an `AddSecretRequest`.
///
/// The magic value is ASCII:
/// ```rust

View File

@@ -122,6 +122,7 @@ pub struct PerformAttOpt {
}
#[cfg(target_arch = "s390x")]
#[derive(Debug)]
pub struct PerformAttOptComb<'a> {
pub input: &'a str,
pub output: &'a str,

View File

@@ -50,7 +50,7 @@ impl<'a> VerifyOutput<'a> {
}
}
impl<'a> Display for VerifyOutput<'a> {
impl Display for VerifyOutput<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "Config UID:")?;
writeln!(f, "{:#}", self.cuid)?;

View File

@@ -16,7 +16,7 @@ use utils::{print_cli_error, print_error, print_version, PvLogger};
use crate::cmd::*;
static LOGGER: PvLogger = PvLogger;
const FEATURES: &[&[&str]] = &[cmd::CMD_FN, cmd::UV_CMD_FN];
const FEATURES: &[&[&str]] = &[CMD_FN, UV_CMD_FN];
const EXIT_CODE_ATTESTATION_FAIL: u8 = 2;
const EXIT_CODE_LOGGER_FAIL: u8 = 3;

View File

@@ -115,7 +115,7 @@ pub struct CreateSecretOpt {
/// Use the content of FILE as user-data.
///
/// Passes user data defined in <FILE> through the add-secret request to the ultravisor. The
/// Passes user data defined in FILE through the add-secret request to the ultravisor. The
/// user data can be up to 512 bytes of arbitrary data, and the maximum size depends on the
/// size of the user-signing key:
/// - No key: user data can be 512 bytes.
@@ -129,7 +129,7 @@ pub struct CreateSecretOpt {
/// Use the content of FILE as user signing key.
///
/// Adds a signature calculated from the key in <FILE> to the add-secret request. The
/// Adds a signature calculated from the key in FILE to the add-secret request. The
/// file must be in DER or PEM format containing a private key. Supported are RSA 2048 &
/// 3072-bit and EC(secp521r1) keys. The firmware ignores the content, but the request tag
/// protects the signature. The user-signing key signs the request. The location of the

View File

@@ -141,7 +141,7 @@ fn build_asrcb(opt: &CreateSecretOpt) -> Result<AddSecretRequest> {
// Try to extract a Config-UId from a yaml structure
// The cuid field can be embedded in an abritray amount of Mappings
// The function takes the first cuid it founds (width search).
fn try_from_val(val: Value) -> anyhow::Result<ConfigUid> {
fn try_from_val(val: Value) -> Result<ConfigUid> {
fn get_cuid_from_mapping(val: &Value, depth: u8) -> Option<String> {
if depth >= 8 {
return None;

View File

@@ -30,7 +30,7 @@ where
}
}
impl<'a> Serialize for HexSlice<'a> {
impl Serialize for HexSlice<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,