Skip to content

Commit f8824ab

Browse files
authored
Fixes clippy warnings from nightly (#747)
* Fixes clippy warnings from nightly * Bumps the Rust version to what we actually use
1 parent 92f2120 commit f8824ab

File tree

13 files changed

+30
-33
lines changed

13 files changed

+30
-33
lines changed

libraries/cbor/src/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a> Reader<'a> {
7171
&mut self,
7272
remaining_depth: Option<i8>,
7373
) -> Result<Value, DecoderError> {
74-
if remaining_depth.map_or(false, |d| d < 0) {
74+
if remaining_depth.is_some_and(|d| d < 0) {
7575
return Err(DecoderError::TooMuchNesting);
7676
}
7777

libraries/cbor/src/writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a> Writer<'a> {
5757
value: Value,
5858
remaining_depth: Option<i8>,
5959
) -> Result<(), EncoderError> {
60-
if remaining_depth.map_or(false, |d| d < 0) {
60+
if remaining_depth.is_some_and(|d| d < 0) {
6161
return Err(EncoderError::TooMuchNesting);
6262
}
6363
let type_label = value.0.type_label();

libraries/opensk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ authors = [
99
]
1010
license = "Apache-2.0"
1111
edition = "2018"
12-
rust-version = "1.66"
12+
rust-version = "1.80"
1313

1414
[dependencies]
1515
sk-cbor = { path = "../cbor" }

libraries/opensk/src/api/crypto/rust_crypto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use std::sync::{Mutex, MutexGuard};
4444
static BUSY: Mutex<()> = Mutex::new(());
4545
#[cfg(test)]
4646
thread_local! {
47-
static BUSY_GUARD: RefCell<Option<MutexGuard<'static, ()>>> = RefCell::new(None);
47+
static BUSY_GUARD: RefCell<Option<MutexGuard<'static, ()>>> = const { RefCell::new(None) };
4848
}
4949

5050
pub struct SoftwareCrypto;

libraries/opensk/src/api/fingerprint.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ pub trait Fingerprint {
5757
///
5858
/// This function returns:
5959
/// - The `Ctap2EnrollFeedback` contains expected errors from the
60-
/// fingerprint capture process.
60+
/// fingerprint capture process.
6161
/// - The expected number of remaining samples.
62-
/// If the sensor finished template creation, return a hardware ID for this
63-
/// template. This ID is different from the FIDO template ID, but they are
62+
/// - Eventually, a hardware ID for this template.
63+
///
64+
/// The template ID must be returned until remaining samples is 0.
65+
/// When or how often it is returned is up to the implementation, but it
66+
/// needs to be consistent if returned more than once.
67+
/// This ID is different from the FIDO template ID, but they are
6468
/// mapped to each other in OpenSK. This should happen exactly when the
6569
/// returned number of `remainingSamples` is 0.
6670
///

libraries/opensk/src/ctap/client_pin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ impl<E: Env> ClientPin<E> {
567567
/// - verified with the shared secret and salt_auth,
568568
/// - decrypted with the shared secret,
569569
/// - HMAC'ed with cred_random.
570+
///
570571
/// The length of the output matches salt_enc and has to be 1 or 2 blocks of
571572
/// 32 byte.
572573
pub fn process_hmac_secret(

libraries/opensk/src/ctap/ctap1.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ impl TryFrom<&[u8]> for U2fCommand {
7878
type Error = Ctap1StatusCode;
7979

8080
fn try_from(message: &[u8]) -> Result<Self, Ctap1StatusCode> {
81-
let apdu: Apdu = match Apdu::try_from(message) {
82-
Ok(apdu) => apdu,
83-
Err(apdu_status_code) => return Err(apdu_status_code),
84-
};
85-
81+
let apdu = Apdu::try_from(message)?;
8682
let lc = apdu.lc as usize;
8783

8884
// ISO7816 APDU Header format. Each cell is 1 byte. Note that the CTAP flavor always

libraries/opensk/src/ctap/data_formats.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,18 +1260,12 @@ mod test {
12601260

12611261
#[test]
12621262
fn test_extract_unsigned_limits() {
1263+
assert_eq!(extract_unsigned(cbor_unsigned!(u64::MAX)), Ok(u64::MAX));
12631264
assert_eq!(
1264-
extract_unsigned(cbor_unsigned!(std::u64::MAX)),
1265-
Ok(std::u64::MAX)
1266-
);
1267-
assert_eq!(
1268-
extract_unsigned(cbor_unsigned!((std::i64::MAX as u64) + 1)),
1269-
Ok((std::i64::MAX as u64) + 1)
1270-
);
1271-
assert_eq!(
1272-
extract_unsigned(cbor_int!(std::i64::MAX)),
1273-
Ok(std::i64::MAX as u64)
1265+
extract_unsigned(cbor_unsigned!((i64::MAX as u64) + 1)),
1266+
Ok((i64::MAX as u64) + 1)
12741267
);
1268+
assert_eq!(extract_unsigned(cbor_int!(i64::MAX)), Ok(i64::MAX as u64));
12751269
assert_eq!(extract_unsigned(cbor_int!(123)), Ok(123));
12761270
assert_eq!(extract_unsigned(cbor_int!(1)), Ok(1));
12771271
assert_eq!(extract_unsigned(cbor_int!(0)), Ok(0));
@@ -1284,7 +1278,7 @@ mod test {
12841278
Err(CTAP2_ERR_CBOR_UNEXPECTED_TYPE)
12851279
);
12861280
assert_eq!(
1287-
extract_unsigned(cbor_int!(std::i64::MIN)),
1281+
extract_unsigned(cbor_int!(i64::MIN)),
12881282
Err(CTAP2_ERR_CBOR_UNEXPECTED_TYPE)
12891283
);
12901284
}
@@ -1318,20 +1312,20 @@ mod test {
13181312
#[test]
13191313
fn test_extract_integer_limits() {
13201314
assert_eq!(
1321-
extract_integer(cbor_unsigned!(std::u64::MAX)),
1315+
extract_integer(cbor_unsigned!(u64::MAX)),
13221316
Err(CTAP2_ERR_CBOR_UNEXPECTED_TYPE)
13231317
);
13241318
assert_eq!(
1325-
extract_integer(cbor_unsigned!((std::i64::MAX as u64) + 1)),
1319+
extract_integer(cbor_unsigned!((i64::MAX as u64) + 1)),
13261320
Err(CTAP2_ERR_CBOR_UNEXPECTED_TYPE)
13271321
);
1328-
assert_eq!(extract_integer(cbor_int!(std::i64::MAX)), Ok(std::i64::MAX));
1322+
assert_eq!(extract_integer(cbor_int!(i64::MAX)), Ok(i64::MAX));
13291323
assert_eq!(extract_integer(cbor_int!(123)), Ok(123));
13301324
assert_eq!(extract_integer(cbor_int!(1)), Ok(1));
13311325
assert_eq!(extract_integer(cbor_int!(0)), Ok(0));
13321326
assert_eq!(extract_integer(cbor_int!(-1)), Ok(-1));
13331327
assert_eq!(extract_integer(cbor_int!(-123)), Ok(-123));
1334-
assert_eq!(extract_integer(cbor_int!(std::i64::MIN)), Ok(std::i64::MIN));
1328+
assert_eq!(extract_integer(cbor_int!(i64::MIN)), Ok(i64::MIN));
13351329
}
13361330

13371331
#[test]

libraries/opensk/src/ctap/large_blobs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ mod test {
478478

479479
let large_blobs_params = AuthenticatorLargeBlobsParameters {
480480
get: None,
481-
set: Some(large_blob.to_vec()),
481+
set: Some(large_blob),
482482
offset: 0,
483483
length: Some(BLOB_LEN),
484484
pin_uv_auth_param: None,

libraries/opensk/src/ctap/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3490,7 +3490,7 @@ mod test {
34903490
// This TestEnv always returns successful user_presence checks.
34913491
let mut env = TestEnv::default();
34923492
let response = check_user_presence(&mut env, DUMMY_CHANNEL);
3493-
assert!(matches!(response, Ok(_)));
3493+
assert!(response.is_ok());
34943494
}
34953495

34963496
#[test]

0 commit comments

Comments
 (0)