diff --git a/neqo-common/src/codec.rs b/neqo-common/src/codec.rs index 5b62e3fad..bb1524384 100644 --- a/neqo-common/src/codec.rs +++ b/neqo-common/src/codec.rs @@ -123,14 +123,13 @@ impl<'a> Decoder<'a> { Some(l) => l, _ => return None, }; - match usize::try_from(len) { - Ok(l) => self.decode(l), - _ => { - // sizeof(usize) < sizeof(u64) and the value is greater than - // usize can hold. Throw away the rest of the input. - self.offset = self.buf.len(); - None - } + if let Ok(l) = usize::try_from(len) { + self.decode(l) + } else { + // sizeof(usize) < sizeof(u64) and the value is greater than + // usize can hold. Throw away the rest of the input. + self.offset = self.buf.len(); + None } } diff --git a/neqo-crypto/src/auth.rs b/neqo-crypto/src/auth.rs index ee3b03744..44b5502dd 100644 --- a/neqo-crypto/src/auth.rs +++ b/neqo-crypto/src/auth.rs @@ -92,7 +92,6 @@ impl From for AuthenticationStatus { mozpkix::MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED => { Self::PolicyRejection } - sec::SEC_ERROR_LIBRARY_FAILURE => Self::Unknown, _ => Self::Unknown, } } diff --git a/neqo-transport/src/connection.rs b/neqo-transport/src/connection.rs index ae97acf23..d3977997b 100644 --- a/neqo-transport/src/connection.rs +++ b/neqo-transport/src/connection.rs @@ -102,6 +102,7 @@ pub enum State { // Implement Ord so that we can enforce monotonic state progression. impl PartialOrd for State { + #[allow(clippy::match_same_arms)] // Lint bug: rust-lang/rust-clippy#860 fn partial_cmp(&self, other: &Self) -> Option { if std::mem::discriminant(self) == std::mem::discriminant(other) { return Some(Ordering::Equal); @@ -141,8 +142,8 @@ struct Path { impl Path { // Used to create a path when receiving a packet. - pub fn new(d: &Datagram, remote_cid: ConnectionId) -> Path { - Path { + pub fn new(d: &Datagram, remote_cid: ConnectionId) -> Self { + Self { local: d.destination(), remote: d.source(), local_cids: Vec::new(), @@ -296,9 +297,9 @@ impl Connection { protocols: &[impl AsRef], local_addr: SocketAddr, remote_addr: SocketAddr, - ) -> Res { + ) -> Res { let dcid = ConnectionId::generate(CID_LENGTH); - let mut c = Connection::new( + let mut c = Self::new( Role::Client, Client::new(server_name)?.into(), None, @@ -319,8 +320,8 @@ impl Connection { certs: &[impl AsRef], protocols: &[impl AsRef], anti_replay: &AntiReplay, - ) -> Res { - Ok(Connection::new( + ) -> Res { + Ok(Self::new( Role::Server, Server::new(certs)?.into(), Some(anti_replay), @@ -355,13 +356,13 @@ impl Connection { anti_replay: Option<&AntiReplay>, protocols: &[impl AsRef], paths: Option, - ) -> Connection { + ) -> Self { let tphandler = Rc::new(RefCell::new(TransportParametersHandler::default())); - Connection::set_tp_defaults(&mut tphandler.borrow_mut().local); + Self::set_tp_defaults(&mut tphandler.borrow_mut().local); let crypto = Crypto::new(agent, protocols, tphandler.clone(), anti_replay) .expect("TLS should be configured successfully"); - Connection { + Self { version: QUIC_VERSION, role: r, state: match r { @@ -835,12 +836,12 @@ impl Connection { } fn process_migrations(&self, d: &Datagram) -> Res<()> { - if !self.paths.iter().any(|p| p.received_on(&d)) { + if self.paths.iter().any(|p| p.received_on(&d)) { + Ok(()) + } else { // Right now, we don't support any form of migration. // So generate an error if a packet is received on a new path. Err(Error::InvalidMigration) - } else { - Ok(()) } }