Skip to content

Commit 767c685

Browse files
committed
Fix MSRV and Fedora builds
Remove inline formatting and add Eq alongside PartialEq. Signed-off-by: Ionut Mihalcea <[email protected]>
1 parent 10a626a commit 767c685

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

tss-esapi-sys/build.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn main() {
5757
}
5858
}
5959

60+
#[allow(clippy::uninlined_format_args)]
6061
#[cfg(feature = "generate-bindings")]
6162
pub fn generate_from_system(esapi_out: PathBuf) {
6263
pkg_config::Config::new()
@@ -96,13 +97,13 @@ pub fn generate_from_system(esapi_out: PathBuf) {
9697
.expect("Error converting OsString to String.");
9798

9899
bindgen::Builder::default()
99-
.clang_arg(format!("-I{tss2_esys_include_path}/tss2/"))
100-
.clang_arg(format!("-I{tss2_tctildr_include_path}/tss2/"))
101-
.clang_arg(format!("-I{tss2_mu_include_path}/tss2/"))
100+
.clang_arg(format!("-I{}/tss2/", tss2_esys_include_path))
101+
.clang_arg(format!("-I{}/tss2/", tss2_tctildr_include_path))
102+
.clang_arg(format!("-I{}/tss2/", tss2_mu_include_path))
102103
.rustfmt_bindings(true)
103-
.header(format!("{tss2_esys_include_path}/tss2/tss2_esys.h"))
104-
.header(format!("{tss2_tctildr_include_path}/tss2/tss2_tctildr.h"))
105-
.header(format!("{tss2_mu_include_path}/tss2/tss2_mu.h"))
104+
.header(format!("{}/tss2/tss2_esys.h", tss2_esys_include_path))
105+
.header(format!("{}/tss2/tss2_tctildr.h", tss2_tctildr_include_path))
106+
.header(format!("{}/tss2/tss2_mu.h", tss2_mu_include_path))
106107
// See this issue: https://github.com/parallaxsecond/rust-cryptoki/issues/12
107108
.blocklist_type("max_align_t")
108109
.generate_comments(false)

tss-esapi/src/constants/response_code.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bitfield! {
1616
}
1717

1818
bitfield! {
19-
#[derive(PartialEq, Copy, Clone)]
19+
#[derive(PartialEq, Eq, Copy, Clone)]
2020
pub struct FormatZeroResponseCode(TSS2_RC);
2121
impl Debug;
2222
error_number, _: 6, 0;
@@ -36,7 +36,7 @@ impl std::fmt::Display for FormatZeroResponseCode {
3636
impl std::error::Error for FormatZeroResponseCode {}
3737

3838
bitfield! {
39-
#[derive(PartialEq, Copy, Clone)]
39+
#[derive(PartialEq, Eq, Copy, Clone)]
4040
pub struct FormatOneResponseCode(TSS2_RC);
4141
impl Debug;
4242
error_number, _: 5, 0;
@@ -56,7 +56,7 @@ impl std::error::Error for FormatOneResponseCode {}
5656

5757
/// Rust native representation of the TSS2 response codes as defined in the spec.
5858
#[allow(clippy::module_name_repetitions)]
59-
#[derive(Copy, Clone, PartialEq, Debug)]
59+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
6060
pub enum Tss2ResponseCode {
6161
Success,
6262
FormatZero(FormatZeroResponseCode),
@@ -234,7 +234,7 @@ impl Tss2ResponseCode {
234234
}
235235

236236
/// Rust enum representation of TSS 2 error codes.
237-
#[derive(PartialEq, Copy, Clone, Debug)]
237+
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
238238
pub enum Tss2ResponseCodeKind {
239239
// FormatZero errors
240240
Success,

tss-esapi/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::tss2_esys::TSS2_RC;
77
/// layer.
88
pub type Result<T> = std::result::Result<T, Error>;
99

10-
#[derive(Copy, Clone, PartialEq, Debug)]
10+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
1111
pub enum Error {
1212
WrapperError(WrapperErrorKind),
1313
Tss2Error(Tss2ResponseCode),
@@ -51,7 +51,7 @@ impl std::error::Error for Error {
5151
}
5252

5353
/// List of error types that might occur in the wrapper.
54-
#[derive(Copy, Clone, PartialEq, Debug)]
54+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
5555
pub enum WrapperErrorKind {
5656
/// Returned when a size or length-defined parameter does not conform with the size
5757
/// restrictions for it.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::ops::Deref;
1111
///
1212
/// # Details
1313
/// This corresponds to `TPML_ECC_CURVE`.
14-
#[derive(Debug, Clone, Default, PartialEq)]
14+
#[derive(Debug, Clone, Default, PartialEq, Eq)]
1515
pub struct EccCurveList {
1616
ecc_curves: Vec<EccCurveIdentifier>,
1717
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::ops::Deref;
1111
///
1212
/// # Details
1313
/// This corresponds to `TPML_HANDLE`.
14-
#[derive(Debug, Clone, Default, PartialEq)]
14+
#[derive(Debug, Clone, Default, PartialEq, Eq)]
1515
pub struct HandleList {
1616
handles: Vec<TpmHandle>,
1717
}

tss-esapi/src/tcti_ldr.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl Drop for TctiInfo {
126126

127127
/// Placeholder TCTI types that can be used when initialising a `Context` to determine which
128128
/// interface will be used to communicate with the TPM.
129-
#[derive(Clone, Debug, PartialEq)]
129+
#[derive(Clone, Debug, PartialEq, Eq)]
130130
pub enum TctiNameConf {
131131
/// Connect to a TPM available as a device node on the system
132132
///
@@ -166,6 +166,7 @@ impl TctiNameConf {
166166
}
167167
}
168168

169+
#[allow(clippy::uninlined_format_args)]
169170
impl TryFrom<TctiNameConf> for CString {
170171
type Error = Error;
171172

@@ -206,7 +207,7 @@ impl TryFrom<TctiNameConf> for CString {
206207
if tcti_conf.is_empty() {
207208
CString::new(tcti_name).or(Err(Error::WrapperError(WrapperErrorKind::InvalidParam)))
208209
} else {
209-
CString::new(format!("{tcti_name}:{tcti_conf}"))
210+
CString::new(format!("{}:{}", tcti_name, tcti_conf))
210211
.or(Err(Error::WrapperError(WrapperErrorKind::InvalidParam)))
211212
}
212213
}
@@ -314,7 +315,7 @@ fn validate_from_str_tcti() {
314315
///
315316
/// The default configuration uses the library default of
316317
/// `/dev/tpm0`.
317-
#[derive(Clone, Debug, PartialEq)]
318+
#[derive(Clone, Debug, PartialEq, Eq)]
318319
pub struct DeviceConfig {
319320
/// Path to the device node to connect to
320321
///
@@ -356,7 +357,7 @@ fn validate_from_str_device_config() {
356357
/// Configuration for an Mssim TCTI context
357358
///
358359
/// The default configuration will point to `localhost:2321`
359-
#[derive(Clone, Debug, PartialEq)]
360+
#[derive(Clone, Debug, PartialEq, Eq)]
360361
pub struct NetworkTPMConfig {
361362
/// Address of the server to connect to
362363
///
@@ -456,7 +457,7 @@ fn validate_from_str_networktpm_config() {
456457
/// Address of a TPM server
457458
///
458459
/// The default value is `localhost`
459-
#[derive(Clone, Debug, PartialEq)]
460+
#[derive(Clone, Debug, PartialEq, Eq)]
460461
pub enum ServerAddress {
461462
/// IPv4 or IPv6 address
462463
Ip(IpAddr),
@@ -499,7 +500,7 @@ impl Default for ServerAddress {
499500
}
500501

501502
/// Configuration for a TABRMD TCTI context
502-
#[derive(Clone, Debug, PartialEq)]
503+
#[derive(Clone, Debug, PartialEq, Eq)]
503504
pub struct TabrmdConfig {
504505
/// Bus name to be used by TABRMD
505506
///
@@ -556,7 +557,7 @@ impl FromStr for TabrmdConfig {
556557
}
557558

558559
/// DBus type for usage with TABRMD
559-
#[derive(Copy, Clone, Debug, PartialEq)]
560+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
560561
pub enum BusType {
561562
System,
562563
Session,

0 commit comments

Comments
 (0)