Skip to content

Commit 752db8c

Browse files
authored
Fixes new clippy lints on the latest nightly (#603)
* Fixes new clippy lints on the latest nightly We didn't see these before because of our old Rust toolchain. * fixes nit
1 parent ca65902 commit 752db8c

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

libraries/opensk/src/api/upgrade_storage/helper.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,12 @@ impl ModRange {
150150
}
151151
}
152152

153+
#[derive(Default)]
153154
pub struct Partition {
154155
ranges: Vec<ModRange>,
155156
}
156157

157158
impl Partition {
158-
pub fn new() -> Partition {
159-
Partition { ranges: Vec::new() }
160-
}
161-
162159
/// Total length of all ranges.
163160
pub fn length(&self) -> usize {
164161
self.ranges.iter().map(|r| r.length()).sum()
@@ -339,7 +336,7 @@ mod tests {
339336

340337
#[test]
341338
fn partition_append() {
342-
let mut partition = Partition::new();
339+
let mut partition = Partition::default();
343340
partition.append(ModRange::new(0x4000, 0x1000));
344341
partition.append(ModRange::new(0x20000, 0x20000));
345342
partition.append(ModRange::new(0x40000, 0x20000));
@@ -349,7 +346,7 @@ mod tests {
349346

350347
#[test]
351348
fn partition_find_address() {
352-
let mut partition = Partition::new();
349+
let mut partition = Partition::default();
353350
partition.append(ModRange::new(0x4000, 0x1000));
354351
partition.append(ModRange::new(0x20000, 0x20000));
355352
partition.append(ModRange::new(0x40000, 0x20000));
@@ -364,7 +361,7 @@ mod tests {
364361

365362
#[test]
366363
fn partition_ranges_from() {
367-
let mut partition = Partition::new();
364+
let mut partition = Partition::default();
368365
partition.append(ModRange::new(0x4000, 0x1000));
369366
partition.append(ModRange::new(0x20000, 0x20000));
370367
partition.append(ModRange::new(0x40000, 0x20000));

libraries/opensk/src/ctap/apdu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl TryFrom<&[u8]> for Apdu {
118118
type Error = ApduStatusCode;
119119

120120
fn try_from(frame: &[u8]) -> Result<Self, ApduStatusCode> {
121-
if frame.len() < APDU_HEADER_LEN as usize {
121+
if frame.len() < APDU_HEADER_LEN {
122122
return Err(ApduStatusCode::SW_WRONG_DATA);
123123
}
124124
// +-----+-----+----+----+

libraries/opensk/src/ctap/client_pin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ mod test {
12241224
),
12251225
// Reject PIN "12'\0'4" (a zero byte at index 2).
12261226
(
1227-
b"12\04".to_vec(),
1227+
[b'1', b'2', 0, b'4'].to_vec(),
12281228
Err(Ctap2StatusCode::CTAP2_ERR_PIN_POLICY_VIOLATION),
12291229
),
12301230
// PINs must be at most 63 bytes long, to allow for a trailing 0u8 padding.

libraries/opensk/src/ctap/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,8 @@ mod test {
15131513
let mut ctap_state = CtapState::<TestEnv>::new(&mut env);
15141514
let info_reponse = ctap_state.process_command(&mut env, &[0x04], DUMMY_CHANNEL);
15151515

1516+
// Fails when removing `to_vec` for `SUPPORTED_CRED_PARAMS` as linted.
1517+
#[allow(clippy::unnecessary_to_owned)]
15161518
let expected_cbor = cbor_map_options! {
15171519
0x01 => cbor_array_vec![vec![
15181520
#[cfg(feature = "with_ctap1")]

src/env/tock/storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl TockUpgradeStorage {
261261
pub fn new() -> StorageResult<TockUpgradeStorage> {
262262
let mut locations = TockUpgradeStorage {
263263
page_size: get_info(command_nr::get_info_nr::PAGE_SIZE, 0)?,
264-
partition: Partition::new(),
264+
partition: Partition::default(),
265265
metadata: ModRange::new_empty(),
266266
running_metadata: ModRange::new_empty(),
267267
identifier: Self::PARTITION_ADDRESS_A as u32,

0 commit comments

Comments
 (0)