Skip to content

Commit bab313a

Browse files
authored
Merge pull request #483 from Superhepper/lint-errors-1.75
Fixes lint errors reported in rust 1.75.
2 parents 2dfc315 + 1bdc1cf commit bab313a

20 files changed

+78
-129
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl Context {
194194
)
195195
},
196196
|ret| {
197-
error!("Error when generating ECDH keypair: {:#010X}", ret);
197+
error!("Error when generating ECDH key pair: {:#010X}", ret);
198198
},
199199
)?;
200200

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Context {
8686
/// # context
8787
/// # .tr_set_auth(primary_key_handle.into(), primary_key_auth)
8888
/// # .expect("Failed to set auth from primary key handle.");
89-
/// # // Create symmetric key objhect attributes
89+
/// # // Create symmetric key object attributes
9090
/// # let symmetric_key_object_attributes = ObjectAttributesBuilder::new()
9191
/// # .with_user_with_auth(true)
9292
/// # .with_sign_encrypt(true)
@@ -162,7 +162,7 @@ impl Context {
162162
/// false, // false, indicates that the data should be encrypted.
163163
/// SymmetricMode::Cfb, // The symmetric mode of the encryption.
164164
/// data.clone(), // The data that is to be encrypted.
165-
/// initial_value.clone(), // Initial value needed by the algorithmen.
165+
/// initial_value.clone(), // Initial value needed by the algorithm.
166166
/// )
167167
/// .expect("Call to encrypt_decrypt_2 failed when encrypting data")
168168
/// });

tss-esapi/src/utils/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@ impl TryFrom<TPMS_CONTEXT> for TpmsContext {
5757
hierarchy: tss2_context.hierarchy,
5858
context_blob: tss2_context.contextBlob.buffer.to_vec(),
5959
};
60-
context.context_blob.truncate(
61-
tss2_context
62-
.contextBlob
63-
.size
64-
.try_into()
65-
.map_err(|_| Error::local_error(WrapperErrorKind::WrongParamSize))?,
66-
);
60+
context
61+
.context_blob
62+
.truncate(tss2_context.contextBlob.size.into());
6763
Ok(context)
6864
}
6965
}
@@ -321,7 +317,7 @@ pub fn get_tpm_vendor(context: &mut Context) -> Result<String> {
321317
]
322318
.iter()
323319
// Retrieve property values
324-
.map(|propid| context.get_tpm_property(*propid))
320+
.map(|prop_id| context.get_tpm_property(*prop_id))
325321
// Collect and return an error if we got one
326322
.collect::<Result<Vec<Option<u32>>>>()?
327323
.iter()

