rust/pv_*: Add more deny lints to pv and pv_core

Denies compiling if one of the following lints find something in pv or
pv_core:
    missing_docs,
    missing_debug_implementations,
    trivial_numeric_casts,
    unstable_features,
    unused_import_braces,
    unused_qualifications

Those lint force developers to avoid unnecessary code and providing
debuggability & documentation for each public symbol.

Fix the compile time error introduced with those lints.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Steffen Eiden
2024-05-23 14:35:30 +02:00
parent f383278a5a
commit 87d43c7a32
12 changed files with 31 additions and 11 deletions
+1
View File
@@ -46,6 +46,7 @@ impl TryFrom<Vec<u8>> for BootHdrTags {
}
/// Magic value for a SE-(boot)header
#[derive(Debug)]
pub struct BootHdrMagic;
impl MagicValue<8> for BootHdrMagic {
const MAGIC: [u8; 8] = [0x49, 0x42, 0x4d, 0x53, 0x65, 0x63, 0x45, 0x78];
+8 -1
View File
@@ -2,7 +2,14 @@
//
// Copyright IBM Corp. 2023, 2024
#![deny(missing_docs)]
#![deny(
missing_docs,
missing_debug_implementations,
trivial_numeric_casts,
unstable_features,
unused_import_braces,
unused_qualifications
)]
#![doc = include_str!("../README.md")]
//! # Manage guest secret store
//!
@@ -111,7 +111,7 @@ impl StackableX509Crl {
);
if r.is_null() {
let err = openssl_sys::ERR_peek_last_error();
if openssl_sys::ERR_GET_LIB(err) as c_int == openssl_sys::ERR_LIB_PEM
if openssl_sys::ERR_GET_LIB(err) == openssl_sys::ERR_LIB_PEM
&& openssl_sys::ERR_GET_REASON(err) == openssl_sys::PEM_R_NO_START_LINE
{
openssl_sys::ERR_clear_error();
+3 -2
View File
@@ -54,6 +54,7 @@ pub trait Encrypt {
}
/// Types of Authenticated Data
#[allow(missing_debug_implementations)]
pub enum Aad<'a> {
/// Authenticated Keyslot
Ks(&'a Keyslot),
@@ -207,7 +208,7 @@ impl ReqEncrCtx {
let mut auth_data: Vec<u8> = Vec::with_capacity(2048);
// reserve space for the request header
auth_data.resize(std::mem::size_of::<RequestHdr>(), 0);
auth_data.resize(size_of::<RequestHdr>(), 0);
for a in aad {
match a {
@@ -229,7 +230,7 @@ impl ReqEncrCtx {
let req_hdr = RequestHdr::new(version, rql, self.iv, nks, sea, magic);
// copy request header to the start of the request
auth_data[..std::mem::size_of::<RequestHdr>()].copy_from_slice(req_hdr.as_bytes());
auth_data[..size_of::<RequestHdr>()].copy_from_slice(req_hdr.as_bytes());
Ok(auth_data)
}
+1 -1
View File
@@ -30,7 +30,7 @@ macro_rules! get_test_asset {
}
pub fn get_cert_asset_path<P: AsRef<Path>>(path: P) -> PathBuf {
let mut p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
p.push("tests");
p.push("assets");
p.push("cert");
+1 -1
View File
@@ -261,7 +261,7 @@ fn load_crl_to_store(
x509_store: &mut X509StoreBuilder,
path: &Path,
err_out_empty_crl: bool,
) -> std::result::Result<(), openssl::error::ErrorStack> {
) -> std::result::Result<(), ErrorStack> {
let lu = x509_store.add_lookup(X509Lookup::<File>::file())?;
// Try to load cert as PEM file
if lu.load_crl_file(path, SslFiletype::PEM).is_err() {