Skip to content

Commit

Permalink
chore: fix clippy lints and warnings (cloudflare#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah-Kennedy authored Feb 12, 2022
1 parent 50c9134 commit 39bb05b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/device/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl<'a, H> EventGuard<'a, H> {
}

pub fn fd(&self) -> i32 {
return self.event.fd;
self.event.fd
}

/// Change the event flags to enable or disable notifying when the fd is writable
Expand Down
2 changes: 1 addition & 1 deletion src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ impl Device {

let peer = match &parsed_packet {
Packet::HandshakeInit(p) => {
parse_handshake_anon(&private_key, &public_key, &p)
parse_handshake_anon(private_key, public_key, p)
.ok()
.and_then(|hh| {
d.peers
Expand Down
4 changes: 2 additions & 2 deletions src/device/tun_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ impl TunSocket {
pub fn new(name: &str) -> Result<TunSocket, Error> {
// If the provided name appears to be a FD, use that.
let provided_fd = name.parse::<i32>();
if provided_fd.is_ok() {
if let Ok(fd) = provided_fd {
return Ok(TunSocket {
fd: provided_fd.unwrap(),
fd,
name: name.to_string(),
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub extern "C" fn x25519_key_to_hex(key: x25519_key) -> *const c_char {
/// Frees memory of the string given by `x25519_key_to_hex` or `x25519_key_to_base64`
#[no_mangle]
pub unsafe extern "C" fn x25519_key_to_str_free(stringified_key: *mut c_char) {
CString::from_raw(stringified_key);
let _ = CString::from_raw(stringified_key);
}

/// Check if the input C-string represents a valid base64 encoded x25519 key.
Expand Down
4 changes: 2 additions & 2 deletions src/noise/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ impl Handshake {
// msg.sender_index = little_endian(initiator.sender_index)
sender_index.copy_from_slice(&local_index.to_le_bytes());
//msg.unencrypted_ephemeral = DH_PUBKEY(initiator.ephemeral_private)
unencrypted_ephemeral.copy_from_slice(&ephemeral_private.public_key().as_bytes());
unencrypted_ephemeral.copy_from_slice(ephemeral_private.public_key().as_bytes());
// initiator.hash = HASH(initiator.hash || msg.unencrypted_ephemeral)
hash = HASH!(hash, unencrypted_ephemeral);
// temp = HMAC(initiator.chaining_key, msg.unencrypted_ephemeral)
Expand Down Expand Up @@ -671,7 +671,7 @@ impl Handshake {
// msg.receiver_index = little_endian(initiator.sender_index)
receiver_index.copy_from_slice(&peer_index.to_le_bytes());
// msg.unencrypted_ephemeral = DH_PUBKEY(initiator.ephemeral_private)
unencrypted_ephemeral.copy_from_slice(&ephemeral_private.public_key().as_bytes());
unencrypted_ephemeral.copy_from_slice(ephemeral_private.public_key().as_bytes());
// responder.hash = HASH(responder.hash || msg.unencrypted_ephemeral)
hash = HASH!(hash, unencrypted_ephemeral);
// temp = HMAC(responder.chaining_key, msg.unencrypted_ephemeral)
Expand Down
6 changes: 3 additions & 3 deletions src/noise/rate_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl RateLimiter {
let (message_type, rest) = dst.split_at_mut(4);
let (receiver_index, rest) = rest.split_at_mut(4);
let (nonce, rest) = rest.split_at_mut(24);
let (mut encrypted_cookie, _) = rest.split_at_mut(16 + 16);
let (encrypted_cookie, _) = rest.split_at_mut(16 + 16);

// msg.message_type = 3
// msg.reserved_zero = { 0, 0, 0 }
Expand All @@ -142,10 +142,10 @@ impl RateLimiter {
nonce.copy_from_slice(&self.nonce()[..]);

ChaCha20Poly1305::new_aead(&self.cookie_key).xseal(
&nonce,
nonce,
mac1,
&cookie[..],
&mut encrypted_cookie,
encrypted_cookie,
);

Ok(&mut dst[..super::COOKIE_REPLY_SZ])
Expand Down

0 comments on commit 39bb05b

Please sign in to comment.