tss-esapi/tests/integration_tests/context_tests/tpm_commands/enhanced_authorization_ea_commands_tests.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
mod test_policy_signed {
44
use crate::common::{create_ctx_with_session, signing_key_pub};
5-
use std::{
6-
convert::{TryFrom, TryInto},
7-
time::Duration,
8-
};
5+
use std::{convert::TryFrom, time::Duration};
96
use tss_esapi::{
107
attributes::SessionAttributesBuilder,
118
constants::SessionType,
@@ -70,7 +67,7 @@ mod test_policy_signed {
7067
context
7168
.policy_signed(
7269
trial_policy_session,
73-
key_handle.try_into().unwrap(),
70+
key_handle.into(),
7471
nonce_tpm,
7572
cp_hash_a,
7673
policy_ref,

tss-esapi/tests/integration_tests/structures_tests/attest_info_test.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ fn test_certify_into_tpm_type_conversions() {
1818
let expected_tpms_certify_info = TPMS_CERTIFY_INFO {
1919
name: Name::try_from(vec![0xffu8; 64])
2020
.expect("Failed to create name")
21-
.try_into()
22-
.expect("Failed to convert name to tss type"),
21+
.into(),
2322
qualifiedName: Name::try_from(vec![0x0fu8; 64])
2423
.expect("Failed to create qualified name")
25-
.try_into()
26-
.expect("failed to convert qualified name to tss type"),
24+
.into(),
2725
};
2826

2927
let tpmu_attest: TPMU_ATTEST = AttestInfo::Certify {
@@ -55,7 +53,7 @@ fn test_quote_into_tpm_type_conversions() {
5553
],
5654
)
5755
.build()
58-
.expect("Failed to createm PcrSelectionList")
56+
.expect("Failed to create PcrSelectionList")
5957
.into(),
6058
pcrDigest: Digest::try_from(vec![0xffu8; 32])
6159
.expect("Failed to create digest")

tss-esapi/tests/integration_tests/structures_tests/attest_tests.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ fn test_attest_with_certify_info_into_tpm_type_conversions() {
2525
Name::try_from(vec![0x0fu8; 64]).expect("Failed to create qualified name");
2626
let expected_attest_info = AttestInfo::Certify {
2727
info: TPMS_CERTIFY_INFO {
28-
name: expected_certify_info_name
29-
.clone()
30-
.try_into()
31-
.expect("Failed to convert name to tss type"),
32-
qualifiedName: expected_certify_info_qualified_name
33-
.clone()
34-
.try_into()
35-
.expect("failed to convert qualified name to tss type"),
28+
name: expected_certify_info_name.clone().into(),
29+
qualifiedName: expected_certify_info_qualified_name.clone().into(),
3630
}
3731
.try_into()
3832
.expect("Failed to convert TPMS_CERTIFY_INFO to CertifyInfo"),
@@ -74,7 +68,7 @@ fn test_attest_with_quote_info_into_tpm_type_conversions() {
7468
],
7569
)
7670
.build()
77-
.expect("Failed to createm PcrSelectionList");
71+
.expect("Failed to create PcrSelectionList");
7872
let expected_pcr_digest = Digest::try_from(vec![0xffu8; 32]).expect("Failed to create digest");
7973
let expected_attest_info = AttestInfo::Quote {
8074
info: TPMS_QUOTE_INFO {

tss-esapi/tests/integration_tests/structures_tests/buffers_tests/attest_buffer_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ const ATTEST_BUFFER_MAX_SIZE: usize = 2304;
88

99
#[test]
1010
fn test_max_sized_data() {
11-
let _ = AttestBuffer::try_from(vec![0xffu8; ATTEST_BUFFER_MAX_SIZE])
11+
let _ = AttestBuffer::try_from(vec![0xFFu8; ATTEST_BUFFER_MAX_SIZE])
1212
.expect("Failed to parse buffer if maximum size as AttestBuffer");
1313
}
1414

1515
#[test]
1616
fn test_to_large_data() {
1717
assert_eq!(
18-
AttestBuffer::try_from(vec![0xffu8; ATTEST_BUFFER_MAX_SIZE + 1])
18+
AttestBuffer::try_from(vec![0xFFu8; ATTEST_BUFFER_MAX_SIZE + 1])
1919
.expect_err("Converting a buffer that is to large did not produce an error"),
2020
Error::WrapperError(WrapperErrorKind::WrongParamSize),
2121
"Wrong kind of error when converting a buffer with size {} to AttestBuffer",
@@ -28,7 +28,7 @@ fn test_default() {
2828
{
2929
let attest_buffer: AttestBuffer = Default::default();
3030
let expected: TPM2B_ATTEST = Default::default();
31-
let actual = TPM2B_ATTEST::try_from(attest_buffer).unwrap();
31+
let actual = TPM2B_ATTEST::from(attest_buffer);
3232
assert_eq!(expected.size, actual.size);
3333
assert_eq!(
3434
expected.attestationData.len(),

tss-esapi/tests/integration_tests/structures_tests/buffers_tests/auth_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod test_auth {
3232
{
3333
let auth: Auth = Default::default();
3434
let expected: TPM2B_AUTH = Default::default();
35-
let actual = TPM2B_AUTH::try_from(auth).unwrap();
35+
let actual = TPM2B_AUTH::from(auth);
3636
assert_eq!(expected.size, actual.size);
3737
assert_eq!(
3838
expected.buffer.len(),

tss-esapi/tests/integration_tests/structures_tests/buffers_tests/data_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::convert::TryFrom;
44
use tss_esapi::structures::Data;
55
use tss_esapi::tss2_esys::TPM2B_DATA;
6-
// The TPM2B_DATA has aisze of 64 bytes
6+
// The TPM2B_DATA has a size of 64 bytes
77
mod test_data {
88
use super::*;
99

@@ -27,7 +27,7 @@ mod test_data {
2727
{
2828
let data: Data = Default::default();
2929
let expected: TPM2B_DATA = Default::default();
30-
let actual = TPM2B_DATA::try_from(data).unwrap();
30+
let actual = TPM2B_DATA::from(data);
3131
assert_eq!(expected.size, actual.size);
3232
assert_eq!(
3333
expected.buffer.len(),

tss-esapi/tests/integration_tests/structures_tests/buffers_tests/max_buffer_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod test_auth {
2424
{
2525
let max_buffer: MaxBuffer = Default::default();
2626
let expected: TPM2B_MAX_BUFFER = Default::default();
27-
let actual = TPM2B_MAX_BUFFER::try_from(max_buffer).unwrap();
27+
let actual = TPM2B_MAX_BUFFER::from(max_buffer);
2828
assert_eq!(expected.size, actual.size);
2929
assert_eq!(
3030
expected.buffer.len(),

0 commit comments

Comments
 (0)