Skip to content

Commit 40a28ca

Browse files
Merge pull request #489 from tgonzalezorlandoarm/tg/backport-fix-lint-errors
Backport lint error fixes for rust 1.75
2 parents 657cf3a + 7654030 commit 40a28ca

29 files changed

+268
-149
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ jobs:
4646
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/all-ubuntu.sh
4747
- name: Run the cross-compilation script
4848
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/cross-compile.sh
49-
- name: Check the documentation
50-
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi ubuntucontainer cargo doc
5149

5250
tests-ubuntu-v3:
5351
name: Ubuntu tests on v3.x.y of tpm2-tss
@@ -68,7 +66,7 @@ jobs:
6866
- name: Build the container
6967
run: docker build -t fedoracontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-fedora
7068
- name: Run the tests
71-
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/all-fedora.sh
69+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env USE_FROZEN_LOCKFILE=1 fedoracontainer dbus-run-session -- /tmp/rust-tss-esapi/tss-esapi/tests/all-fedora.sh
7270

7371
tests-fedora-rawhide:
7472
name: Fedora rawhide tests
@@ -90,3 +88,27 @@ jobs:
9088
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
9189
- name: Run the tests
9290
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
91+
92+
# Check that the documentation builds as well.
93+
docs:
94+
name: Check documentation
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v2
98+
- name: Build the container
99+
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu
100+
- name: Check documentation
101+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi -e RUSTDOCFLAGS="-Dwarnings" ubuntucontainer cargo doc --document-private-items --no-deps
102+
103+
# Check that there are no Clippy lint errors.
104+
clippy:
105+
name: Check Clippy lints
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v2
109+
- name: Build the container
110+
run: docker build -t ubuntucontainer tss-esapi/tests/ --file tss-esapi/tests/Dockerfile-ubuntu --target tpm2-tss
111+
- name: Check Clippy lints MSRV
112+
run: docker run -v $(pwd):/tmp/rust-tss-esapi -w /tmp/rust-tss-esapi/tss-esapi --env RUST_TOOLCHAIN_VERSION=1.66.0 ubuntucontainer /tmp/rust-tss-esapi/tss-esapi/tests/lint-checks.sh
113+
- name: Check Clippy lints latest
114+
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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ At the moment we test (via CI) and support the following Rust compiler versions:
1111
- The latest stable compiler version, as accessible through `rustup`.
1212
- The 1.66 compiler version.
1313
* On Fedora we test with the compiler version included with the Fedora 36 release.
14+
* On Fedora rawhide we test with the compiler version included.
1415

1516
If you need support for other versions of the compiler, get in touch with us to see what we can do!
1617

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/interface_types/session_handles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub enum AuthSession {
9292
}
9393

9494
impl AuthSession {
95-
/// Function that creates a Option<Session>.
95+
/// Function that creates a `Option<Session>`.
9696
///
9797
/// If a Session is created from the NoneHandle
9898
/// then the returned value from the function will be None.

tss-esapi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
overflowing_literals,
1010
path_statements,
1111
patterns_in_fns_without_body,
12-
private_in_public,
1312
unconditional_recursion,
1413
unused,
1514
unused_allocation,

tss-esapi/src/structures/lists/pcr_selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl PcrSelectionList {
5252
Ok(())
5353
}
5454

55-
/// Function for retrieving the PcrSelectionList from Option<PcrSelectionList>
55+
/// Function for retrieving the PcrSelectionList from `Option<PcrSelectionList>`
5656
///
5757
/// This returns an empty list if None is passed
5858
pub fn list_from_option(pcr_list: Option<PcrSelectionList>) -> PcrSelectionList {

tss-esapi/src/utils/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ impl TryFrom<TPMS_CONTEXT> for TpmsContext {
5959
hierarchy: tss2_context.hierarchy,
6060
context_blob: tss2_context.contextBlob.buffer.to_vec(),
6161
};
62-
context.context_blob.truncate(
63-
tss2_context
64-
.contextBlob
65-
.size
66-
.try_into()
67-
.map_err(|_| Error::local_error(WrapperErrorKind::WrongParamSize))?,
68-
);
62+
context
63+
.context_blob
64+
.truncate(tss2_context.contextBlob.size.into());
6965
Ok(context)
7066
}
7167
}
@@ -323,7 +319,7 @@ pub fn get_tpm_vendor(context: &mut Context) -> Result<String> {
323319
]
324320
.iter()
325321
// Retrieve property values
326-
.map(|propid| context.get_tpm_property(*propid))
322+
.map(|prop_id| context.get_tpm_property(*prop_id))
327323
// Collect and return an error if we got one
328324
.collect::<Result<Vec<Option<u32>>>>()?
329325
.iter()

