Skip to content

Commit

Permalink
cleanup more lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
micolous committed Jul 6, 2023
1 parent fee7d12 commit fd2bd76
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion fido-hid-rs/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, path::PathBuf};

const LINUX_WRAPPER_H: &'static str = "src/linux/wrapper.h";
const LINUX_WRAPPER_H: &str = "src/linux/wrapper.h";

fn linux_headers() {
println!("cargo:rerun-if-changed={LINUX_WRAPPER_H}");
Expand Down
2 changes: 1 addition & 1 deletion webauthn-authenticator-rs/examples/authenticate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl From<UvPolicy> for UserVerificationPolicy {
async fn select_transport<U: UiCallback>(ui: &U) -> impl AuthenticatorBackend + '_ {
use futures::StreamExt;

let mut reader = AnyTransport::new().await.unwrap();
let reader = AnyTransport::new().await.unwrap();
info!("Using reader: {:?}", reader);

match reader.watch().await {
Expand Down
2 changes: 1 addition & 1 deletion webauthn-authenticator-rs/src/ctap2/ctap20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ impl<'a, T: Token, U: UiCallback> Ctap20Authenticator<'a, T, U> {
}

error!("got unexpected OK response from authenticator");
return Err(WebauthnCError::Internal);
Err(WebauthnCError::Internal)
}
}

Expand Down
6 changes: 2 additions & 4 deletions webauthn-authenticator-rs/src/ctap2/ctap21.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use webauthn_rs_proto::UserVerificationPolicy;
use crate::{error::WebauthnCError, transport::Token, ui::UiCallback};

use super::{
commands::{GetInfoResponse, SelectionRequest},
ctap21_bio::BiometricAuthenticatorInfo,
ctap21_cred::CredentialManagementAuthenticatorInfo,
internal::CtapAuthenticatorVersion,
commands::GetInfoResponse, ctap21_bio::BiometricAuthenticatorInfo,
ctap21_cred::CredentialManagementAuthenticatorInfo, internal::CtapAuthenticatorVersion,
Ctap20Authenticator,
};

Expand Down
2 changes: 1 addition & 1 deletion webauthn-authenticator-rs/src/ctap2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ use std::ops::{Deref, DerefMut};
use std::pin::Pin;

use futures::stream::{BoxStream, FuturesUnordered};
use futures::{select, Future, Stream, StreamExt};
use futures::{select, Future, StreamExt};

use crate::authenticator_hashed::AuthenticatorBackendHashedClientData;
use crate::error::WebauthnCError;
Expand Down
20 changes: 9 additions & 11 deletions webauthn-authenticator-rs/src/nfc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use async_trait::async_trait;
use futures::executor::block_on;
use futures::{stream::BoxStream, Stream};
use tokio::sync::mpsc;
use tokio::task::{spawn_blocking, JoinHandle};
use tokio::task::spawn_blocking;
use tokio_stream::wrappers::ReceiverStream;

use pcsc::*;
Expand Down Expand Up @@ -130,24 +130,20 @@ fn ignored_reader(reader_name: &CStr) -> bool {
}

struct NFCDeviceWatcher {
handle: JoinHandle<Result<(), WebauthnCError>>,
stream: ReceiverStream<TokenEvent<NFCCard>>,
}

impl NFCDeviceWatcher {
fn new(ctx: Context) -> Result<Self, WebauthnCError> {
fn new(ctx: Context) -> Self {
let (tx, rx) = mpsc::channel(16);
let stream = ReceiverStream::from(rx);

let handle = spawn_blocking(move || {
spawn_blocking(move || {
let mut enumeration_complete = false;
let mut reader_states: Vec<ReaderState> =
vec![ReaderState::new(PNP_NOTIFICATION(), State::UNAWARE)];

'main: loop {
if tx.is_closed() {
break;
}
'main: while !tx.is_closed() {
// trace!(
// "{} known reader(s), pruning ignored readers",
// reader_states.len()
Expand Down Expand Up @@ -282,6 +278,8 @@ impl NFCDeviceWatcher {
// Channel lost!
break 'main;
}
} else {
// Unhandled state transition
}
}

Expand All @@ -304,10 +302,10 @@ impl NFCDeviceWatcher {
}
}

Ok(())
Ok::<(), WebauthnCError>(())
});

Ok(Self { handle, stream })
Self { stream }
}
}

Expand Down Expand Up @@ -382,7 +380,7 @@ impl<'b> Transport<'b> for NFCTransport {
type Token = NFCCard;

async fn watch(&self) -> Result<BoxStream<TokenEvent<Self::Token>>, WebauthnCError> {
let watcher = NFCDeviceWatcher::new(self.ctx.clone())?;
let watcher = NFCDeviceWatcher::new(self.ctx.clone());

Ok(Box::pin(watcher))
}
Expand Down
4 changes: 2 additions & 2 deletions webauthn-authenticator-rs/src/stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod authenticator {
pub mod fido_hid_rs {
const HID_RPT_SIZE: usize = 64;
const HID_RPT_SEND_SIZE: usize = HID_RPT_SIZE + 1;

pub type HidReportBytes = [u8; HID_RPT_SIZE];
pub type HidSendReportBytes = [u8; HID_RPT_SEND_SIZE];
pub trait USBDevice {}
Expand All @@ -30,7 +30,7 @@ pub mod fido_hid_rs {
}
pub struct USBDeviceInfoImpl {}
impl USBDeviceInfo for USBDeviceInfoImpl {
type Id = String;
type Id = String;
}
pub trait USBDeviceManager {}
pub struct USBDeviceManagerImpl {}
Expand Down
21 changes: 12 additions & 9 deletions webauthn-authenticator-rs/src/transport/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,41 +150,44 @@ impl<'b> Transport<'b> for AnyTransport {
while !bluetooth.is_terminated() || !nfc.is_terminated() || !usb.is_terminated() {
tokio::select! {
Some(b) = bluetooth.next() => {
let a: TokenEvent<AnyToken> = b.into();
if matches!(a, TokenEvent::EnumerationComplete) {
#[cfg(feature = "bluetooth")]
let b: TokenEvent<AnyToken> = b.into();
if matches!(b, TokenEvent::EnumerationComplete) {
if nfc_complete && usb_complete {
trace!("Sending enumeration complete from Bluetooth");
yield TokenEvent::EnumerationComplete;
}
bluetooth_complete = true;
} else {
yield a;
yield b;
}
}

Some(n) = nfc.next() => {
let a: TokenEvent<AnyToken> = n.into();
if matches!(a, TokenEvent::EnumerationComplete) {
#[cfg(feature = "nfc")]
let n: TokenEvent<AnyToken> = n.into();
if matches!(n, TokenEvent::EnumerationComplete) {
if bluetooth_complete && usb_complete {
trace!("Sending enumeration complete from NFC");
yield TokenEvent::EnumerationComplete;
}
nfc_complete = true;
} else {
yield a;
yield n;
}
}

Some(u) = usb.next() => {
let a: TokenEvent<AnyToken> = u.into();
if matches!(a, TokenEvent::EnumerationComplete) {
#[cfg(feature = "usb")]
let u: TokenEvent<AnyToken> = u.into();
if matches!(u, TokenEvent::EnumerationComplete) {
if bluetooth_complete && nfc_complete {
trace!("Sending enumeration complete from USB");
yield TokenEvent::EnumerationComplete;
}
usb_complete = true;
} else {
yield a;
yield u;
}
}

Expand Down

0 comments on commit fd2bd76

Please sign in to comment.