From 4563193950ecab53b74cc3a606d8920fd2a053ef Mon Sep 17 00:00:00 2001 From: kaczmarczyck <43844792+kaczmarczyck@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:29:50 +0200 Subject: [PATCH] Small fixes for consistency (#703) - Adds `Eq` to types that already derive `PartialEq`. - Fixes a comment to match the latest USB changes. - Removes a back-and-forth conversion. --- libraries/opensk/fuzz/fuzz_helper/src/lib.rs | 2 +- libraries/opensk/src/ctap/status_code.rs | 2 +- libraries/opensk/src/env/test/mod.rs | 2 +- src/main.rs | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/opensk/fuzz/fuzz_helper/src/lib.rs b/libraries/opensk/fuzz/fuzz_helper/src/lib.rs index cab68a59..b998e4ad 100644 --- a/libraries/opensk/fuzz/fuzz_helper/src/lib.rs +++ b/libraries/opensk/fuzz/fuzz_helper/src/lib.rs @@ -31,7 +31,7 @@ use opensk::{test_helpers, Ctap, Transport}; const CHANNEL_BROADCAST: ChannelID = [0xFF, 0xFF, 0xFF, 0xFF]; -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum InputType { CborMakeCredentialParameter, CborGetAssertionParameter, diff --git a/libraries/opensk/src/ctap/status_code.rs b/libraries/opensk/src/ctap/status_code.rs index 27126180..1fda8398 100644 --- a/libraries/opensk/src/ctap/status_code.rs +++ b/libraries/opensk/src/ctap/status_code.rs @@ -21,7 +21,7 @@ pub type CtapResult = Result; // For now, only the CTAP2 codes are here, the CTAP1 are not included. #[allow(non_camel_case_types)] #[allow(dead_code)] -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Ctap2StatusCode { CTAP2_OK = 0x00, CTAP1_ERR_INVALID_COMMAND = 0x01, diff --git a/libraries/opensk/src/env/test/mod.rs b/libraries/opensk/src/env/test/mod.rs index 75b072db..4d8ab34b 100644 --- a/libraries/opensk/src/env/test/mod.rs +++ b/libraries/opensk/src/env/test/mod.rs @@ -43,7 +43,7 @@ pub type TestRng = StdRng; impl Rng for TestRng {} -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Eq)] pub struct TestTimer { end_ms: usize, } diff --git a/src/main.rs b/src/main.rs index 069ee580..e9f49eab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,6 @@ extern crate byteorder; extern crate core; extern crate lang_items; -use core::convert::TryFrom; #[cfg(feature = "debug_ctap")] use core::fmt::Write; #[cfg(feature = "with_ctap1")] @@ -151,7 +150,7 @@ fn main() { #[cfg(feature = "with_ctap1")] let num_buttons = Buttons::::count().ok().unwrap(); - // Variable for use in both the send_and_maybe_recv and recv cases. + // Variable for use in both the send and recv cases. let mut usb_endpoint: Option = None; let mut pkt_request = [0; 64]; @@ -189,7 +188,7 @@ fn main() { ctap.env().clock().timestamp_us(), &mut writer, ); - UsbEndpoint::try_from(endpoint as usize).ok() + Some(endpoint) } Err(_) => panic!("Error on USB recv"), };