Skip to content

Commit d68a13a

Browse files
authored
Merge pull request #532 from Superhepper/lint-errors-1.80.0
Fixes lint problems reported by Clippy in Rust 1.80.0
2 parents 75e9879 + af49128 commit d68a13a

File tree

22 files changed

+69
-63
lines changed

22 files changed

+69
-63
lines changed

tss-esapi/build.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
use semver::{Version, VersionReq};
44

55
fn main() {
6+
println!("cargo:rustc-check-cfg=cfg(hierarchy_is_esys_tr)");
7+
println!("cargo:rustc-check-cfg=cfg(has_tss_base_rc_values_28_to_51)");
8+
println!("cargo:rustc-check-cfg=cfg(has_tss_base_rc_values_52_to_53)");
9+
println!("cargo:rustc-check-cfg=cfg(has_tpmu_sensitive_create)");
10+
println!("cargo:rustc-check-cfg=cfg(has_esys_tr_get_tpm_handle)");
11+
612
let tss_version_string = std::env::var("DEP_TSS2_ESYS_VERSION")
713
.expect("Failed to parse ENV variable DEP_TSS2_ESYS_VERSION as string");
814

@@ -12,11 +18,6 @@ fn main() {
1218
let supported_tss_version =
1319
VersionReq::parse("<5.0.0, >=2.3.3").expect("Failed to parse supported TSS version");
1420

15-
let hierarchy_is_esys_tr_req = VersionReq::parse(">=3.0.0").unwrap();
16-
if hierarchy_is_esys_tr_req.matches(&tss_version) {
17-
println!("cargo:rustc-cfg=hierarchy_is_esys_tr")
18-
}
19-
2021
assert!(
2122
supported_tss_version.matches(&tss_version),
2223
"Unsupported TSS version {}",

tss-esapi/src/abstraction/transient/key_attestation.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use std::convert::TryFrom;
3232
///
3333
/// * it includes all the public parameters of the attested key
3434
/// * can be hashed (in its marshaled form) with the name hash
35-
/// (found by unmarshaling it) to obtain `name`
35+
/// (found by unmarshaling it) to obtain `name`
3636
pub struct MakeCredParams {
3737
/// TPM name of the object being attested
3838
pub name: Vec<u8>,
@@ -48,10 +48,8 @@ impl TransientKeyContext {
4848
///
4949
/// # Parameters
5050
///
51-
/// * `object` - the object whose TPM name will be included in
52-
/// the credential
53-
/// * `key` - the key to be used to encrypt the secret that wraps
54-
/// the credential
51+
/// * `object` - the object whose TPM name will be included in the credential
52+
/// * `key` - the key to be used to encrypt the secret that wraps the credential
5553
///
5654
/// **Note**: If no `key` is given, the default Endorsement Key
5755
/// will be used.
@@ -88,8 +86,7 @@ impl TransientKeyContext {
8886
///
8987
/// * `object` - the object whose TPM name is included in the credential
9088
/// * `key` - the key used to encrypt the secret that wraps the credential
91-
/// * `credential_blob` - encrypted credential that will be returned by the
92-
/// TPM
89+
/// * `credential_blob` - encrypted credential that will be returned by the TPM
9390
/// * `secret` - encrypted secret that was used to encrypt the credential
9491
///
9592
/// **Note**: if no `key` is given, the default Endorsement Key

tss-esapi/src/abstraction/transient/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ impl KeyMaterial {
101101
///
102102
/// - `material` identifies the numeric value of the key object
103103
/// - `params` identifies the algorithm to use on the key and other relevant
104-
/// parameters
104+
/// parameters
105105
/// - `auth` identifies the optional authentication value to be used with the
106-
/// key
106+
/// key
107107
#[derive(Debug, Clone)]
108108
pub struct ObjectWrapper {
109109
pub material: KeyMaterial,
@@ -660,10 +660,10 @@ impl TransientKeyContextBuilder {
660660
///
661661
/// # Errors
662662
/// * errors are returned if any method calls return an error: `Context::start_auth_session`
663-
/// `Context::create_primary`, `Context::flush_context`, `Context::set_handle_auth`
664-
/// or if an internal error occurs when getting random numbers from the local machine
663+
/// `Context::create_primary`, `Context::flush_context`, `Context::set_handle_auth`
664+
/// or if an internal error occurs when getting random numbers from the local machine
665665
/// * if the root key authentication size is given greater than 32 or if the root key size is
666-
/// not 1024, 2048, 3072 or 4096, a `InvalidParam` wrapper error is returned
666+
/// not 1024, 2048, 3072 or 4096, a `InvalidParam` wrapper error is returned
667667
pub fn build(mut self) -> Result<TransientKeyContext> {
668668
if self.root_key_auth_size > 32 {
669669
return Err(Error::local_error(ErrorKind::WrongParamSize));

tss-esapi/src/constants/tss.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ pub use crate::tss2_esys::TSS2_BASE_RC_RSP_AUTH_FAILED; /* Authorizing the TPM r
677677
pub use crate::tss2_esys::TSS2_BASE_RC_TRY_AGAIN; /* Operation timed out; function must be called again to be completed */
678678

679679
cfg_if::cfg_if! {
680-
if #[cfg(has_tss_base_rc_values_28_to_51_req)] {
680+
if #[cfg(has_tss_base_rc_values_28_to_51)] {
681681
pub use crate::tss2_esys::TSS2_BASE_RC_NO_CONFIG; /* No config is available */
682682
pub use crate::tss2_esys::TSS2_BASE_RC_BAD_PATH; /* The provided path is bad */
683683
pub use crate::tss2_esys::TSS2_BASE_RC_NOT_DELETABLE; /* The object is not deletable */
@@ -731,7 +731,7 @@ cfg_if::cfg_if! {
731731
}
732732

733733
cfg_if::cfg_if! {
734-
if #[cfg(has_tss_base_rc_values_52_to_53_req)] {
734+
if #[cfg(has_tss_base_rc_values_52_to_53)] {
735735
pub use crate::tss2_esys::TSS2_BASE_RC_NOT_PROVISIONED; /* Provisioning was not executed */
736736
pub use crate::tss2_esys::TSS2_BASE_RC_ALREADY_PROVISIONED; /* Already provisioned */
737737
} else {

tss-esapi/src/context.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ use std::ptr::null_mut;
3333
///
3434
/// Code safety-wise, the methods should cover the two kinds of problems that might arise:
3535
/// * in terms of memory safety, all parameters passed down to the TSS are verified and the library
36-
/// stack is then trusted to provide back valid outputs
36+
/// stack is then trusted to provide back valid outputs
3737
/// * in terms of thread safety, all methods require a mutable reference to the context object,
38-
/// ensuring that no two threads can use the context at the same time for an operation (barring use
39-
/// of `unsafe` constructs on the client side)
38+
/// ensuring that no two threads can use the context at the same time for an operation (barring use
39+
/// of `unsafe` constructs on the client side)
40+
///
4041
/// More testing and verification will be added to ensure this.
4142
///
4243
/// For most methods, if the wrapped TSS call fails and returns a non-zero `TPM2_RC`, a
@@ -86,7 +87,7 @@ impl Context {
8687
///
8788
/// # Errors
8889
/// * if either `Tss2_TctiLdr_Initiialize` or `Esys_Initialize` fail, a corresponding
89-
/// Tss2ResponseCode will be returned
90+
/// Tss2ResponseCode will be returned
9091
pub fn new(tcti_name_conf: TctiNameConf) -> Result<Self> {
9192
let mut esys_context = null_mut();
9293

@@ -120,7 +121,7 @@ impl Context {
120121
///
121122
/// # Errors
122123
/// * if either `Tss2_TctiLdr_Initiialize` or `Esys_Initialize` fail, a corresponding
123-
/// Tss2ResponseCode will be returned
124+
/// Tss2ResponseCode will be returned
124125
pub fn new_with_tabrmd(tabrmd_conf: TabrmdConfig) -> Result<Self> {
125126
Context::new(TctiNameConf::Tabrmd(tabrmd_conf))
126127
}

tss-esapi/src/context/general_esys_tr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl Context {
408408
/// # Errors
409409
/// * if the TPM cannot serialize the handle, a TSS error is returned.
410410
/// * if the buffer length cannot be converted to a `usize`, an `InvalidParam`
411-
/// wrapper error is returned.
411+
/// wrapper error is returned.
412412
///
413413
/// ```rust
414414
/// # use tss_esapi::{
@@ -476,7 +476,7 @@ impl Context {
476476
/// # Errors
477477
/// * if the TPM cannot deserialize the buffer, a TSS error is returned.
478478
/// * if the buffer length cannot be converted to a `usize`, an `InvalidParam`
479-
/// wrapper error is returned.
479+
/// wrapper error is returned.
480480
///
481481
/// ```rust
482482
/// # use tss_esapi::{

tss-esapi/src/context/tpm_commands/capability_commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Context {
7878
///
7979
/// # Errors
8080
/// * if any of the public parameters is not compatible with the TPM,
81-
/// an `Err` containing the specific unmarshalling error will be returned.
81+
/// an `Err` containing the specific unmarshalling error will be returned.
8282
pub fn test_parms(&mut self, public_parmeters: PublicParameters) -> Result<()> {
8383
ReturnCode::ensure_success(
8484
unsafe {

tss-esapi/src/context/tpm_commands/context_management.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Context {
1717
///
1818
/// # Errors
1919
/// * if conversion from `TPMS_CONTEXT` to `TpmsContext` fails, a `WrongParamSize` error will
20-
/// be returned
20+
/// be returned
2121
pub fn context_save(&mut self, handle: ObjectHandle) -> Result<SavedTpmContext> {
2222
let mut context_ptr = null_mut();
2323
ReturnCode::ensure_success(
@@ -33,7 +33,7 @@ impl Context {
3333
///
3434
/// # Errors
3535
/// * if conversion from `TpmsContext` to the native `TPMS_CONTEXT` fails, a `WrongParamSize`
36-
/// error will be returned
36+
/// error will be returned
3737
pub fn context_load(&mut self, context: SavedTpmContext) -> Result<ObjectHandle> {
3838
let mut esys_loaded_handle = ObjectHandle::None.into();
3939
let tpm_context = context.into();

tss-esapi/src/context/tpm_commands/hierarchy_commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Context {
2323
///
2424
/// # Errors
2525
/// * if either of the slices is larger than the maximum size of the native objects, a
26-
/// `WrongParamSize` wrapper error is returned
26+
/// `WrongParamSize` wrapper error is returned
2727
// TODO: Fix when compacting the arguments into a struct
2828
#[allow(clippy::too_many_arguments)]
2929
pub fn create_primary(

tss-esapi/src/context/tpm_commands/integrity_collection_pcr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl Context {
111111
///
112112
/// # Arguments
113113
/// * `pcr_selection_list` - A [PcrSelectionList] that contains pcr slots in
114-
/// different banks that is going to be read.
114+
/// different banks that is going to be read.
115115
///
116116
/// # Details
117117
/// The provided [PcrSelectionList] contains the pcr slots in the different

0 commit comments

Comments
 (0)