Skip to content

Fixed most recent nightly clippy warnings #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/client-libs/gateway-client/src/socket_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ impl PartiallyDelegated {
// this call failing is incredibly unlikely, but not impossible.
// basically the gateway connection must have failed after executing previous line but
// before starting execution of this one.
if notify.send(()).is_err() {
return Err(GatewayClientError::ConnectionAbruptlyClosed);
}
notify
.send(())
.map_err(|_| GatewayClientError::ConnectionAbruptlyClosed)?;

let stream_results: Result<_, GatewayClientError> = stream_receiver
.await
Expand Down
11 changes: 2 additions & 9 deletions common/crypto/src/hkdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ use digest::{BlockInput, FixedOutput, Reset, Update};
use generic_array::ArrayLength;
use hkdf::Hkdf;

#[derive(Debug)]
pub enum HkdfError {
InvalidOkmLength,
}

/// Perform HKDF `extract` then `expand` as a single step.
pub fn extract_then_expand<D>(
salt: Option<&[u8]>,
ikm: &[u8],
info: Option<&[u8]>,
okm_length: usize,
) -> Result<Vec<u8>, HkdfError>
) -> Result<Vec<u8>, hkdf::InvalidLength>
where
D: Update + BlockInput + FixedOutput + Reset + Default + Clone,
D::BlockSize: ArrayLength<u8>,
Expand All @@ -27,9 +22,7 @@ where

let hkdf = Hkdf::<D>::new(salt, ikm);
let mut okm = vec![0u8; okm_length];
if hkdf.expand(info.unwrap_or_else(|| &[]), &mut okm).is_err() {
return Err(HkdfError::InvalidOkmLength);
}
hkdf.expand(info.unwrap_or_else(|| &[]), &mut okm)?;

Ok(okm)
}
8 changes: 3 additions & 5 deletions common/nymsphinx/src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,9 @@ impl MessageReceiver {
};

// Finally, remove the zero padding from the message
if Self::remove_padding(&mut message).is_err() {
return Err(MessageRecoveryError::MalformedReconstructedMessage(
used_sets,
));
};
Self::remove_padding(&mut message).map_err(|_| {
MessageRecoveryError::MalformedReconstructedMessage(used_sets.clone())
})?;

Ok(Some((
ReconstructedMessage {
Expand Down