Skip to content

Commit 40899e5

Browse files
authored
Merge pull request #580 from Superhepper/main
Fixed lint errors reported by Clippy in 1.88.
2 parents cecd256 + 88c3138 commit 40899e5

File tree

28 files changed

+136
-189
lines changed

28 files changed

+136
-189
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
name: Check spelling
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1313
- name: Check spelling
1414
uses: codespell-project/actions-codespell@v1
1515
with:
@@ -19,15 +19,15 @@ jobs:
1919
name: Check formatting
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2323
- name: Check formatting
2424
run: cargo fmt --all -- --check
2525
# Check that it builds with the Minimum Supported Rust Version
2626
msrv:
2727
name: Check minimum supported rust version (MSRV)
2828
runs-on: ubuntu-latest
2929
steps:
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
3131
- name: Build the container
3232
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
3333
- name: Run the container
@@ -38,7 +38,7 @@ jobs:
3838
name: Ubuntu tests
3939
runs-on: ubuntu-latest
4040
steps:
41-
- uses: actions/checkout@v2
41+
- uses: actions/checkout@v4
4242
- name: Build the container
4343
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
4444
- name: Run the container
@@ -50,7 +50,7 @@ jobs:
5050
name: Ubuntu tests on v4.x.y of tpm2-tss libraries found using pkg-config --target tpm2-tools
5151
runs-on: ubuntu-latest
5252
steps:
53-
- uses: actions/checkout@v2
53+
- uses: actions/checkout@v4
5454
- name: Build the container
5555
run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.1.3 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
5656
- name: Run the container
@@ -60,7 +60,7 @@ jobs:
6060
name: Ubuntu tests on v4.x.y of tpm2-tss libraries found using a path
6161
runs-on: ubuntu-latest
6262
steps:
63-
- uses: actions/checkout@v2
63+
- uses: actions/checkout@v4
6464
- name: Build the container
6565
run: docker build -t ubuntucontainer tss-esapi/tests/ --build-arg TPM2_TSS_VERSION=4.0.1 --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss-install-dir
6666
- name: Run the container
@@ -71,7 +71,7 @@ jobs:
7171
# We just build a container... GitHub doesn't like Fedora :(
7272
runs-on: ubuntu-latest
7373
steps:
74-
- uses: actions/checkout@v2
74+
- uses: actions/checkout@v4
7575
- name: Build the container
7676
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora
7777
- name: Run the tests
@@ -82,18 +82,17 @@ jobs:
8282
# We just build a container... GitHub doesn't like Fedora :(
8383
runs-on: ubuntu-latest
8484
steps:
85-
- uses: actions/checkout@v2
85+
- uses: actions/checkout@v4
8686
- name: Build the container
8787
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora-rawhide
8888
- name: Run the tests
8989
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
9090

91-
# SEE #558 : remove use of 1.82 once 1.84 rolls out;
9291
tests-valgrind:
9392
name: Valgrind test run
9493
runs-on: ubuntu-latest
9594
steps:
96-
- uses: actions/checkout@v2
95+
- uses: actions/checkout@v4
9796
- name: Build the container
9897
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
9998
- name: Run the tests
@@ -104,7 +103,7 @@ jobs:
104103
name: Check documentation
105104
runs-on: ubuntu-latest
106105
steps:
107-
- uses: actions/checkout@v2
106+
- uses: actions/checkout@v4
108107
- name: Build the container
109108
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tools
110109
- name: Check documentation
@@ -115,7 +114,7 @@ jobs:
115114
name: Check Clippy lints
116115
runs-on: ubuntu-latest
117116
steps:
118-
- uses: actions/checkout@v2
117+
- uses: actions/checkout@v4
119118
- name: Build the container
120119
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss
121120
- name: Check Clippy lints MSRV