tss-esapi/tests/Dockerfile-fedora-rawhide

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM fedora:rawhide
22

33
RUN dnf install -y \
44
tpm2-tss-devel tpm2-abrmd tpm2-tools \
5-
swtpm swtpm-tools \
5+
swtpm swtpm-tools swtpm-selinux\
66
rust clippy cargo \
77
llvm llvm-devel clang pkg-config \
8-
dbus-daemon
8+
dbus-daemon rust-gobject-sys-devel

tss-esapi/tests/Dockerfile-ubuntu

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
FROM ghcr.io/tpm2-software/ubuntu-18.04:latest
1+
FROM ghcr.io/tpm2-software/ubuntu-18.04:latest AS base
22

3+
FROM base AS rust-toolchain
4+
# Install Rust toolchain
5+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
6+
ENV PATH="/root/.cargo/bin:${PATH}"
7+
8+
FROM rust-toolchain AS tpm2-tss
9+
# Download and install the TSS library
310
ARG TPM2_TSS_VERSION=2.4.6
411
ENV TPM2_TSS_VERSION=$TPM2_TSS_VERSION
512
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
6-
7-
# Download and install the TSS library
813
RUN git clone https://github.com/tpm2-software/tpm2-tss.git --branch $TPM2_TSS_VERSION
914
RUN cd tpm2-tss \
1015
&& ./bootstrap \
@@ -13,13 +18,10 @@ RUN cd tpm2-tss \
1318
&& make install \
1419
&& ldconfig
1520

21+
FROM tpm2-tss AS tpm2-tools
1622
# Download and install TPM2 tools
1723
RUN git clone https://github.com/tpm2-software/tpm2-tools.git --branch 4.1
1824
RUN cd tpm2-tools \
1925
&& ./bootstrap \
2026
&& ./configure --enable-unit \
2127
&& make install
22-
23-
# Install Rust toolchain
24-
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
25-
ENV PATH="/root/.cargo/bin:${PATH}"

tss-esapi/tests/all-fedora.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
# Copyright 2019 Contributors to the Parsec project.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
# This script executes static checks and tests for the tss-esapi crate.
6+
# This script executes tests for the tss-esapi crate.
77
# It can be run inside the container which Dockerfile is in the same folder.
88
#
99
# Usage: ./tests/all.sh
1010

1111
set -euf -o pipefail
1212

13+
if [[ ! -z ${USE_FROZEN_LOCKFILE:+x} ]]; then
14+
# Some versions of Fedora that are used during testing are old
15+
# so in order to prevent any drift from the versions available
16+
# in the old versions the frozen Cargo lock is used.
17+
cp tests/Cargo.lock.frozen ../Cargo.lock
18+
fi
19+
1320
############################
1421
# Run the TPM SWTPM server #
1522
############################
@@ -33,11 +40,6 @@ tpm2-abrmd \
3340
--session \
3441
--flush-all &
3542

36-
##################
37-
# Execute clippy #
38-
##################
39-
cargo clippy --all-targets --all-features -- -D clippy::all -D clippy::cargo
40-
4143
###################
4244
# Build the crate #
4345
###################

0 commit comments

Comments
 (0)