Skip to content

Commit

Permalink
Merge branch 'main' into chore-semicolon_inside_block
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert authored Jan 10, 2025
2 parents 3168be4 + 5aee532 commit 9f9a970
Show file tree
Hide file tree
Showing 51 changed files with 273 additions and 290 deletions.
17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ regex = { version = "1.9", default-features = false, features = ["unicode-perl"]
static_assertions = { version = "1.1", default-features = false }
url = { version = "2.5.3", default-features = false, features = ["std"] }

[workspace.lints.rust]
absolute_paths_not_starting_with_crate = "warn"
ambiguous_negative_literals = "warn"
closure_returning_async_block = "warn"
explicit_outlives_requirements = "warn"
macro_use_extern_crate = "warn"
missing_abi = "warn"
non_ascii_idents = "warn"
redundant_imports = "warn"
redundant_lifetimes = "warn"
trivial_numeric_casts = "warn"
unit_bindings = "warn"
unused_import_braces = "warn"
unused_lifetimes = "warn"
unused_macro_rules = "warn"
# unused_qualifications = "warn" // Try to re-enable when MSRV is > 1.76

[workspace.lints.clippy]
cargo = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
Expand Down
6 changes: 3 additions & 3 deletions neqo-bin/src/client/http09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
time::Instant,
};

use neqo_common::{event::Provider as _, qdebug, qinfo, qwarn, Datagram};
use neqo_common::{event::Provider, qdebug, qinfo, qwarn, Datagram};
use neqo_crypto::{AuthenticationStatus, ResumptionToken};
use neqo_transport::{
CloseReason, Connection, ConnectionEvent, ConnectionIdGenerator, EmptyConnectionIdGenerator,
Expand Down Expand Up @@ -61,7 +61,7 @@ impl super::Handler for Handler<'_> {
self.needs_key_update = false;
self.download_urls(client);
}
Err(neqo_transport::Error::KeyUpdateBlocked) => (),
Err(Error::KeyUpdateBlocked) => (),
Err(e) => return Err(e.into()),
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ impl super::Client for Connection {
}

fn has_events(&self) -> bool {
neqo_common::event::Provider::has_events(self)
Provider::has_events(self)
}
}

Expand Down
4 changes: 2 additions & 2 deletions neqo-bin/src/client/http3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::{
time::Instant,
};

use neqo_common::{event::Provider as _, hex, qdebug, qinfo, qwarn, Datagram, Header};
use neqo_common::{event::Provider, hex, qdebug, qinfo, qwarn, Datagram, Header};
use neqo_crypto::{AuthenticationStatus, ResumptionToken};
use neqo_http3::{Error, Http3Client, Http3ClientEvent, Http3Parameters, Http3State, Priority};
use neqo_transport::{
Expand Down Expand Up @@ -155,7 +155,7 @@ impl super::Client for Http3Client {
}

fn has_events(&self) -> bool {
neqo_common::event::Provider::has_events(self)
Provider::has_events(self)
}
}

Expand Down
8 changes: 4 additions & 4 deletions neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum Error {
IoError(io::Error),
QlogError(qlog::Error),
TransportError(neqo_transport::Error),
ApplicationError(neqo_transport::AppError),
ApplicationError(AppError),
CryptoError(neqo_crypto::Error),
}

Expand Down Expand Up @@ -82,8 +82,8 @@ impl From<neqo_transport::Error> for Error {
}
}

