Skip to content

Commit e86099b

Browse files
authored
Merge pull request #611 from Superhepper/Lint-Problems-1.92-v2
Fixes lint problems reported Clippy in rust version 1.92
2 parents 8c856a7 + aefd1e3 commit e86099b

File tree

15 files changed

+46
-47
lines changed

15 files changed

+46
-47
lines changed

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.74.0"
1+
msrv = "1.76.0"

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
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
34-
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.74.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
34+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.76.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
3535
# All in one job as I think it is a big overhead to build and run the Docker
3636
# container?
3737
tests-ubuntu:
@@ -118,7 +118,7 @@ jobs:
118118
- name: Build the container
119119
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss
120120
- name: Check Clippy lints MSRV
121-
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.74.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh
121+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.76.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh
122122
- name: Check Clippy lints latest
123123
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh
124124

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ At the moment we test (via CI) and support the following Rust compiler versions:
99

1010
* On Ubuntu we test with:
1111
- The latest stable compiler version, as accessible through `rustup`.
12-
- The 1.74.0 compiler version.
12+
- The 1.76.0 compiler version.
1313
* On Fedora we test with the compiler version included with the Fedora 38 release.
1414
* On Fedora rawhide we test with the compiler version included.
1515

tss-esapi-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "Apache-2.0"
1111
repository = "https://github.com/parallaxsecond/rust-tss-esapi"
1212
documentation = "https://docs.rs/crate/tss-esapi-sys"
1313
links = "tss2-esys"
14-
rust-version = "1.74.0"
14+
rust-version = "1.76.0"
1515

1616
[build-dependencies]
1717
bindgen = { version = "0.72.0", optional = true }

tss-esapi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ categories = ["api-bindings", "external-ffi-bindings", "cryptography"]
1010
license = "Apache-2.0"
1111
repository = "https://github.com/parallaxsecond/rust-tss-esapi"
1212
documentation = "https://docs.rs/crate/tss-esapi"
13-
rust-version = "1.74.0"
13+
rust-version = "1.76.0"
1414

1515
[[example]]
1616
name = "hmac"

tss-esapi/examples/duplication.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,8 @@ fn main() {
215215
None,
216216
)
217217
})
218-
.map_err(|err| {
218+
.inspect_err(|err| {
219219
eprintln!("⚠️ {err}");
220-
err
221220
})
222221
.unwrap();
223222

@@ -268,9 +267,8 @@ fn main() {
268267
.execute_with_nullauth_session(|ctx| {
269268
ctx.create(loaded_storage_key, hmac_public, None, None, None, None)
270269
})
271-
.map_err(|err| {
270+
.inspect_err(|err| {
272271
eprintln!("⚠️ {err}");
273-
err
274272
})
275273
.unwrap();
276274

@@ -370,9 +368,8 @@ fn main() {
370368
// Return the duplicate result.
371369
result
372370
})
373-
.map_err(|err| {
371+
.inspect_err(|err| {
374372
eprintln!("⚠️ {err}");
375-
err
376373
})
377374
.unwrap();
378375

tss-esapi/examples/duplication_secret.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ fn main() {
216216
None,
217217
)
218218
})
219-
.map_err(|err| {
219+
.inspect_err(|err| {
220220
eprintln!("⚠️ {err}");
221-
err
222221
})
223222
.unwrap();
224223

@@ -267,9 +266,8 @@ fn main() {
267266
.execute_with_nullauth_session(|ctx| {
268267
ctx.create(loaded_storage_key, hmac_public, None, None, None, None)
269268
})
270-
.map_err(|err| {
269+
.inspect_err(|err| {
271270
eprintln!("⚠️ {err}");
272-
err
273271
})
274272
.unwrap();
275273

@@ -363,9 +361,8 @@ fn main() {
363361
// Return the duplicate result.
364362
result
365363
})
366-
.map_err(|err| {
364+
.inspect_err(|err| {
367365
eprintln!("⚠️ {err}");
368-
err
369366
})
370367
.unwrap();
371368

tss-esapi/src/abstraction/nv.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ fn get_nv_index_info(
5353
.and_then(|mut object_handle| {
5454
context
5555
.nv_read_public(NvIndexHandle::from(object_handle))
56-
.map_err(|e| {
56+
.inspect_err(|_| {
5757
let _ = context.tr_close(&mut object_handle);
58-
e
5958
})
6059
.and_then(|(nv_public, name)| {
6160
context.tr_close(&mut object_handle)?;

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ impl Context {
151151
) -> Result<PublicKeyRsa> {
152152
let mut out_data_ptr = null_mut();
153153
let potential_label = label.into().map(|v| v.into());
154-
let label_ptr = potential_label.as_ref().map_or_else(null, |v| v);
154+
let label_ptr = potential_label
155+
.as_ref()
156+
.map_or_else(null, std::ptr::from_ref);
155157
ReturnCode::ensure_success(
156158
unsafe {
157159
Esys_RSA_Encrypt(
@@ -310,7 +312,9 @@ impl Context {
310312
) -> Result<PublicKeyRsa> {
311313
let mut message_ptr = null_mut();
312314
let potential_label = label.into().map(|v| v.into());
313-
let label_ptr = potential_label.as_ref().map_or_else(null, |v| v);
315+
let label_ptr = potential_label
316+
.as_ref()
317+
.map_or_else(null, std::ptr::from_ref);
314318
ReturnCode::ensure_success(
315319
unsafe {
316320
Esys_RSA_Decrypt(

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ impl Context {
234234
}
235235
let mut object_handle = ObjectHandle::None.into();
236236
let potential_private_in = potential_private.map(|v| v.try_into()).transpose()?;
237+
let private_in_ptr = potential_private_in
238+
.as_ref()
239+
.map_or_else(null, std::ptr::from_ref);
237240
let public_in = public.try_into()?;
238241
ReturnCode::ensure_success(
239242
unsafe {
@@ -242,7 +245,7 @@ impl Context {
242245
self.optional_session_1(),
243246
self.optional_session_2(),
244247
self.optional_session_3(),
245-
potential_private_in.as_ref().map_or_else(null, |v| v),
248+
private_in_ptr,
246249
&public_in,
247250
if cfg!(hierarchy_is_esys_tr) {
248251
ObjectHandle::from(hierarchy).into()

0 commit comments

Comments
 (0)