tss-esapi-sys/build.rs

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub mod target {
2727
/// Ensures that the `TARGET` is valid for cross compilation.
2828
pub fn ensure_supported() {
2929
let target = Triple::from_str(&std::env::var(TARGET_ENV_VAR_NAME).unwrap_or_else(|_| {
30-
panic!("Missing environment variable `{}`.", TARGET_ENV_VAR_NAME);
30+
panic!("Missing environment variable `{TARGET_ENV_VAR_NAME}`.");
3131
}))
3232
.expect("Failed to parse target triple.");
3333
match (target.architecture, target.operating_system) {
@@ -37,10 +37,9 @@ pub mod target {
3737
| (Architecture::X86_64, OperatingSystem::Linux) => {}
3838
(arch, os) => {
3939
panic!(
40-
"Compilation target (architecture, OS) tuple ({}, {}) is not part of the \
40+
"Compilation target (architecture, OS) tuple ({arch}, {os}) is not part of the \
4141
supported tuples. Please compile with the \"generate-bindings\" feature or \
42-
add support for your platform.",
43-
arch, os
42+
add support for your platform."
4443
);
4544
}
4645
}
@@ -163,10 +162,7 @@ pub mod tpm2_tss {
163162
std::env::var(PATH_ENV_VAR_NAME).map_or_else(
164163
|e| match e {
165164
std::env::VarError::NotUnicode(invalid_value) => {
166-
panic!(
167-
"Invalid `{}` env var: `{:?}`.",
168-
PATH_ENV_VAR_NAME, invalid_value
169-
);
165+
panic!("Invalid `{PATH_ENV_VAR_NAME}` env var: `{invalid_value:?}`.");
170166
}
171167
std::env::VarError::NotPresent => None,
172168
},
@@ -196,64 +192,53 @@ pub mod tpm2_tss {
196192
let install_path = PathBuf::from(env_var);
197193
if !install_path.is_dir() {
198194
panic!(
199-
"The tpm2-tss installation path `{}` specifies an existing directory (`{}`).",
200-
PATH_ENV_VAR_NAME,
201-
install_path.to_string_lossy(),
195+
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies an existing directory (`{}`).",
196+
install_path.to_string_lossy()
202197
);
203198
}
204199
if !install_path.join("include").is_dir() {
205200
panic!(
206-
"The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
201+
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
207202
contain an `include` directory",
208-
PATH_ENV_VAR_NAME,
209-
install_path.to_string_lossy(),
203+
install_path.to_string_lossy()
210204
);
211205
}
212206
if !install_path.join("lib").is_dir() {
213207
panic!(
214-
"The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
208+
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
215209
contain an `lib` directory",
216-
PATH_ENV_VAR_NAME,
217-
install_path.to_string_lossy(),
210+
install_path.to_string_lossy()
218211
);
219212
}
220213
let version_str =
221214
std::fs::read_to_string(install_path.join("VERSION")).unwrap_or_else(|e| {
222215
panic!(
223-
"The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
224-
contain a readable VERSION file: {}.",
225-
PATH_ENV_VAR_NAME,
226-
install_path.to_string_lossy(),
227-
e,
216+
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
217+
contain a readable VERSION file: {e}.",
218+
install_path.to_string_lossy()
228219
);
229220
});
230221
let version = Version::parse(version_str.trim()).unwrap_or_else(|e| {
231222
panic!(
232-
"The tpm2-tss installation path `{}` specifies a path `{}`, contains a \
233-
VERSION file that cannot be parsed: {}.",
234-
PATH_ENV_VAR_NAME,
235-
install_path.to_string_lossy(),
236-
e
223+
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, contains a \
224+
VERSION file that cannot be parsed: {e}.",
225+
install_path.to_string_lossy()
237226
);
238227
});
239228

240-
let min_version_req_str = format!(">={}", MINIMUM_VERSION);
229+
let min_version_req_str = format!(">={MINIMUM_VERSION}");
241230
let min_version_req = VersionReq::parse(&min_version_req_str).unwrap_or_else(|e| {
242231
panic!(
243232
"[Internal Error]: Failed to parse minimum tpm2-tss library version \
244-
requirement. Error: `{}`. Please report this.",
245-
e
233+
requirement. Error: `{e}`. Please report this."
246234
);
247235
});
248236
if !min_version_req.matches(&version) {
249237
panic!(
250-
"The tpm2-tss installation path `{}` specifies a path `{}`, contains a \
251-
VERSION file that specifies a version `{}` that does not meet the minimum \
252-
version requirement `{}`.",
253-
PATH_ENV_VAR_NAME,
254-
install_path.to_string_lossy(),
255-
version_str,
256-
MINIMUM_VERSION,
238+
"The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, contains a \
239+
VERSION file that specifies a version `{version_str}` that does not meet the minimum \
240+
version requirement `{MINIMUM_VERSION}`.",
241+
install_path.to_string_lossy()
257242
);
258243
}
259244
println!(
@@ -296,8 +281,7 @@ pub mod tpm2_tss {
296281
Self::probe_optional(lib_name, install_path, with_header_files).map_or_else(
297282
|| {
298283
panic!(
299-
"Failed to find {} library of version {MINIMUM_VERSION} or greater.",
300-
lib_name
284+
"Failed to find {lib_name} library of version {MINIMUM_VERSION} or greater."
301285
)
302286
},
303287
|lib| {
@@ -356,7 +340,7 @@ pub mod tpm2_tss {
356340
self.name
357341
);
358342
},
359-
|v| format!("-I{}", v),
343+
|v| format!("-I{v}"),
360344
)
361345
}
362346

@@ -436,7 +420,7 @@ pub mod tpm2_tss {
436420
let lib_path = path.join("lib");
437421
Self::lib_file(lib_name, &lib_path)?;
438422
// If the lib file was found then the name is reported to Cargo.
439-
println!("cargo:rustc-link-lib={}", lib_name);
423+
println!("cargo:rustc-link-lib={lib_name}");
440424

441425
let include_path = path.join("include/tss2");
442426
Some(Self {
@@ -481,8 +465,7 @@ pub mod tpm2_tss {
481465
let mut associated_files = hit_iter.collect::<Vec<PathBuf>>();
482466
associated_files.push(hit.clone());
483467
panic!(
484-
"More then one match found for library `{}`: {:?}",
485-
lib_name, associated_files
468+
"More then one match found for library `{lib_name}`: {associated_files:?}",
486469
);
487470
}
488471
}

tss-esapi/build.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ fn main() {
2020

2121
assert!(
2222
supported_tss_version.matches(&tss_version),
23-
"Unsupported TSS version {}",
24-
tss_version
23+
"Unsupported TSS version {tss_version}"
2524
);
2625

2726
let hierarchy_is_esys_tr_req = VersionReq::parse(">=3.0.0").unwrap();

tss-esapi/examples/certify.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fn main() {
184184
// Alternately on the CLI you can view the certificate with:
185185
// # tpm2_getekcertificate | openssl x509 -inform DER -noout -text
186186

187-
eprintln!("ek_pubcert der: {:x?}", ek_pubcert);
187+
eprintln!("ek_pubcert der: {ek_pubcert:x?}");
188188

189189
// Retrieve the EK public template that allows us to access a handle to the EK
190190
let ek_template = create_ek_public_from_default_template(ek_alg, None).unwrap();
@@ -495,8 +495,8 @@ fn main() {
495495
.flush_context(SessionHandle::from(aik_auth_session).into())
496496
.expect("Failed to clear policy_auth_session");
497497

498-
println!("attest: {:?}", attest);
499-
println!("signature: {:?}", signature);
498+
println!("attest: {attest:?}");
499+
println!("signature: {signature:?}");
500500

501501
// ================================================================================
502502
// Now back on our certifying authority, we want to assert that the attestation we
@@ -537,7 +537,7 @@ fn main() {
537537
})
538538
.expect("Failed to verify attestation");
539539

540-
println!("verification: {:?}", verified_ticket);
540+
println!("verification: {verified_ticket:?}");
541541
}
542542

543543
fn create_key(context: &mut Context) -> KeyHandle {

tss-esapi/examples/duplication.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn main() {
216216
)
217217
})
218218
.map_err(|err| {
219-
eprintln!("⚠️ {}", err);
219+
eprintln!("⚠️ {err}");
220220
err
221221
})
222222
.unwrap();
@@ -269,7 +269,7 @@ fn main() {
269269
ctx.create(loaded_storage_key, hmac_public, None, None, None, None)
270270
})
271271
.map_err(|err| {
272-
eprintln!("⚠️ {}", err);
272+
eprintln!("⚠️ {err}");
273273
err
274274
})
275275
.unwrap();
@@ -371,7 +371,7 @@ fn main() {
371371
result
372372
})
373373
.map_err(|err| {
374-
eprintln!("⚠️ {}", err);
374+
eprintln!("⚠️ {err}");
375375
err
376376
})
377377
.unwrap();
@@ -434,8 +434,8 @@ fn main() {
434434
})
435435
.unwrap();
436436

437-
println!("hmac1 = {:?}", hmac1);
438-
println!("hmac2 = {:?}", hmac2);
437+
println!("hmac1 = {hmac1:?}");
438+
println!("hmac2 = {hmac2:?}");
439439
// They are the same!
440440
assert_eq!(hmac1, hmac2);
441441
}

tss-esapi/examples/duplication_secret.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn main() {
217217
)
218218
})
219219
.map_err(|err| {
220-
eprintln!("⚠️ {}", err);
220+
eprintln!("⚠️ {err}");
221221
err
222222
})
223223
.unwrap();
@@ -268,7 +268,7 @@ fn main() {
268268
ctx.create(loaded_storage_key, hmac_public, None, None, None, None)
269269
})
270270
.map_err(|err| {
271-
eprintln!("⚠️ {}", err);
271+
eprintln!("⚠️ {err}");
272272
err
273273
})
274274
.unwrap();
@@ -364,7 +364,7 @@ fn main() {
364364
result
365365
})
366366
.map_err(|err| {
367-
eprintln!("⚠️ {}", err);
367+
eprintln!("⚠️ {err}");
368368
err
369369
})
370370
.unwrap();
@@ -428,8 +428,8 @@ fn main() {
428428
})
429429
.unwrap();
430430

431-
println!("hmac1 = {:?}", hmac1);
432-
println!("hmac2 = {:?}", hmac2);
431+
println!("hmac1 = {hmac1:?}");
432+
println!("hmac2 = {hmac2:?}");
433433
// They are the same!
434434
assert_eq!(hmac1, hmac2);
435435
}

tss-esapi/examples/hmac.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ fn main() {
164164
})
165165
.unwrap();
166166

167-
println!("hmac1 = {:?}", hmac1);
168-
println!("hmac2 = {:?}", hmac2);
167+
println!("hmac1 = {hmac1:?}");
168+
println!("hmac2 = {hmac2:?}");
169169
// They are the same!
170170
assert_eq!(hmac1, hmac2);
171171
}

0 commit comments

Comments
 (0)