impl From<neqo_transport::CloseReason> for Error {
fn from(err: neqo_transport::CloseReason) -> Self {
impl From<CloseReason> for Error {
fn from(err: CloseReason) -> Self {
match err {
CloseReason::Transport(e) => Self::TransportError(e),
CloseReason::Application(e) => Self::ApplicationError(e),
Expand Down Expand Up @@ -184,7 +184,7 @@ impl Args {
pub fn new(requests: &[usize], upload: bool) -> Self {
use std::str::FromStr as _;
Self {
shared: crate::SharedArgs::default(),
shared: SharedArgs::default(),
urls: requests
.iter()
.map(|r| Url::from_str(&format!("http://[::1]:12345/{r}")).unwrap())
Expand Down
2 changes: 1 addition & 1 deletion neqo-bin/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Default for Args {
fn default() -> Self {
use std::str::FromStr as _;
Self {
shared: crate::SharedArgs::default(),
shared: SharedArgs::default(),
hosts: vec!["[::]:12345".to_string()],
db: PathBuf::from_str("../test-fixture/db").unwrap(),
key: "key".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions neqo-common/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::{fmt::Debug, mem::size_of};
use std::fmt::Debug;

use crate::hex_with_len;

Expand Down Expand Up @@ -111,7 +111,7 @@ impl<'a> Decoder<'a> {
/// unsigned integer types: `u8`, `u16`, `u32`, or `u64`.
/// Signed types will fail if the high bit is set.
pub fn decode_uint<T: TryFrom<u64>>(&mut self) -> Option<T> {
let v = self.decode_n(size_of::<T>());
let v = self.decode_n(std::mem::size_of::<T>());
v.and_then(|v| T::try_from(v).ok())
}

Expand Down
4 changes: 2 additions & 2 deletions neqo-common/src/hrtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl PeriodSet {
#[cfg(target_os = "macos")]
#[allow(non_camel_case_types)]
mod mac {
use std::{mem::size_of, ptr::addr_of_mut};
use std::ptr::addr_of_mut;

// These are manually extracted from the many bindings generated
// by bindgen when provided with the simple header:
Expand Down Expand Up @@ -126,7 +126,7 @@ mod mac {
const THREAD_TIME_CONSTRAINT_POLICY: thread_policy_flavor_t = 2;
#[allow(clippy::cast_possible_truncation)]
const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
(size_of::<thread_time_constraint_policy>() / size_of::<integer_t>())
(std::mem::size_of::<thread_time_constraint_policy>() / std::mem::size_of::<integer_t>())
as mach_msg_type_number_t;

// These function definitions are taken from a comment in <thread_policy.h>.
Expand Down
4 changes: 2 additions & 2 deletions neqo-common/src/qlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl NeqoQlog {
title,
description,
None,
std::time::Instant::now(),
Instant::now(),
new_trace(role),
qlog::events::EventImportance::Base,
Box::new(BufWriter::new(file)),
Expand Down Expand Up @@ -175,7 +175,7 @@ impl Drop for NeqoQlogShared {
}

#[must_use]
pub fn new_trace(role: Role) -> qlog::TraceSeq {
pub fn new_trace(role: Role) -> TraceSeq {
TraceSeq {
vantage_point: VantagePoint {
name: Some(format!("neqo-{role}")),
Expand Down
4 changes: 2 additions & 2 deletions neqo-crypto/src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
experimental_api,
p11::{PK11SymKey, SymKey},
scoped_ptr,
ssl::{self, PRUint16, PRUint64, PRUint8, SSLAeadContext},
ssl::{PRUint16, PRUint64, PRUint8, SSLAeadContext},
};

experimental_api!(SSL_MakeAead(
Expand Down Expand Up @@ -80,7 +80,7 @@ impl RealAead {
prefix: &str,
) -> Res<Self> {
let p = prefix.as_bytes();
let mut ctx: *mut ssl::SSLAeadContext = null_mut();
let mut ctx: *mut SSLAeadContext = null_mut();
SSL_MakeAead(
version,
cipher,
Expand Down
26 changes: 13 additions & 13 deletions neqo-crypto/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use std::{
cell::RefCell,
ffi::{CStr, CString},
mem::{self, MaybeUninit},
mem::MaybeUninit,
ops::{Deref, DerefMut},
os::raw::{c_uint, c_void},
pin::Pin,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl SecretAgentPreInfo {
ssl::SSL_GetPreliminaryChannelInfo(
fd,
info.as_mut_ptr(),
c_uint::try_from(mem::size_of::<ssl::SSLPreliminaryChannelInfo>())?,
c_uint::try_from(std::mem::size_of::<ssl::SSLPreliminaryChannelInfo>())?,
)
})?;

Expand Down Expand Up @@ -222,7 +222,7 @@ impl SecretAgentInfo {
ssl::SSL_GetChannelInfo(
fd,
info.as_mut_ptr(),
c_uint::try_from(mem::size_of::<ssl::SSLChannelInfo>())?,
c_uint::try_from(std::mem::size_of::<ssl::SSLChannelInfo>())?,
)
})?;
let info = unsafe { info.assume_init() };
Expand Down Expand Up @@ -349,8 +349,8 @@ impl SecretAgent {
unsafe extern "C" fn auth_complete_hook(
arg: *mut c_void,
_fd: *mut ssl::PRFileDesc,
_check_sig: ssl::PRBool,
_is_server: ssl::PRBool,
_check_sig: PRBool,
_is_server: PRBool,
) -> ssl::SECStatus {
let auth_required_ptr = arg.cast::<bool>();
*auth_required_ptr = true;
Expand Down Expand Up @@ -396,7 +396,7 @@ impl SecretAgent {

self.now.bind(self.fd)?;
self.configure(grease)?;
secstatus_to_res(unsafe { ssl::SSL_ResetHandshake(self.fd, ssl::PRBool::from(is_server)) })
secstatus_to_res(unsafe { ssl::SSL_ResetHandshake(self.fd, PRBool::from(is_server)) })
}

/// Default configuration.
Expand Down Expand Up @@ -440,13 +440,13 @@ impl SecretAgent {
for i in 0..cipher_count {
let p = all_ciphers.wrapping_add(i);
secstatus_to_res(unsafe {
ssl::SSL_CipherPrefSet(self.fd, i32::from(*p), ssl::PRBool::from(false))
ssl::SSL_CipherPrefSet(self.fd, i32::from(*p), PRBool::from(false))
})?;
}

for c in ciphers {
secstatus_to_res(unsafe {
ssl::SSL_CipherPrefSet(self.fd, i32::from(*c), ssl::PRBool::from(true))
ssl::SSL_CipherPrefSet(self.fd, i32::from(*c), PRBool::from(true))
})?;
}
Ok(())
Expand Down Expand Up @@ -882,7 +882,7 @@ impl Client {
token,
len,
info.as_mut_ptr(),
c_uint::try_from(mem::size_of::<ssl::SSLResumptionTokenInfo>()).unwrap(),
c_uint::try_from(std::mem::size_of::<ssl::SSLResumptionTokenInfo>()).unwrap(),
);
if info_res.is_err() {
// Ignore the token.
Expand Down Expand Up @@ -1022,7 +1022,7 @@ pub enum ZeroRttCheckResult {

/// A `ZeroRttChecker` is used by the agent to validate the application token (as provided by
/// `send_ticket`)
pub trait ZeroRttChecker: std::fmt::Debug + std::marker::Unpin {
pub trait ZeroRttChecker: std::fmt::Debug + Unpin {
fn check(&self, token: &[u8]) -> ZeroRttCheckResult;
}

Expand Down Expand Up @@ -1074,7 +1074,7 @@ impl Server {
return Err(Error::CertificateLoading);
};
let key_ptr = unsafe { p11::PK11_FindKeyByAnyCert(*cert, null_mut()) };
let Ok(key) = p11::PrivateKey::from_ptr(key_ptr) else {
let Ok(key) = PrivateKey::from_ptr(key_ptr) else {
return Err(Error::CertificateLoading);
};
secstatus_to_res(unsafe {
Expand Down Expand Up @@ -1219,8 +1219,8 @@ impl ::std::fmt::Display for Server {
/// A generic container for Client or Server.
#[derive(Debug)]
pub enum Agent {
Client(crate::agent::Client),
Server(crate::agent::Server),
Client(Client),
Server(Server),
}

impl Deref for Agent {
Expand Down
4 changes: 2 additions & 2 deletions neqo-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod nss {

// Need to map the types through.
fn secstatus_to_res(code: nss::SECStatus) -> Res<()> {
crate::err::secstatus_to_res(code as crate::ssl::SECStatus)
err::secstatus_to_res(code)
}

enum NssLoaded {
Expand Down Expand Up @@ -106,7 +106,7 @@ fn version_check() -> Res<()> {
/// This allows us to use SSLTRACE in all of our unit tests and programs.
#[cfg(debug_assertions)]
fn enable_ssl_trace() -> Res<()> {
let opt = ssl::Opt::Locking.as_int();
let opt = Opt::Locking.as_int();
let mut v: ::std::os::raw::c_int = 0;
secstatus_to_res(unsafe { ssl::SSL_OptionGetDefault(opt, &mut v) })
}
Expand Down
3 changes: 1 addition & 2 deletions neqo-crypto/src/p11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use std::{
cell::RefCell,
mem,
ops::{Deref, DerefMut},
os::raw::c_uint,
ptr::null_mut,
Expand Down Expand Up @@ -265,7 +264,7 @@ impl Item {
SECItem {
type_: SECItemType::siBuffer,
data: data.cast_mut().cast(),
len: c_uint::try_from(mem::size_of::<T>()).unwrap(),
len: c_uint::try_from(std::mem::size_of::<T>()).unwrap(),
}
}

Expand Down
6 changes: 2 additions & 4 deletions neqo-crypto/tests/hp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::mem;

use neqo_crypto::{
constants::{
Cipher, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256,
Expand Down Expand Up @@ -71,12 +69,12 @@ fn chacha20_ctr() {
#[should_panic(expected = "out of range")]
fn aes_short() {
let hp = make_hp(TLS_AES_128_GCM_SHA256);
mem::drop(hp.mask(&[0; 15]));
drop(hp.mask(&[0; 15]));
}

#[test]
#[should_panic(expected = "out of range")]
fn chacha20_short() {
let hp = make_hp(TLS_CHACHA20_POLY1305_SHA256);
mem::drop(hp.mask(&[0; 15]));
drop(hp.mask(&[0; 15]));
}
Loading

0 comments on commit 9f9a970

Please sign in to comment.