Skip to content

Commit 7d84ef9

Browse files
committed
Allows for erroneous Clippy lints
Signed-off-by: Mathias Hall-Andersen <[email protected]>
1 parent 1fb7975 commit 7d84ef9

File tree

10 files changed

+30
-14
lines changed

10 files changed

+30
-14
lines changed

src/platform/linux/tun.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ impl Tun for LinuxTun {
318318
impl PlatformTun for LinuxTun {
319319
type Status = LinuxTunStatus;
320320

321+
#[allow(clippy::type_complexity)]
321322
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error> {
322323
// construct request struct
323324
let mut req = Ifreq {

src/platform/linux/udp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,8 @@ impl LinuxUDP {
666666
impl PlatformUDP for LinuxUDP {
667667
type Owner = LinuxOwner;
668668

669+
#[allow(clippy::type_complexity)]
670+
#[allow(clippy::unnecessary_unwrap)]
669671
fn bind(mut port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error> {
670672
log::debug!("bind to port {}", port);
671673

src/platform/tun.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ pub trait Tun: Send + Sync + 'static {
5858
pub trait PlatformTun: Tun {
5959
type Status: Status;
6060

61+
#[allow(clippy::type_complexity)]
6162
fn create(name: &str) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Status), Self::Error>;
6263
}

src/platform/udp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ pub trait PlatformUDP: UDP {
4141
/// Bind to a new port, returning the reader/writer and
4242
/// an associated instance of the owner type, which closes the UDP socket upon "drop"
4343
/// and enables configuration of the fwmark value.
44+
#[allow(clippy::type_complexity)]
4445
fn bind(port: u16) -> Result<(Vec<Self::Reader>, Self::Writer, Self::Owner), Self::Error>;
4546
}

src/wireguard/handshake/macs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ impl Generator {
141141
pub fn process(&mut self, reply: &CookieReply) -> Result<(), HandshakeError> {
142142
let mac1 = self.last_mac1.ok_or(HandshakeError::InvalidState)?;
143143
let mut tau = [0u8; SIZE_COOKIE];
144+
#[allow(clippy::unnecessary_mut_passed)]
144145
XOPEN!(
145146
&self.cookie_key, // key
146147
&reply.f_nonce, // nonce

src/wireguard/handshake/ratelimiter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ impl Drop for RateLimiter {
3737

3838
impl RateLimiter {
3939
pub fn new() -> Self {
40+
#[allow(clippy::mutex_atomic)]
4041
RateLimiter(Arc::new(RateLimiterInner {
4142
gc_dropped: (Mutex::new(false), Condvar::new()),
4243
gc_running: AtomicBool::from(false),
@@ -143,7 +144,7 @@ mod tests {
143144
expected.push(Result {
144145
allowed: true,
145146
wait: Duration::new(0, 0),
146-
text: "inital burst",
147+
text: "initial burst",
147148
});
148149
}
149150

src/wireguard/mod.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
/* The wireguard sub-module represents a full, pure, WireGuard implementation:
2-
*
3-
* The WireGuard device described here does not depend on particular IO implementations
4-
* or UAPI, and can be instantiated in unit-tests with the dummy IO implementation.
5-
*
6-
* The code at this level serves to "glue" the handshake state-machine
7-
* and the crypto-key router code together,
8-
* e.g. every WireGuard peer consists of a handshake and router peer.
9-
*/
1+
/// The wireguard sub-module represents a full, pure, WireGuard implementation:
2+
///
3+
/// The WireGuard device described here does not depend on particular IO implementations
4+
/// or UAPI, and can be instantiated in unit-tests with the dummy IO implementation.
5+
///
6+
/// The code at this level serves to "glue" the handshake state-machine
7+
/// and the crypto-key router code together,
8+
/// e.g. every WireGuard peer consists of one handshake peer and one router peer.
109
mod constants;
1110
mod handshake;
1211
mod peer;
1312
mod queue;
1413
mod router;
1514
mod timers;
1615
mod types;
17-
mod wireguard;
1816
mod workers;
1917

2018
#[cfg(test)]
2119
mod tests;
2220

21+
#[allow(clippy::module_inception)]
22+
mod wireguard;
23+
2324
// represents a WireGuard interface
2425
pub use wireguard::WireGuard;
2526

src/wireguard/router/device.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub struct DeviceInner<E: Endpoint, C: Callbacks, T: tun::Writer, B: udp::Writer
3030
pub(super) outbound: RwLock<(bool, Option<B>)>,
3131

3232
// routing
33+
#[allow(clippy::type_complexity)]
3334
pub(super) recv: RwLock<HashMap<u32, Arc<DecryptionState<E, C, T, B>>>>, /* receiver id -> decryption state */
3435
pub(super) table: RoutingTable<Peer<E, C, T, B>>,
3536

src/wireguard/router/tests/bench.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,26 @@ struct TransmissionCounter {
2525
}
2626

2727
impl TransmissionCounter {
28+
#[allow(dead_code)]
2829
fn new() -> TransmissionCounter {
2930
TransmissionCounter {
3031
sent: AtomicUsize::new(0),
3132
recv: AtomicUsize::new(0),
3233
}
3334
}
3435

36+
#[allow(dead_code)]
3537
fn reset(&self) {
3638
self.sent.store(0, Ordering::SeqCst);
3739
self.recv.store(0, Ordering::SeqCst);
3840
}
3941

42+
#[allow(dead_code)]
4043
fn sent(&self) -> usize {
4144
self.sent.load(Ordering::Acquire)
4245
}
4346

47+
#[allow(dead_code)]
4448
fn recv(&self) -> usize {
4549
self.recv.load(Ordering::Acquire)
4650
}

src/wireguard/wireguard.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@ use super::udp::UDP;
1313
use super::workers::{handshake_worker, tun_worker, udp_worker};
1414

1515
use std::fmt;
16+
use std::thread;
17+
1618
use std::ops::Deref;
1719
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
1820
use std::sync::Arc;
1921
use std::sync::Condvar;
2022
use std::sync::Mutex as StdMutex;
21-
use std::thread;
2223
use std::time::Instant;
2324

24-
use hjul::Runner;
2525
use rand::rngs::OsRng;
2626
use rand::Rng;
27-
use spin::{Mutex, RwLock};
2827

28+
use hjul::Runner;
29+
use spin::{Mutex, RwLock};
2930
use x25519_dalek::{PublicKey, StaticSecret};
3031

3132
pub struct WireguardInner<T: Tun, B: UDP> {
@@ -45,6 +46,7 @@ pub struct WireguardInner<T: Tun, B: UDP> {
4546
pub mtu: AtomicUsize,
4647

4748
// peer map
49+
#[allow(clippy::type_complexity)]
4850
pub peers: RwLock<
4951
handshake::Device<router::PeerHandle<B::Endpoint, PeerInner<T, B>, T::Writer, B::Writer>>,
5052
>,
@@ -85,6 +87,7 @@ impl<T: Tun, B: UDP> Clone for WireGuard<T, B> {
8587
}
8688
}
8789

90+
#[allow(clippy::mutex_atomic)]
8891
impl WaitCounter {
8992
pub fn wait(&self) {
9093
let mut nread = self.0.lock().unwrap();

0 commit comments

Comments
 (0)