From 5620779472f2937fea9b67887bd31fc61005ec30 Mon Sep 17 00:00:00 2001 From: Ionut Mihalcea Date: Sun, 1 Dec 2024 23:45:44 +0000 Subject: [PATCH] Fix clippy warnings Signed-off-by: Ionut Mihalcea --- .github/workflows/ci.yml | 3 +- tss-esapi/src/constants/mod.rs | 4 +- tss-esapi/src/handles/mod.rs | 18 ++-- .../src/interface_types/resource_handles.rs | 6 +- tss-esapi/src/structures/mod.rs | 97 +++++++++---------- tss-esapi/src/structures/nv/mod.rs | 4 +- tss-esapi/tests/valgrind.sh | 4 + 7 files changed, 70 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad187a2b..8f39d76d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,6 +79,7 @@ jobs: - name: Run the tests run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --security-opt seccomp=unconfined fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/all-fedora.sh + # SEE #558 : remove use of 1.82 once 1.84 rolls out; tests-valgrind: name: Valgrind test run runs-on: ubuntu-latest @@ -87,7 +88,7 @@ jobs: - name: Build the container run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu - name: Run the tests - run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/valgrind.sh + run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi -e RUST_TOOLCHAIN_VERSION="1.82" ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/valgrind.sh # Check that the documentation builds as well. docs: diff --git a/tss-esapi/src/constants/mod.rs b/tss-esapi/src/constants/mod.rs index e1ead7ba..ce1add47 100644 --- a/tss-esapi/src/constants/mod.rs +++ b/tss-esapi/src/constants/mod.rs @@ -1,8 +1,8 @@ // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -/// This module contains both the constants defined in the TSS specification (tss module) -/// but also the internal representation of the TSS constants. +//! This module contains both the constants defined in the TSS specification (tss module) +//! but also the internal representation of the TSS constants. /// Representation of the constants defined in the /// Constants -> TPM_ALG_ID section of the specification diff --git a/tss-esapi/src/handles/mod.rs b/tss-esapi/src/handles/mod.rs index 3d6daf53..9577f0f0 100644 --- a/tss-esapi/src/handles/mod.rs +++ b/tss-esapi/src/handles/mod.rs @@ -1,13 +1,13 @@ // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -/// Module that contains the different types of handles -/// that the ESAPI and the TPM uses in order to provide -/// access to objects that was or has been created. +//! Module that contains the different types of handles +//! that the ESAPI and the TPM uses in order to provide +//! access to objects that was or has been created. -///////////////////////////////////////////////////////// -/// ESYS Handles -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// ESYS Handles +// /////////////////////////////////////////////////////// pub use handle::auth::AuthHandle; pub use handle::key::KeyHandle; pub use handle::nv_index::NvIndexHandle; @@ -18,9 +18,9 @@ pub(crate) mod handle_conversion { pub(crate) use super::handle::conversions::*; } mod handle; -///////////////////////////////////////////////////////// -/// TPM Handles -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// TPM Handles +// /////////////////////////////////////////////////////// pub use tpm::attached_component::AttachedComponentTpmHandle; pub use tpm::hmac_session::HmacSessionTpmHandle; pub use tpm::loaded_session::LoadedSessionTpmHandle; diff --git a/tss-esapi/src/interface_types/resource_handles.rs b/tss-esapi/src/interface_types/resource_handles.rs index 45c31363..d4d55aee 100644 --- a/tss-esapi/src/interface_types/resource_handles.rs +++ b/tss-esapi/src/interface_types/resource_handles.rs @@ -206,9 +206,9 @@ impl TryFrom for HierarchyAuth { } } } -////////////////////////////////////////////////////////////////////////////////// -/// TODO: HierarchyPolicy -////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////// +// TODO: HierarchyPolicy +// //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// /// Platform diff --git a/tss-esapi/src/structures/mod.rs b/tss-esapi/src/structures/mod.rs index 95172c18..bd59a00f 100644 --- a/tss-esapi/src/structures/mod.rs +++ b/tss-esapi/src/structures/mod.rs @@ -13,26 +13,25 @@ /// Published /// /// Chapter 10: Structure Definitions - -///////////////////////////////////////////////////////// -/// The capabilitydata section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The capabilitydata section +// /////////////////////////////////////////////////////// mod capability_data; pub use self::capability_data::CapabilityData; -///////////////////////////////////////////////////////// -/// The names section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The names section +// /////////////////////////////////////////////////////// mod names; pub use names::name::Name; -///////////////////////////////////////////////////////// -/// The result section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The result section +// /////////////////////////////////////////////////////// mod result; pub use result::CreateKeyResult; pub use result::CreatePrimaryKeyResult; -///////////////////////////////////////////////////////// -/// The sized buffers section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The sized buffers section +// /////////////////////////////////////////////////////// mod buffers; pub use self::buffers::{ attest::AttestBuffer, auth::Auth, data::Data, digest::Digest, ecc_parameter::EccParameter, @@ -42,19 +41,19 @@ pub use self::buffers::{ public::PublicBuffer, public_key_rsa::PublicKeyRsa, sensitive::SensitiveBuffer, sensitive_data::SensitiveData, symmetric_key::SymmetricKey, timeout::Timeout, }; -///////////////////////////////////////////////////////// -/// The creation section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The creation section +// /////////////////////////////////////////////////////// mod creation; pub use self::creation::CreationData; -///////////////////////////////////////////////////////// -/// The hash section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The hash section +// /////////////////////////////////////////////////////// mod hash; pub use self::hash::agile::HashAgile; -///////////////////////////////////////////////////////// -/// The pcr section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The pcr section +// /////////////////////////////////////////////////////// mod pcr; pub use self::pcr_slot::PcrSlot; @@ -76,9 +75,9 @@ pub use self::pcr_select_size::PcrSelectSize; pub mod pcr_select_size { pub use super::pcr::select_size::*; } -///////////////////////////////////////////////////////// -/// The lists section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The lists section +// /////////////////////////////////////////////////////// mod lists; pub use self::digest_list::DigestList; pub mod digest_list { @@ -132,14 +131,14 @@ pub mod command_code_attributes_list { } pub(crate) use pcr::slot_collection::PcrSlotCollection; -///////////////////////////////////////////////////////// -/// The parameters section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The parameters section +// /////////////////////////////////////////////////////// mod parameters; pub use self::parameters::SymmetricCipherParameters; -///////////////////////////////////////////////////////// -/// The tickets section -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// The tickets section +// /////////////////////////////////////////////////////// mod tickets; pub use tickets::AuthTicket; pub use tickets::CreationTicket; @@ -167,19 +166,19 @@ pub use tagged::{ signature::Signature, symmetric::{SymmetricDefinition, SymmetricDefinitionObject}, }; -///////////////////////////////////////////////////////// -/// ECC structures -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// ECC structures +// /////////////////////////////////////////////////////// mod ecc; pub use ecc::point::EccPoint; -///////////////////////////////////////////////////////// -/// Signatures structures -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// Signatures structures +// /////////////////////////////////////////////////////// mod signatures; pub use signatures::{EccSignature, RsaSignature}; -///////////////////////////////////////////////////////// -/// Attestation Structures -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// Attestation Structures +// /////////////////////////////////////////////////////// mod attestation; pub use attestation::{ attest::Attest, attest_info::AttestInfo, certify_info::CertifyInfo, @@ -187,22 +186,22 @@ pub use attestation::{ nv_certify_info::NvCertifyInfo, nv_digest_certify_info::NvDigestCertifyInfo, quote_info::QuoteInfo, session_audit_info::SessionAuditInfo, time_attest_info::TimeAttestInfo, }; -///////////////////////////////////////////////////////// -/// Clock/Time Structures -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// Clock/Time Structures +// /////////////////////////////////////////////////////// mod clock; pub use clock::{clock_info::ClockInfo, time_info::TimeInfo}; -///////////////////////////////////////////////////////// -/// Property Structures -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// Property Structures +// /////////////////////////////////////////////////////// mod property; pub use property::{ algorithm_property::AlgorithmProperty, tagged_pcr_select::TaggedPcrSelect, tagged_property::TaggedProperty, }; -///////////////////////////////////////////////////////// -/// NV structures -///////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// NV structures +// /////////////////////////////////////////////////////// mod nv; pub use nv::storage::{NvPublic, NvPublicBuilder}; diff --git a/tss-esapi/src/structures/nv/mod.rs b/tss-esapi/src/structures/nv/mod.rs index d5bf6ba1..940537d8 100644 --- a/tss-esapi/src/structures/nv/mod.rs +++ b/tss-esapi/src/structures/nv/mod.rs @@ -1,8 +1,8 @@ // Copyright 2020 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 -/// This module contains code that deals with the non volatile -/// parts of the tpm. +//! This module contains code that deals with the non volatile +//! parts of the tpm. /// Non volatile storage module. pub mod storage; diff --git a/tss-esapi/tests/valgrind.sh b/tss-esapi/tests/valgrind.sh index 2035b5d9..8775510b 100755 --- a/tss-esapi/tests/valgrind.sh +++ b/tss-esapi/tests/valgrind.sh @@ -8,6 +8,10 @@ set -euf -o pipefail +if [[ ! -z ${RUST_TOOLCHAIN_VERSION:+x} ]]; then + rustup override set ${RUST_TOOLCHAIN_VERSION} +fi + ################################# # Run the TPM simulation server # #################################