Skip to content

Fixes new clippy lints on the latest nightly #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions libraries/opensk/src/api/upgrade_storage/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,12 @@ impl ModRange {
}
}

#[derive(Default)]
pub struct Partition {
ranges: Vec<ModRange>,
}

impl Partition {
pub fn new() -> Partition {
Partition { ranges: Vec::new() }
}

/// Total length of all ranges.
pub fn length(&self) -> usize {
self.ranges.iter().map(|r| r.length()).sum()
Expand Down Expand Up @@ -339,7 +336,7 @@ mod tests {

#[test]
fn partition_append() {
let mut partition = Partition::new();
let mut partition = Partition::default();
partition.append(ModRange::new(0x4000, 0x1000));
partition.append(ModRange::new(0x20000, 0x20000));
partition.append(ModRange::new(0x40000, 0x20000));
Expand All @@ -349,7 +346,7 @@ mod tests {

#[test]
fn partition_find_address() {
let mut partition = Partition::new();
let mut partition = Partition::default();
partition.append(ModRange::new(0x4000, 0x1000));
partition.append(ModRange::new(0x20000, 0x20000));
partition.append(ModRange::new(0x40000, 0x20000));
Expand All @@ -364,7 +361,7 @@ mod tests {

#[test]
fn partition_ranges_from() {
let mut partition = Partition::new();
let mut partition = Partition::default();
partition.append(ModRange::new(0x4000, 0x1000));
partition.append(ModRange::new(0x20000, 0x20000));
partition.append(ModRange::new(0x40000, 0x20000));
Expand Down
2 changes: 1 addition & 1 deletion libraries/opensk/src/ctap/apdu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl TryFrom<&[u8]> for Apdu {
type Error = ApduStatusCode;

fn try_from(frame: &[u8]) -> Result<Self, ApduStatusCode> {
if frame.len() < APDU_HEADER_LEN as usize {
if frame.len() < APDU_HEADER_LEN {
return Err(ApduStatusCode::SW_WRONG_DATA);
}
// +-----+-----+----+----+
Expand Down
2 changes: 1 addition & 1 deletion libraries/opensk/src/ctap/client_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ mod test {
),
// Reject PIN "12'\0'4" (a zero byte at index 2).
(
b"12\04".to_vec(),
[b'1', b'2', 0, b'4'].to_vec(),
Err(Ctap2StatusCode::CTAP2_ERR_PIN_POLICY_VIOLATION),
),
// PINs must be at most 63 bytes long, to allow for a trailing 0u8 padding.
Expand Down
2 changes: 2 additions & 0 deletions libraries/opensk/src/ctap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,8 @@ mod test {
let mut ctap_state = CtapState::<TestEnv>::new(&mut env);
let info_reponse = ctap_state.process_command(&mut env, &[0x04], DUMMY_CHANNEL);

// Fails when removing `to_vec` for `SUPPORTED_CRED_PARAMS` as linted.
#[allow(clippy::unnecessary_to_owned)]
let expected_cbor = cbor_map_options! {
0x01 => cbor_array_vec![vec![
#[cfg(feature = "with_ctap1")]
Expand Down
2 changes: 1 addition & 1 deletion src/env/tock/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl TockUpgradeStorage {
pub fn new() -> StorageResult<TockUpgradeStorage> {
let mut locations = TockUpgradeStorage {
page_size: get_info(command_nr::get_info_nr::PAGE_SIZE, 0)?,
partition: Partition::new(),
partition: Partition::default(),
metadata: ModRange::new_empty(),
running_metadata: ModRange::new_empty(),
identifier: Self::PARTITION_ADDRESS_A as u32,
Expand Down